Hi so I am trying to make a item that can move a tile entity and blocks from a location to another which works with blocks however if I move a tile entity one of two things will happen if it is a furnace it will move but the items will pop out and fuel level gets removed so the furnace is no longer burning. The other thing is that if you move a chest all the items pop out and the chest is empty when it gets to the final location. Here is the code I have any help is appreciated.
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (stack.getTagCompound() == null) {
stack.setTagCompound(new NBTTagCompound());
}
if (world.getBlockState(pos).getBlock().equals(ModBlocks.block_warper)) {
stack.getTagCompound().setDouble("x", pos.getX());
stack.getTagCompound().setDouble("y", pos.getY());
stack.getTagCompound().setDouble("z", pos.getZ());
stack.getTagCompound().setBoolean("linked", true);
}
if (!world.getBlockState(pos).getBlock().equals(ModBlocks.block_warper)) {
BlockPos targetPos = new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ());
IBlockState targetBlockState = world.getBlockState(new BlockPos(stack.getTagCompound().getDouble("x"), stack.getTagCompound().getDouble("y") + 1, stack.getTagCompound().getDouble("z")));
if (world.getBlockState(targetPos).getBlock().equals(Blocks.air)) {
world.setBlockState(targetPos, targetBlockState);
if (!(world.getTileEntity(new BlockPos(stack.getTagCompound().getDouble("x"), stack.getTagCompound().getDouble("y") + 1, stack.getTagCompound().getDouble("z"))) == null)) {
world.setTileEntity(targetPos, world.getTileEntity(new BlockPos(stack.getTagCompound().getDouble("x"), stack.getTagCompound().getDouble("y") + 1, stack.getTagCompound().getDouble("z"))));
}
world.setBlockToAir(new BlockPos(stack.getTagCompound().getDouble("x"), stack.getTagCompound().getDouble("y") + 1, stack.getTagCompound().getDouble("z")));
}
}
return EnumActionResult.PASS;
}