AESU stores inventory correctly. Closes #2018
This commit is contained in:
parent
bc0af95053
commit
c2f387f1ae
2 changed files with 45 additions and 46 deletions
|
@ -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;
|
||||||
|
@ -104,15 +83,27 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
return dropStack;
|
return dropStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrentOutput() {
|
// EnergyStorageBlockEntity
|
||||||
return OUTPUT;
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
super.tick();
|
||||||
|
if (world == null){
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurentOutput(int output) {
|
if (OUTPUT > getMaxConfigOutput()) {
|
||||||
this.OUTPUT = output;
|
OUTPUT = getMaxConfigOutput();
|
||||||
|
}
|
||||||
|
if(world.getTime() % 20 == 0){
|
||||||
|
checkTier();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBeUpgraded() {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TileEnergyStorage
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(PlayerEntity entityPlayer) {
|
public ItemStack getToolDrop(PlayerEntity entityPlayer) {
|
||||||
return getDropWithNBT();
|
return getDropWithNBT();
|
||||||
|
@ -123,11 +114,6 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
|
||||||
return OUTPUT;
|
return OUTPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getMaxOutput(EnergySide side) {
|
|
||||||
return OUTPUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxInput() {
|
public double getBaseMaxInput() {
|
||||||
//If we have super conductors increase the max input of the machine
|
//If we have super conductors increase the max input of the machine
|
||||||
|
@ -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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Add table
Reference in a new issue