From 97f2d46d65b02a987749d8240bb4ed26990c5800 Mon Sep 17 00:00:00 2001 From: DrParadox7 Date: Thu, 25 Jan 2024 20:50:24 +0100 Subject: [PATCH] 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. --- .../common/tile/TileEntityFuelwoodHeater.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java b/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java index bdf470252..3ff895c30 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java +++ b/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java @@ -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); } }