Includes a change that might also resolve #1041 in creative mode, but
that's untested.
This commit is contained in:
Shadows_of_Fire 2018-03-19 12:50:18 -04:00
parent 8cd9c6a095
commit 9aaaeb9ed0
3 changed files with 9 additions and 15 deletions

View file

@ -217,10 +217,8 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player){ public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player){
if(!player.capabilities.isCreativeMode){ if(!player.capabilities.isCreativeMode){
TileEntity tile = world.getTileEntity(pos); TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityBase){ if(tile instanceof TileEntityBase && ((TileEntityBase)tile).stopFromDropping){
if(((TileEntityBase)tile).stopFromDropping){ player.sendMessage(new TextComponentTranslation("info."+ModUtil.MOD_ID+".machineBroke").setStyle(new Style().setColor(TextFormatting.RED)));
player.sendMessage(new TextComponentTranslation("info."+ModUtil.MOD_ID+".machineBroke").setStyle(new Style().setColor(TextFormatting.RED)));
}
} }
} }
} }

View file

@ -174,30 +174,30 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
} }
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
if(type != NBTType.SAVE_BLOCK){ if(type != NBTType.SAVE_BLOCK) super.writeToNBT(compound);
super.writeToNBT(compound);
}
if(type == NBTType.SAVE_TILE){ if(type == NBTType.SAVE_TILE){
compound.setBoolean("Redstone", this.isRedstonePowered); compound.setBoolean("Redstone", this.isRedstonePowered);
compound.setInteger("TicksElapsed", this.ticksElapsed); compound.setInteger("TicksElapsed", this.ticksElapsed);
compound.setBoolean("StopDrop", this.stopFromDropping); 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)){ if(this.isRedstoneToggle() && (type != NBTType.SAVE_BLOCK || this.isPulseMode)){
compound.setBoolean("IsPulseMode", this.isPulseMode); compound.setBoolean("IsPulseMode", this.isPulseMode);
} }
} }
public void readSyncableNBT(NBTTagCompound compound, NBTType type){ public void readSyncableNBT(NBTTagCompound compound, NBTType type){
if(type != NBTType.SAVE_BLOCK){ if(type != NBTType.SAVE_BLOCK) super.readFromNBT(compound);
super.readFromNBT(compound);
}
if(type == NBTType.SAVE_TILE){ if(type == NBTType.SAVE_TILE){
this.isRedstonePowered = compound.getBoolean("Redstone"); this.isRedstonePowered = compound.getBoolean("Redstone");
this.ticksElapsed = compound.getInteger("TicksElapsed"); this.ticksElapsed = compound.getInteger("TicksElapsed");
this.stopFromDropping = compound.getBoolean("StopDrop"); this.stopFromDropping = compound.getBoolean("StopDrop");
} }
else if(type == NBTType.SYNC) this.stopFromDropping = compound.getBoolean("StopDrop");
if(this.isRedstoneToggle()){ if(this.isRedstoneToggle()){
this.isPulseMode = compound.getBoolean("IsPulseMode"); this.isPulseMode = compound.getBoolean("IsPulseMode");
} }

View file

@ -376,7 +376,6 @@ public final class WorldUtil {
Block block = state.getBlock(); Block block = state.getBlock();
if (player.capabilities.isCreativeMode) { if (player.capabilities.isCreativeMode) {
block.onBlockHarvested(world, pos, state, player);
if (block.removedByPlayer(state, world, pos, player, false)) { if (block.removedByPlayer(state, world, pos, player, false)) {
block.onBlockDestroyedByPlayer(world, pos, state); block.onBlockDestroyedByPlayer(world, pos, state);
} }
@ -395,12 +394,9 @@ public final class WorldUtil {
if (!world.isRemote) { if (!world.isRemote) {
// send the blockbreak event // send the blockbreak event
int xp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, pos); int xp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, pos);
if (xp == -1) { return false; } if (xp == -1) return false;
// serverside we reproduce ItemInWorldManager.tryHarvestBlock
TileEntity tileEntity = world.getTileEntity(pos); TileEntity tileEntity = world.getTileEntity(pos);
// ItemInWorldManager.removeBlock
if (block.removedByPlayer(state, world, pos, player, true)) { // boolean is if block can be harvested, checked above if (block.removedByPlayer(state, world, pos, player, true)) { // boolean is if block can be harvested, checked above
block.onBlockDestroyedByPlayer(world, pos, state); block.onBlockDestroyedByPlayer(world, pos, state);
block.harvestBlock(world, player, pos, state, tileEntity, stack); block.harvestBlock(world, player, pos, state, tileEntity, stack);