From c2f387f1ae23dfd80d290c095e4ddce985c06fbd Mon Sep 17 00:00:00 2001 From: drcrazy Date: Mon, 10 Feb 2020 21:33:21 +0300 Subject: [PATCH] AESU stores inventory correctly. Closes #2018 --- .../energy/AdjustableSUBlockEntity.java | 87 +++++++++---------- .../energy/EnergyStorageBlockEntity.java | 4 +- 2 files changed, 45 insertions(+), 46 deletions(-) diff --git a/src/main/java/techreborn/blockentity/storage/energy/AdjustableSUBlockEntity.java b/src/main/java/techreborn/blockentity/storage/energy/AdjustableSUBlockEntity.java index ffac2529d..7ba2d3759 100644 --- a/src/main/java/techreborn/blockentity/storage/energy/AdjustableSUBlockEntity.java +++ b/src/main/java/techreborn/blockentity/storage/energy/AdjustableSUBlockEntity.java @@ -48,21 +48,6 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements super(TRBlockEntities.ADJUSTABLE_SU, "ADJUSTABLE_SU", 4, TRContent.Machine.ADJUSTABLE_SU.block, EnergyTier.INSANE, TechRebornConfig.aesuMaxEnergy); } - @Override - public void tick() { - super.tick(); - if (world == null){ - return; - } - - if (OUTPUT > getMaxConfigOutput()) { - OUTPUT = getMaxConfigOutput(); - } - if(world.getTime() % 20 == 0){ - checkTier(); - } - } - public int getMaxConfigOutput(){ int extra = 0; if(superconductors > 0){ @@ -71,12 +56,6 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements return maxOutput + extra; } - @Override - public void resetUpgrades() { - super.resetUpgrades(); - superconductors = 0; - } - public void handleGuiInputFromClient(int id, boolean shift, boolean ctrl) { if(shift){ id *= 4; @@ -103,28 +82,35 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements dropStack.getOrCreateTag().put("blockEntity", blockEntity); return dropStack; } - - public int getCurrentOutput() { - return OUTPUT; + + // EnergyStorageBlockEntity + @Override + public void tick() { + super.tick(); + if (world == null){ + return; + } + + if (OUTPUT > getMaxConfigOutput()) { + OUTPUT = getMaxConfigOutput(); + } + if(world.getTime() % 20 == 0){ + checkTier(); + } } - - public void setCurentOutput(int output) { - this.OUTPUT = output; + + @Override + public boolean canBeUpgraded() { + return true; } - - // TileEnergyStorage + @Override public ItemStack getToolDrop(PlayerEntity entityPlayer) { return getDropWithNBT(); } - - @Override - public double getBaseMaxOutput() { - return OUTPUT; - } @Override - public double getMaxOutput(EnergySide side) { + public double getBaseMaxOutput() { return OUTPUT; } @@ -137,12 +123,22 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements return maxInput; } - // TilePowerAcceptor + // PowerAcceptorBlockEntity + @Override + public void resetUpgrades() { + super.resetUpgrades(); + superconductors = 0; + } + + @Override + public double getMaxOutput(EnergySide side) { + return OUTPUT; + } + @Override public CompoundTag toTag(CompoundTag tagCompound) { super.toTag(tagCompound); tagCompound.putInt("output", OUTPUT); - inventory.write(tagCompound); return tagCompound; } @@ -150,7 +146,12 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements public void fromTag(CompoundTag nbttagcompound) { super.fromTag(nbttagcompound); this.OUTPUT = nbttagcompound.getInt("output"); - inventory.read(nbttagcompound); + } + + // MachineBaseBlockEntity + @Override + public boolean isUpgradeValid(IUpgrade upgrade, ItemStack stack) { + return stack.isItemEqual(new ItemStack(TRContent.Upgrades.SUPERCONDUCTOR.item)); } // IContainerProvider @@ -161,13 +162,11 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements .syncEnergyValue().sync(this::getCurrentOutput, this::setCurentOutput).addInventory().create(this, syncID); } - @Override - public boolean canBeUpgraded() { - return true; + public int getCurrentOutput() { + return OUTPUT; } - @Override - public boolean isUpgradeValid(IUpgrade upgrade, ItemStack stack) { - return stack.isItemEqual(new ItemStack(TRContent.Upgrades.SUPERCONDUCTOR.item)); + public void setCurentOutput(int output) { + this.OUTPUT = output; } } diff --git a/src/main/java/techreborn/blockentity/storage/energy/EnergyStorageBlockEntity.java b/src/main/java/techreborn/blockentity/storage/energy/EnergyStorageBlockEntity.java index 4d2afd83c..f09aa8e91 100644 --- a/src/main/java/techreborn/blockentity/storage/energy/EnergyStorageBlockEntity.java +++ b/src/main/java/techreborn/blockentity/storage/energy/EnergyStorageBlockEntity.java @@ -64,7 +64,7 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity checkTier(); } - // TilePowerAcceptor + // PowerAcceptorBlockEntity @Override public void tick() { super.tick(); @@ -140,7 +140,7 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity return new ItemStack(wrenchDrop); } - // ItemHandlerProvider + // InventoryProvider @Override public RebornInventory getInventory() { return inventory;