Add tryAddingEnergy to ThermalGenerator to fix eternal activation with adjacent lava

This commit is contained in:
Ourten 2016-12-15 14:41:04 +01:00
parent d727c2698b
commit 1181ce49f2

View file

@ -108,17 +108,19 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab
this.getPos().getY() + direction.getFrontOffsetY(),
this.getPos().getZ() + direction.getFrontOffsetZ()))
.getBlock() == Blocks.LAVA) {
this.addEnergy(1);
if(this.tryAddingEnergy(1))
this.lastOutput = this.world.getTotalWorldTime();
}
}
}
if (this.tank.getFluidAmount() > 0 && this.getMaxPower() - this.getEnergy() >= TileThermalGenerator.euTick) {
if (this.tank.getFluidAmount() > 0) {
if(tryAddingEnergy(euTick))
{
this.tank.drain(1, true);
this.addEnergy(TileThermalGenerator.euTick);
this.lastOutput = this.world.getTotalWorldTime();
}
}
if (!this.world.isRemote) {
if (this.world.getTotalWorldTime() - this.lastOutput < 30 && !this.isActive())
@ -136,6 +138,21 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab
}
}
private boolean tryAddingEnergy(int amount)
{
if(this.getMaxPower() - this.getEnergy() >= amount)
{
addEnergy(amount);
return true;
}
else if(this.getMaxPower() - this.getEnergy() > 0)
{
addEnergy(this.getMaxPower() - this.getEnergy());
return true;
}
return false;
}
@Override
public double getMaxPower() {
return ConfigTechReborn.ThermalGeneratorCharge;