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);
}
@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;
@ -104,15 +83,27 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
return dropStack;
}
public int getCurrentOutput() {
return OUTPUT;
// EnergyStorageBlockEntity
@Override
public void tick() {
super.tick();
if (world == null){
return;
}
public void setCurentOutput(int output) {
this.OUTPUT = output;
if (OUTPUT > getMaxConfigOutput()) {
OUTPUT = getMaxConfigOutput();
}
if(world.getTime() % 20 == 0){
checkTier();
}
}
@Override
public boolean canBeUpgraded() {
return true;
}
// TileEnergyStorage
@Override
public ItemStack getToolDrop(PlayerEntity entityPlayer) {
return getDropWithNBT();
@ -123,11 +114,6 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
return OUTPUT;
}
@Override
public double getMaxOutput(EnergySide side) {
return OUTPUT;
}
@Override
public double getBaseMaxInput() {
//If we have super conductors increase the max input of the machine
@ -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;
}
}

View file

@ -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<EnergyStorageBlockEntity> getInventory() {
return inventory;