From e3ece3ec7b54abe1fdd52cd0a791f1456217ffc5 Mon Sep 17 00:00:00 2001 From: Reece Mackie <20544390+Rover656@users.noreply.github.com> Date: Wed, 25 Sep 2024 00:12:51 +0100 Subject: [PATCH] fix: Ensure stirling generator saves burn progress Closes: GH-753 --- .../enderio/machines/common/MachineNBTKeys.java | 1 - .../StirlingGeneratorBlockEntity.java | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/machines/java/com/enderio/machines/common/MachineNBTKeys.java b/src/machines/java/com/enderio/machines/common/MachineNBTKeys.java index 8f9a6b4de7..0eaeb87259 100644 --- a/src/machines/java/com/enderio/machines/common/MachineNBTKeys.java +++ b/src/machines/java/com/enderio/machines/common/MachineNBTKeys.java @@ -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"; diff --git a/src/machines/java/com/enderio/machines/common/blockentity/StirlingGeneratorBlockEntity.java b/src/machines/java/com/enderio/machines/common/blockentity/StirlingGeneratorBlockEntity.java index 38150a99c0..ac8532955e 100644 --- a/src/machines/java/com/enderio/machines/common/blockentity/StirlingGeneratorBlockEntity.java +++ b/src/machines/java/com/enderio/machines/common/blockentity/StirlingGeneratorBlockEntity.java @@ -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; @@ -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);