Improve Fuelwood Tick performance

Improves server performance of Fuelwood Heater by:
- Preventing it from doing unnecessary operations when it has no fuel and no temperature.

- Reducing fuel value checks of empty container items.

This is a block that gets spammed a lot for steam generation so these small tweaks go a long way.

Better non-burnable detection

Saves last invalid ItemStack (no fuel value).
The next operation will only occur with a different stack.

It will no longer attempt to read fuel values of something that cannot be consumed (since no fuel value) more than once.
This commit is contained in:
DrParadox7 committed 2024-01-31 16:12:01 +01:00
1 parent 1e9b28dfbe
commit 97f2d46d65
1 file changed
+12 -13
@@ -25,10 +25,12 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement
{
public double temperature;
public double heatToAbsorb = 0;
public int burnTime;
public int maxBurnTime;
public ItemStack nonBurnable;
/** Whether this machine is in its active state. */
public boolean isActive;
@@ -73,19 +75,20 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
}
}
boolean burning = false;
if(burnTime > 0)
{
burnTime--;
burning = true;
}
else {
if(inventory[0] != null) {
if (inventory[0] != null && inventory[0] != nonBurnable) {
int fuelTime = TileEntityFurnace.getItemBurnTime(inventory[0]);
if (fuelTime > 0) {
nonBurnable = null;
maxBurnTime = burnTime = fuelTime / 2;
if (burnTime > 0) {
@@ -97,10 +100,13 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement
burning = true;
}
} else {
nonBurnable = inventory[0];
}
}
}
if(burning)
{
heatToAbsorb += general.heatPerFuelTick;
@@ -114,13 +120,6 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement
applyTemperatureChange();
lastEnvironmentLoss = loss[1];
}
double[] loss = simulateHeat();
applyTemperatureChange();
lastEnvironmentLoss = loss[1];
setActive(burning);
}
}