Handful of improvements to the electrical furnace, closes #1349

This commit is contained in:
modmuss50 2017-12-04 20:55:57 +00:00
parent 777707373a
commit 53c731d678

View file

@ -48,9 +48,10 @@ public class TileElectricFurnace extends TilePowerAcceptor
public int capacity = 1000; public int capacity = 1000;
public int progress; public int progress;
public int fuelScale = 100; public int fuelScale = 100;
public int cost = 8; public int cost = 6;
int input1 = 0; int input1 = 0;
int output = 1; int output = 1;
boolean wasBurning = false;
public TileElectricFurnace() { public TileElectricFurnace() {
super(); super();
@ -71,16 +72,15 @@ public class TileElectricFurnace extends TilePowerAcceptor
boolean updateInventory = false; boolean updateInventory = false;
if (this.isBurning() && this.canSmelt()) { if (this.isBurning() && this.canSmelt()) {
this.updateState(); this.updateState();
if(canUseEnergy(this.cost)){
this.useEnergy(this.cost);
this.progress++; this.progress++;
if (this.progress % 10 == 0) { if (this.progress >= Math.max((int) (fuelScale * (1.0 - getSpeedMultiplier())), 2)) {
this.useEnergy(getEuPerTick(this.cost));
}
if (this.progress >= Math.max((int) (fuelScale * (1.0 - getSpeedMultiplier())), 1)) {
this.progress = 0; this.progress = 0;
this.cookItems(); this.cookItems();
updateInventory = true; updateInventory = true;
} }
}
} else { } else {
this.progress = 0; this.progress = 0;
this.updateState(); this.updateState();
@ -139,12 +139,16 @@ public class TileElectricFurnace extends TilePowerAcceptor
} }
public void updateState() { public void updateState() {
if(wasBurning != (this.progress > 0)){
final IBlockState BlockStateContainer = this.world.getBlockState(this.pos); final IBlockState BlockStateContainer = this.world.getBlockState(this.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.getValue(BlockMachineBase.ACTIVE) != this.progress > 0) if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != this.progress > 0)
blockMachineBase.setActive(this.progress > 0, this.world, this.pos); blockMachineBase.setActive(this.progress > 0, this.world, this.pos);
} }
wasBurning = (this.progress > 0);
}
} }
@Override @Override