From c461f50dcd3705a350012ab1f8ae8482c2290a18 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Thu, 5 Apr 2018 20:27:24 -1000 Subject: Overcharged power substation drains energy gradually instead of immediately --- ...echMetaTileEntity_PowerSubStationController.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/Java') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java index 1bed942cc1..2aa30a0c30 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java @@ -276,10 +276,9 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe this.mAverageEuUsage = 0; } - // Only set these here, after the machine check is 100% passed. + // Only set this here, after the machine check is 100% passed. this.mBatteryCapacity = getCapacityFromCellTier(tOverallCellTier) * tCellCount; - this.setEUVar(Math.min(this.getEUVar(), this.mBatteryCapacity)); return true; } @@ -394,7 +393,13 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe @Override public boolean onRunningTick(ItemStack aStack) { - // First, Pay Tax + // First, decay overcharge (0.1% of stored energy plus 1000 EU per tick) + if (this.getEUVar() > this.mBatteryCapacity) { + long energy = (long) (this.getEUVar() * 0.999f) - 1000; + this.setEUVar(energy); + } + + // Pay Tax long mDecrease = computeEnergyTax(); this.mTotalEnergyLost += Math.min(mDecrease, this.getEUVar()); this.setEUVar(Math.max(0, this.getEUVar() - mDecrease)); @@ -457,9 +462,17 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe } else { mode = EnumChatFormatting.BLUE + "Input" + EnumChatFormatting.RESET; } + + String storedEnergyText; + if (this.getEUVar() > this.mBatteryCapacity) { + storedEnergyText = EnumChatFormatting.RED + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; + } else { + storedEnergyText = EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; + } + return new String[]{ "Ergon Energy - District Sub-Station", - "Stored EU:" + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET, + "Stored EU:" + storedEnergyText, "Capacity: " + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(this.maxEUStore()) + EnumChatFormatting.RESET, "Running Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.computeEnergyTax()) + EnumChatFormatting.RESET + " EU/t", "Controller Mode: " + mode, -- cgit