diff --git a/src/main/java/slimeknights/mantle/block/InventoryBlock.java b/src/main/java/slimeknights/mantle/block/InventoryBlock.java index 7d98810..5f0e584 100644 --- a/src/main/java/slimeknights/mantle/block/InventoryBlock.java +++ b/src/main/java/slimeknights/mantle/block/InventoryBlock.java @@ -57,8 +57,7 @@ public abstract class InventoryBlock extends Block { } @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, - ItemStack stack) { + public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { super.onBlockPlacedBy(worldIn, pos, state, placer, stack); // set custom name from named stack @@ -74,8 +73,6 @@ public abstract class InventoryBlock extends Block { @Override public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (state.getBlock() != newState.getBlock()) { - super.onReplaced(state, worldIn, pos, newState, isMoving); - TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof InventoryTileEntity) { @@ -83,6 +80,8 @@ public abstract class InventoryBlock extends Block { worldIn.updateComparatorOutputLevel(pos, this); } } + + super.onReplaced(state, worldIn, pos, newState, isMoving); } // BlockContainer sets this to invisible @@ -104,6 +103,6 @@ public abstract class InventoryBlock extends Block { @Nullable public INamedContainerProvider getContainer(BlockState state, World worldIn, BlockPos pos) { TileEntity tileentity = worldIn.getTileEntity(pos); - return tileentity instanceof INamedContainerProvider ? (INamedContainerProvider)tileentity : null; + return tileentity instanceof INamedContainerProvider ? (INamedContainerProvider) tileentity : null; } -} \ No newline at end of file +} diff --git a/src/main/java/slimeknights/mantle/tileentity/InventoryTileEntity.java b/src/main/java/slimeknights/mantle/tileentity/InventoryTileEntity.java index 4c531db..4c4ca64 100644 --- a/src/main/java/slimeknights/mantle/tileentity/InventoryTileEntity.java +++ b/src/main/java/slimeknights/mantle/tileentity/InventoryTileEntity.java @@ -82,7 +82,9 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II return !this.getStackInSlot(slot).isEmpty(); } - /** Same as resize, but does not call markDirty. Used on loading from NBT */ + /** + * Same as resize, but does not call markDirty. Used on loading from NBT + */ private void resizeInternal(int size) { // save effort if the size did not change if (size == this.inventory.size()) { @@ -191,11 +193,10 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II @Override public boolean hasCustomName() { - return this.hasCustomName; + return this.getCustomName() != null; } public void setCustomName(ITextComponent customName) { - this.hasCustomName = true; this.inventoryTitle = customName; } @@ -223,9 +224,7 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II return false; } - return - entityplayer.getDistanceSq(this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D) - <= 64D; + return entityplayer.getDistanceSq(this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D) <= 64D; } @Override @@ -266,7 +265,9 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II return tags; } - /** Writes the contents of the inventory to the tag */ + /** + * Writes the contents of the inventory to the tag + */ public void writeInventoryToNBT(CompoundNBT tag) { IInventory inventory = this; ListNBT nbttaglist = new ListNBT(); @@ -283,7 +284,9 @@ public abstract class InventoryTileEntity extends MantleTileEntity implements II tag.put("Items", nbttaglist); } - /** Reads a an inventory from the tag. Overwrites current content */ + /** + * Reads a an inventory from the tag. Overwrites current content + */ public void readInventoryFromNBT(CompoundNBT tag) { ListNBT nbttaglist = tag.getList("Items", 10); diff --git a/src/main/java/slimeknights/mantle/util/TileEntityUtil.java b/src/main/java/slimeknights/mantle/util/TileEntityUtil.java index 6ba7c1f..042da69 100644 --- a/src/main/java/slimeknights/mantle/util/TileEntityUtil.java +++ b/src/main/java/slimeknights/mantle/util/TileEntityUtil.java @@ -10,6 +10,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class TileEntityUtil { + @Nullable public static T getTileEntity(@Nonnull Class clazz, @Nullable IBlockReader world, @Nonnull BlockPos pos) { return getTileEntity(clazz, world, pos, false); @@ -17,7 +18,6 @@ public class TileEntityUtil { @Nullable public static T getTileEntity(@Nonnull Class clazz, @Nullable IBlockReader world, @Nonnull BlockPos pos, boolean logWrongType) { - System.out.println("world: " + world + " pos: " + pos); if (!isBlockLoaded(world, pos)) { return null; } @@ -25,8 +25,6 @@ public class TileEntityUtil { //TODO: This causes freezes if being called from onLoad TileEntity tile = world.getTileEntity(pos); - System.out.println("world: " + world + " pos: " + pos + " tile: " + tile); - if (tile == null) { return null; }