Skip to content

Instantly share code, notes, and snippets.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
//Check if the metadata value is 0 -- we don't want the user to replace Ancient Fabric
if (heldItem != null && state.getValue(TYPE) != 1) {
Block block = Block.getBlockFromItem(heldItem.getItem());
if (!state.isNormalCube() || block instanceof BlockContainer || block == this || player.isSneaking()) {
return false;
}
if (!world.isRemote) {
if (!player.capabilities.isCreativeMode) {
It should only create the TileEntity once, however it seems to create it twice.
These are the stacktraces that show up after placing down a door.
First one:
at com.zixiken.dimdoors.blocks.BlockDimDoorBase.createTileEntity(BlockDimDoorBase.java:70) ~[BlockDimDoorBase.class:?]
at net.minecraft.world.chunk.Chunk.setBlockState(Chunk.java:666) ~[Chunk.class:?]
at net.minecraft.world.World.setBlockState(World.java:384) ~[World.class:?]
at net.minecraft.item.ItemDoor.placeDoor(ItemDoor.java:89) ~[ItemDoor.class:?]
at com.zixiken.dimdoors.items.ItemDoorBase.placeDoorOnBlock(ItemDoorBase.java:122) ~[ItemDoorBase.class:?]
at com.zixiken.dimdoors.items.ItemDoorBase.tryToPlaceDoor(ItemDoorBase.java:89) ~[ItemDoorBase.class:?]
[02:56:36] [Client thread/INFO] [FML]: [DimDoors] onItemUse world is Remote (class com.zixiken.dimdoors.items.ItemDimDoor )
[02:56:36] [Client thread/INFO] [FML]: [DimDoors] onItemRightClick world is Remote (class com.zixiken.dimdoors.items.ItemDimDoor )
[02:56:36] [Server thread/INFO] [STDERR]: [java.lang.Thread:dumpStack:1333]: java.lang.Exception: Stack trace
[02:56:36] [Server thread/INFO] [STDERR]: [java.lang.Thread:dumpStack:1333]: at java.lang.Thread.dumpStack(Thread.java:1333)
[02:56:36] [Server thread/INFO] [STDERR]: [java.lang.Thread:dumpStack:1333]: at com.zixiken.dimdoors.tileentities.DDTileEntityBase.<init>(DDTileEntityBase.java:21)
[02:56:36] [Server thread/INFO] [STDERR]: [java.lang.Thread:dumpStack:1333]: at com.zixiken.dimdoors.tileentities.TileEntityDimDoor.<init>(TileEntityDimDoor.java:8)
[02:56:36] [Server thread/INFO] [STDERR]: [java.lang.Thread:dumpStack:1333]: at com.zixiken.dimdoors.blocks.BlockDimDoorBase.createNewTileEntity(BlockDimDoorBase.java:108)
[02:56:36] [Server thread/INF
public static void teleport(Entity entity, Location location) {
PlayerList playerList = Minecraft.getMinecraft().getIntegratedServer().getPlayerList();
Teleporter tele = new TeleportHelper(location);
if (entity instanceof EntityPlayerMP) {
playerList.transferPlayerToDimension((EntityPlayerMP) entity, location.getDimensionID(), tele);
} else {
playerList.transferEntityToWorld(entity, entity.dimension, DimDoors.proxy.getWorldServer(entity.dimension), location.getWorld(), tele);
}
}
[05:04:11] [Server thread/INFO] [FML]: [DimDoors] transFerPlayerToDimension (class com.zixiken.dimdoors.shared.Location )
[05:04:11] [Server thread/INFO] [FML]: [DimDoors] transFerPlayerToDimension (class com.zixiken.dimdoors.shared.Location )
[05:04:11] [Server thread/WARN]: Player440 moved wrongly!
[05:04:11] [Client thread/INFO] [FML]: [DimDoors] Printing stacktrace for debugging purposes: (class com.zixiken.dimdoors.tileentities.TileEntityRift )
[05:04:11] [Client thread/INFO] [STDERR]: [java.lang.Thread:dumpStack:1333]: java.lang.Exception: Stack trace
[05:04:11] [Client thread/INFO] [STDERR]: [java.lang.Thread:dumpStack:1333]: at java.lang.Thread.dumpStack(Thread.java:1333)
[05:04:11] [Client thread/INFO] [STDERR]: [java.lang.Thread:dumpStack:1333]: at com.zixiken.dimdoors.tileentities.DDTileEntityBase.<init>(DDTileEntityBase.java:23)
[05:04:11] [Client thread/INFO] [STDERR]: [java.lang.Thread:dumpStack:1333]: at com.zixiken.dimdoors.tileentities.TileEntityRift.<init>(TileEntityRift.java:36)
[05:04:1
at java.lang.Thread.dumpStack(Thread.java:1333)
at com.zixiken.dimdoors.tileentities.DDTileEntityBase.<init>(DDTileEntityBase.java:22)
at com.zixiken.dimdoors.tileentities.TileEntityDimDoor.<init>(TileEntityDimDoor.java:10)
at com.zixiken.dimdoors.blocks.BlockDimDoorBase.createNewTileEntity(BlockDimDoorBase.java:117)
at net.minecraft.block.Block.createTileEntity(Block.java:1206)
at net.minecraft.world.chunk.Chunk.setBlockState(Chunk.java:621)
at net.minecraft.world.World.setBlockState(World.java:331)
at net.minecraft.item.ItemDoor.placeDoor(ItemDoor.java:86)
at com.zixiken.dimdoors.items.ItemDoorBase.onItemUse(ItemDoorBase.java:114)
at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:780)
if (blockString.startsWith("dimdoors")) {
String dimdoorsBlockName = blockString.split(":")[1];
if (dimdoorsBlockName.equals("Fabric of RealityPerm")) { //only special case, because this is now another state of another block
isAncientFabric = true;
} else {
dimdoorsBlockName = convertOldDimDoorsBlockNameToNewDimDoorsBlockName(dimdoorsBlockName);
blockString = "dimdoors:" + dimdoorsBlockName;
}
}
IBlockState blockstate;
Test the opening of the new schematic type (.schem)
Test the placement of schematics
Write a method to write a schematic's nbt to disk
Write a Teleportation handler like the one BloodMagic uses
Add Config option for Dim-ID (default 684)
public void saveSchematic(Schematic schematic, String name) {
NBTTagCompound schematicNBT = Schematic.saveToNBT(schematic);
File saveFolder = new File(DDConfig.configurationFolder, "/Schematics/Saved");
if (!saveFolder.exists()) {
saveFolder.mkdirs();
}
File saveFile = new File(saveFolder.getAbsolutePath() + "/" + name + ".schem");
try {
saveFile.createNewFile();
{
"biomeName" : "<customBiomeName>",
"topBlock" :
{
"block": "minecraft:stone",
"properties":
{
"type": "<cobble>"
}
},