mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Fixes #1043
Includes a change that might also resolve #1041 in creative mode, but that's untested.
This commit is contained in:
parent
8cd9c6a095
commit
9aaaeb9ed0
3 changed files with 9 additions and 15 deletions
|
@ -217,13 +217,11 @@ 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){
|
||||
if(tile instanceof TileEntityBase && ((TileEntityBase)tile).stopFromDropping){
|
||||
player.sendMessage(new TextComponentTranslation("info."+ModUtil.MOD_ID+".machineBroke").setStyle(new Style().setColor(TextFormatting.RED)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(IBlockState state){
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue