Tiles now save that they're powered by redstone so that they won't be unpowered on re-entering chunks

This commit is contained in:
Ellpeck 2015-12-13 15:13:56 +01:00
parent eb88a33b03
commit 94f84d68b1
2 changed files with 4 additions and 1 deletions

View file

@ -125,10 +125,11 @@ public abstract class BlockContainerBase extends BlockContainer{
this.updateRedstoneState(world, x, y, z); this.updateRedstoneState(world, x, y, z);
} }
private void updateRedstoneState(World world, int x, int y, int z){ public void updateRedstoneState(World world, int x, int y, int z){
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityBase){ if(tile instanceof TileEntityBase){
((TileEntityBase)tile).setRedstonePowered(world.isBlockIndirectlyGettingPowered(x, y, z)); ((TileEntityBase)tile).setRedstonePowered(world.isBlockIndirectlyGettingPowered(x, y, z));
tile.markDirty();
} }
} }

View file

@ -76,12 +76,14 @@ public abstract class TileEntityBase extends TileEntity{
@Override @Override
public final void readFromNBT(NBTTagCompound compound){ public final void readFromNBT(NBTTagCompound compound){
super.readFromNBT(compound); super.readFromNBT(compound);
this.isRedstonePowered = compound.getBoolean("Redstone");
this.readSyncableNBT(compound, false); this.readSyncableNBT(compound, false);
} }
@Override @Override
public final void writeToNBT(NBTTagCompound compound){ public final void writeToNBT(NBTTagCompound compound){
super.writeToNBT(compound); super.writeToNBT(compound);
compound.setBoolean("Redstone", this.isRedstonePowered);
this.writeSyncableNBT(compound, false); this.writeSyncableNBT(compound, false);
} }