From 04118a76458b4e6c886454081dd3695b62660f80 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Wed, 15 Nov 2017 05:28:56 +1000 Subject: $ Fixed Charge Hatches not having the correct amount of inputs. $ Fixed Charge Hatches correctly handling electric items. --- ...chMetaTileEntity_PowerSubStationController.java | 54 ++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java index c6a4cc03c1..a163215459 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java @@ -17,6 +17,8 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBattery; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; @@ -244,12 +246,12 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe } } } - if ((this.mInputBusses.size() != 1) || (this.mOutputBusses.size() != 1) + if ((this.mChargeHatches.size() < 1) || (this.mDischargeHatches.size() < 1) || (this.mMaintenanceHatches.size() != 1) || (this.mEnergyHatches.size() < 1) || (this.mDynamoHatches.size() < 1)) { Utils.LOG_MACHINE_INFO("Returned False 3"); - Utils.LOG_MACHINE_INFO("Input Buses: "+this.mInputBusses.size()+" | expected: 1 | "+(this.mInputBusses.size() != 1)); - Utils.LOG_MACHINE_INFO("Output Buses: "+this.mOutputBusses.size()+" | expected: 1 | "+(this.mOutputBusses.size() != 1)); + Utils.LOG_MACHINE_INFO("Charge Buses: "+this.mChargeHatches.size()+" | expected: 1 | "+(this.mChargeHatches.size() != 1)); + Utils.LOG_MACHINE_INFO("Discharge Buses: "+this.mDischargeHatches.size()+" | expected: 1 | "+(this.mDischargeHatches.size() != 1)); Utils.LOG_MACHINE_INFO("Energy Hatches: "+this.mEnergyHatches.size()+" | expected: >= 1 | "+(this.mEnergyHatches.size() < 1)); Utils.LOG_MACHINE_INFO("Dynamo Hatches: "+this.mDynamoHatches.size()+" | expected: >= 1 | "+(this.mDynamoHatches.size() < 1)); Utils.LOG_MACHINE_INFO("Maint. Hatches: "+this.mMaintenanceHatches.size()+" | expected: 1 | "+(this.mMaintenanceHatches.size() != 1)); @@ -363,6 +365,13 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { this.mActualStoredEU = this.getEUVar(); + + if (this.mActualStoredEU < 0){ + this.mActualStoredEU = 0; + } + if (this.getEUVar() < 0){ + this.setEUVar(0); + } if (aBaseMetaTileEntity.isServerSide()){ this.mTotalRunTime++; @@ -391,6 +400,17 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe if (this.getBaseMetaTileEntity().isAllowedToWork()){ this.getBaseMetaTileEntity().enableWorking(); } + for (GT_MetaTileEntity_Hatch_OutputBattery energy : this.mDischargeHatches){ + long stored = energy.getEUVar(); + long voltage = energy.maxEUInput(); + if (stored > 0){ + energy.setEUVar((stored-voltage)); + this.mTotalEnergyAdded+=voltage; + if (this.getBaseMetaTileEntity().increaseStoredEnergyUnits(voltage, false)){ + //Utils.LOG_INFO("Draining Discharge Hatch #1"); + } + } + } for (GT_MetaTileEntity_Hatch_Energy energy : this.mEnergyHatches){ long stored = energy.getEUVar(); long voltage = energy.maxEUInput(); @@ -431,14 +451,28 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe public boolean drainEnergyInput(long aEU) { if (aEU <= 0L) return true; + long nStoredPower = this.getEUVar(); + for (GT_MetaTileEntity_Hatch_OutputBattery tHatch : this.mDischargeHatches) { + if ((isValidMetaTileEntity(tHatch)) && (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false))){ + if (this.mActualStoredEU