Skip to content

Commit

Permalink
Improve Fuelwood Tick performance
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DrParadox7 committed Jan 26, 2024
1 parent 1a76742 commit c137639
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement
{
public double temperature;
public double heatToAbsorb = 0;

public int burnTime;
public int maxBurnTime;
public int checkDelay;

/** Whether or not this machine is in it's active state. */
public boolean isActive;
Expand Down Expand Up @@ -73,45 +74,54 @@ public void onUpdate()
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) {
int fuelTime = TileEntityFurnace.getItemBurnTime(inventory[0]);
if (inventory[0] != null) {
if (checkDelay == 0) {
int fuelTime = TileEntityFurnace.getItemBurnTime(inventory[0]);

if (fuelTime > 0) {
maxBurnTime = burnTime = fuelTime / 2;
if (fuelTime > 0) {
maxBurnTime = burnTime = fuelTime / 2;

if (burnTime > 0) {
inventory[0].stackSize--;
if (burnTime > 0) {
inventory[0].stackSize--;

if (inventory[0].stackSize == 0) {
inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]);
}
if (inventory[0].stackSize == 0) {
inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]);
}

burning = true;
burning = true;
}
} else {
checkDelay = 60;
}
} else {
checkDelay--;
}
}
}



if(burning)
{
heatToAbsorb += general.heatPerFuelTick;
setActive(true);
} else if (isActive) {
setActive(false);
}

if (this.getTemp() > 0 || heatToAbsorb > 0) {
double[] loss = simulateHeat();
applyTemperatureChange();
lastEnvironmentLoss = loss[1];
}

double[] loss = simulateHeat();
applyTemperatureChange();

lastEnvironmentLoss = loss[1];

setActive(burning);
}
}

Expand Down

0 comments on commit c137639

Please sign in to comment.