AESU stores inventory correctly. Closes #2018

This commit is contained in:
drcrazy 2020-02-10 21:33:21 +03:00
parent bc0af95053
commit c2f387f1ae
2 changed files with 45 additions and 46 deletions

View file

@ -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); 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(){ public int getMaxConfigOutput(){
int extra = 0; int extra = 0;
if(superconductors > 0){ if(superconductors > 0){
@ -71,12 +56,6 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
return maxOutput + extra; return maxOutput + extra;
} }
@Override
public void resetUpgrades() {
super.resetUpgrades();
superconductors = 0;
}
public void handleGuiInputFromClient(int id, boolean shift, boolean ctrl) { public void handleGuiInputFromClient(int id, boolean shift, boolean ctrl) {
if(shift){ if(shift){
id *= 4; id *= 4;
@ -103,28 +82,35 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
dropStack.getOrCreateTag().put("blockEntity", blockEntity); dropStack.getOrCreateTag().put("blockEntity", blockEntity);
return dropStack; return dropStack;
} }
public int getCurrentOutput() { // EnergyStorageBlockEntity
return OUTPUT; @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) { @Override
this.OUTPUT = output; public boolean canBeUpgraded() {
return true;
} }
// TileEnergyStorage
@Override @Override
public ItemStack getToolDrop(PlayerEntity entityPlayer) { public ItemStack getToolDrop(PlayerEntity entityPlayer) {
return getDropWithNBT(); return getDropWithNBT();
} }
@Override
public double getBaseMaxOutput() {
return OUTPUT;
}
@Override @Override
public double getMaxOutput(EnergySide side) { public double getBaseMaxOutput() {
return OUTPUT; return OUTPUT;
} }
@ -137,12 +123,22 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
return maxInput; return maxInput;
} }
// TilePowerAcceptor // PowerAcceptorBlockEntity
@Override
public void resetUpgrades() {
super.resetUpgrades();
superconductors = 0;
}
@Override
public double getMaxOutput(EnergySide side) {
return OUTPUT;
}
@Override @Override
public CompoundTag toTag(CompoundTag tagCompound) { public CompoundTag toTag(CompoundTag tagCompound) {
super.toTag(tagCompound); super.toTag(tagCompound);
tagCompound.putInt("output", OUTPUT); tagCompound.putInt("output", OUTPUT);
inventory.write(tagCompound);
return tagCompound; return tagCompound;
} }
@ -150,7 +146,12 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
public void fromTag(CompoundTag nbttagcompound) { public void fromTag(CompoundTag nbttagcompound) {
super.fromTag(nbttagcompound); super.fromTag(nbttagcompound);
this.OUTPUT = nbttagcompound.getInt("output"); 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 // IContainerProvider
@ -161,13 +162,11 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
.syncEnergyValue().sync(this::getCurrentOutput, this::setCurentOutput).addInventory().create(this, syncID); .syncEnergyValue().sync(this::getCurrentOutput, this::setCurentOutput).addInventory().create(this, syncID);
} }
@Override public int getCurrentOutput() {
public boolean canBeUpgraded() { return OUTPUT;
return true;
} }
@Override public void setCurentOutput(int output) {
public boolean isUpgradeValid(IUpgrade upgrade, ItemStack stack) { this.OUTPUT = output;
return stack.isItemEqual(new ItemStack(TRContent.Upgrades.SUPERCONDUCTOR.item));
} }
} }

View file

@ -64,7 +64,7 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity
checkTier(); checkTier();
} }
// TilePowerAcceptor // PowerAcceptorBlockEntity
@Override @Override
public void tick() { public void tick() {
super.tick(); super.tick();
@ -140,7 +140,7 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity
return new ItemStack(wrenchDrop); return new ItemStack(wrenchDrop);
} }
// ItemHandlerProvider // InventoryProvider
@Override @Override
public RebornInventory<EnergyStorageBlockEntity> getInventory() { public RebornInventory<EnergyStorageBlockEntity> getInventory() {
return inventory; return inventory;