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){
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)));
}
}
}

View file

@ -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");
}

View file

@ -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);