diff --git a/RebornCore/src/main/java/reborncore/common/blockentity/MachineBaseBlockEntity.java b/RebornCore/src/main/java/reborncore/common/blockentity/MachineBaseBlockEntity.java index 60518059c..b71049088 100644 --- a/RebornCore/src/main/java/reborncore/common/blockentity/MachineBaseBlockEntity.java +++ b/RebornCore/src/main/java/reborncore/common/blockentity/MachineBaseBlockEntity.java @@ -155,6 +155,7 @@ public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTi ((IUpgrade) stack.getItem()).process(this, this, stack); } } + afterUpgradesApplication(); } if (world == null || world.isClient) { return; @@ -175,6 +176,9 @@ public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTi resetSpeedMulti(); } + protected void afterUpgradesApplication() { + } + public int getFacingInt() { Block block = world.getBlockState(pos).getBlock(); if (block instanceof BlockMachineBase) { diff --git a/RebornCore/src/main/java/reborncore/common/powerSystem/PowerAcceptorBlockEntity.java b/RebornCore/src/main/java/reborncore/common/powerSystem/PowerAcceptorBlockEntity.java index 4589c826e..529a34a3d 100644 --- a/RebornCore/src/main/java/reborncore/common/powerSystem/PowerAcceptorBlockEntity.java +++ b/RebornCore/src/main/java/reborncore/common/powerSystem/PowerAcceptorBlockEntity.java @@ -346,7 +346,8 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im super.readNbt(tag); NbtCompound data = tag.getCompound("PowerAcceptor"); if (shouldHandleEnergyNBT()) { - this.setStored(data.getLong("energy")); + // Bypass the overfill check in setStored() because upgrades have not yet been applied. + this.energyContainer.amount = data.getLong("energy"); } } @@ -367,6 +368,13 @@ public abstract class PowerAcceptorBlockEntity extends MachineBaseBlockEntity im extraPowerInput = 0; } + @Override + protected void afterUpgradesApplication() { + if (checkOverfill && getStored() > getMaxStoredPower()) { + setStored(getStored()); + } + } + public long getStored() { return energyContainer.amount; }