From 9aaaeb9ed0be206ae3d2fa61c413f09bd0433b66 Mon Sep 17 00:00:00 2001 From: Shadows_of_Fire Date: Mon, 19 Mar 2018 12:50:18 -0400 Subject: [PATCH] Fixes #1043 Includes a change that might also resolve #1041 in creative mode, but that's untested. --- .../mod/blocks/base/BlockContainerBase.java | 6 ++---- .../actuallyadditions/mod/tile/TileEntityBase.java | 12 ++++++------ .../actuallyadditions/mod/util/WorldUtil.java | 6 +----- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java index 8347eb505..48ffad112 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java @@ -217,10 +217,8 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player){ if(!player.capabilities.isCreativeMode){ TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityBase){ - if(((TileEntityBase)tile).stopFromDropping){ - player.sendMessage(new TextComponentTranslation("info."+ModUtil.MOD_ID+".machineBroke").setStyle(new Style().setColor(TextFormatting.RED))); - } + if(tile instanceof TileEntityBase && ((TileEntityBase)tile).stopFromDropping){ + player.sendMessage(new TextComponentTranslation("info."+ModUtil.MOD_ID+".machineBroke").setStyle(new Style().setColor(TextFormatting.RED))); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java index 158a7bfa1..6a4a4773a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java @@ -174,30 +174,30 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ } public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ - if(type != NBTType.SAVE_BLOCK){ - super.writeToNBT(compound); - } + if(type != NBTType.SAVE_BLOCK) super.writeToNBT(compound); if(type == NBTType.SAVE_TILE){ compound.setBoolean("Redstone", this.isRedstonePowered); compound.setInteger("TicksElapsed", this.ticksElapsed); compound.setBoolean("StopDrop", this.stopFromDropping); } + else if(type == NBTType.SYNC && stopFromDropping) compound.setBoolean("StopDrop", this.stopFromDropping); + if(this.isRedstoneToggle() && (type != NBTType.SAVE_BLOCK || this.isPulseMode)){ compound.setBoolean("IsPulseMode", this.isPulseMode); } } public void readSyncableNBT(NBTTagCompound compound, NBTType type){ - if(type != NBTType.SAVE_BLOCK){ - super.readFromNBT(compound); - } + if(type != NBTType.SAVE_BLOCK) super.readFromNBT(compound); if(type == NBTType.SAVE_TILE){ this.isRedstonePowered = compound.getBoolean("Redstone"); this.ticksElapsed = compound.getInteger("TicksElapsed"); this.stopFromDropping = compound.getBoolean("StopDrop"); } + else if(type == NBTType.SYNC) this.stopFromDropping = compound.getBoolean("StopDrop"); + if(this.isRedstoneToggle()){ this.isPulseMode = compound.getBoolean("IsPulseMode"); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java index 0e1d590e8..16ade3c23 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java @@ -376,7 +376,6 @@ public final class WorldUtil { Block block = state.getBlock(); if (player.capabilities.isCreativeMode) { - block.onBlockHarvested(world, pos, state, player); if (block.removedByPlayer(state, world, pos, player, false)) { block.onBlockDestroyedByPlayer(world, pos, state); } @@ -395,12 +394,9 @@ public final class WorldUtil { if (!world.isRemote) { // send the blockbreak event int xp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, pos); - if (xp == -1) { return false; } - - // serverside we reproduce ItemInWorldManager.tryHarvestBlock + if (xp == -1) return false; TileEntity tileEntity = world.getTileEntity(pos); - // ItemInWorldManager.removeBlock if (block.removedByPlayer(state, world, pos, player, true)) { // boolean is if block can be harvested, checked above block.onBlockDestroyedByPlayer(world, pos, state); block.harvestBlock(world, player, pos, state, tileEntity, stack);