From 5694d4f8dad4db68b8e6ddf12e344538a09613b9 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 28 Nov 2016 13:17:20 +0100 Subject: [PATCH] Make the heat collector a little more rare to pick up lava --- .../mod/tile/TileEntityHeatCollector.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java index 75ebd2d27..022d24762 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java @@ -27,6 +27,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE public static final int BLOCKS_NEEDED = 4; public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 0, 80); private int oldEnergy; + private int disappearTime; public TileEntityHeatCollector(){ super("heatCollector"); @@ -35,13 +36,21 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE @Override public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ super.writeSyncableNBT(compound, type); + this.storage.writeToNBT(compound); + if(type == NBTType.SAVE_TILE){ + compound.setInteger("DisappearTime", this.disappearTime); + } } @Override public void readSyncableNBT(NBTTagCompound compound, NBTType type){ super.readSyncableNBT(compound, type); + this.storage.readFromNBT(compound); + if(type == NBTType.SAVE_TILE){ + this.disappearTime = compound.getInteger("DisappearTime"); + } } @Override @@ -63,9 +72,14 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE this.storage.receiveEnergyInternal(ENERGY_PRODUCE, false); this.markDirty(); - if(this.world.rand.nextInt(10000) == 0){ - int randomSide = blocksAround.get(this.world.rand.nextInt(blocksAround.size())); - this.world.setBlockToAir(this.pos.offset(WorldUtil.getDirectionBySidesInOrder(randomSide))); + 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())); + this.world.setBlockToAir(this.pos.offset(WorldUtil.getDirectionBySidesInOrder(randomSide))); + } } } }