Skip to content

Commit

Permalink
fix: Ensure stirling generator saves burn progress
Browse files Browse the repository at this point in the history
Closes: GH-753
  • Loading branch information
Rover656 committed Sep 24, 2024
1 parent 431505c commit e3ece3e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class MachineNBTKeys extends EIONBTKeys {
public static final String MACHINE_MODE = "Mode";
public static final String PROCESSED_INPUTS = "ProcessedInputs";

// TODO: If the previous TODO is carried out, these should probably be moved to PrimitiveAlloySmelterBlockEntity
public static final String BURN_TIME = "BurnTime";
public static final String BURN_DURATION = "BurnDuration";
public static final String RANGE = "Range";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.enderio.api.capacitor.SteppedScalable;
import com.enderio.api.io.energy.EnergyIOMode;
import com.enderio.core.common.network.slot.FloatNetworkDataSlot;
import com.enderio.machines.common.MachineNBTKeys;
import com.enderio.machines.common.blockentity.base.PoweredMachineBlockEntity;
import com.enderio.machines.common.config.MachinesConfig;
import com.enderio.machines.common.io.energy.MachineEnergyStorage;
Expand Down Expand Up @@ -160,11 +161,27 @@ protected void onContentsChanged() {
public void load(CompoundTag pTag) {
super.load(pTag);

if (pTag.contains(MachineNBTKeys.BURN_TIME, CompoundTag.TAG_INT)) {
burnTime = pTag.getInt(MachineNBTKeys.BURN_TIME);
}

if (pTag.contains(MachineNBTKeys.BURN_DURATION, CompoundTag.TAG_INT)) {
burnDuration = pTag.getInt(MachineNBTKeys.BURN_DURATION);
}

updateMachineState(MachineState.NO_POWER, false);
updateMachineState(MachineState.FULL_POWER, (getEnergyStorage().getEnergyStored() >= getEnergyStorage().getMaxEnergyStored()) && isCapacitorInstalled());
updateMachineState(MachineState.EMPTY_INPUT, FUEL.getItemStack(getInventoryNN()).isEmpty());
}

@Override
public void saveAdditional(CompoundTag pTag) {
super.saveAdditional(pTag);

pTag.putInt(MachineNBTKeys.BURN_TIME, burnTime);
pTag.putInt(MachineNBTKeys.BURN_DURATION, burnDuration);
}

@Override
public void setLevel(Level level) {
super.setLevel(level);
Expand Down

0 comments on commit e3ece3e

Please sign in to comment.