Make the heat collector a little more rare to pick up lava

This commit is contained in:
Ellpeck 2016-11-28 13:17:20 +01:00
parent ca38b43b67
commit 5694d4f8da

View file

@ -27,6 +27,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE
public static final int BLOCKS_NEEDED = 4; public static final int BLOCKS_NEEDED = 4;
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 0, 80); public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 0, 80);
private int oldEnergy; private int oldEnergy;
private int disappearTime;
public TileEntityHeatCollector(){ public TileEntityHeatCollector(){
super("heatCollector"); super("heatCollector");
@ -35,13 +36,21 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
super.writeSyncableNBT(compound, type); super.writeSyncableNBT(compound, type);
this.storage.writeToNBT(compound); this.storage.writeToNBT(compound);
if(type == NBTType.SAVE_TILE){
compound.setInteger("DisappearTime", this.disappearTime);
}
} }
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, NBTType type){ public void readSyncableNBT(NBTTagCompound compound, NBTType type){
super.readSyncableNBT(compound, type); super.readSyncableNBT(compound, type);
this.storage.readFromNBT(compound); this.storage.readFromNBT(compound);
if(type == NBTType.SAVE_TILE){
this.disappearTime = compound.getInteger("DisappearTime");
}
} }
@Override @Override
@ -63,12 +72,17 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE
this.storage.receiveEnergyInternal(ENERGY_PRODUCE, false); this.storage.receiveEnergyInternal(ENERGY_PRODUCE, false);
this.markDirty(); this.markDirty();
if(this.world.rand.nextInt(10000) == 0){ this.disappearTime++;
if(this.disappearTime >= 1000){
this.disappearTime = 0;
if(this.world.rand.nextInt(200) == 0){
int randomSide = blocksAround.get(this.world.rand.nextInt(blocksAround.size())); int randomSide = blocksAround.get(this.world.rand.nextInt(blocksAround.size()));
this.world.setBlockToAir(this.pos.offset(WorldUtil.getDirectionBySidesInOrder(randomSide))); this.world.setBlockToAir(this.pos.offset(WorldUtil.getDirectionBySidesInOrder(randomSide)));
} }
} }
} }
}
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){ if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
this.oldEnergy = this.storage.getEnergyStored(); this.oldEnergy = this.storage.getEnergyStored();