Fix generator's active state being incorrect in some situations

This commit is contained in:
modmuss50 2019-09-21 11:24:40 +01:00
parent 0a7b501511
commit 5001331577

View file

@ -77,6 +77,7 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
if (world.isClient) { if (world.isClient) {
return; return;
} }
discharge(1);
if (getEnergy() < getMaxPower()) { if (getEnergy() < getMaxPower()) {
if (burnTime > 0) { if (burnTime > 0) {
burnTime--; burnTime--;
@ -85,6 +86,7 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
} }
} else { } else {
isBurning = false; isBurning = false;
updateState();
} }
if (burnTime == 0) { if (burnTime == 0) {
@ -113,8 +115,9 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
final BlockState BlockStateContainer = world.getBlockState(pos); final BlockState BlockStateContainer = world.getBlockState(pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) { if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock(); final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != burnTime > 0) { boolean active = burnTime > 0 && getEnergy() < getMaxPower();
blockMachineBase.setActive(burnTime > 0, world, pos); if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != active) {
blockMachineBase.setActive(active, world, pos);
} }
} }
} }