From 48fe59d7889dd6362561e83418c31bdbfdbb68e0 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Tue, 6 Mar 2018 22:43:44 -1000 Subject: Substation: Remove pointless overrides and dead code --- ...chMetaTileEntity_PowerSubStationController.java | 42 ---------------------- 1 file changed, 42 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines') 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 4c8dd4cc4c..e46e8be17c 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 @@ -94,11 +94,6 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); } - @Override - public void onConfigLoad(final GT_Config aConfig) { - super.onConfigLoad(aConfig); - } - @Override public boolean checkRecipe(final ItemStack aStack) { return (this.mActualStoredEU >= 0); @@ -303,38 +298,11 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe return tAmount >= 35; } - public boolean ignoreController(final Block tTileEntity) { - if (!controller && (tTileEntity == GregTech_API.sBlockMachines)) { - return true; - } - return false; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; @@ -386,11 +354,6 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe super.loadNBTData(aNBT); } - @Override - public int maxProgresstime() { - return super.maxProgresstime(); - } - @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { this.mActualStoredEU = this.getEUVar(); @@ -458,11 +421,6 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe super.onPostTick(aBaseMetaTileEntity, aTick); } - @Override - public boolean onRunningTick(ItemStack aStack) { - return super.onRunningTick(aStack); - } - @Override public boolean drainEnergyInput(long aEU) { if (aEU <= 0L) -- cgit From ce45a168f28c22e68af4adc4797a08dc16557040 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Tue, 6 Mar 2018 22:47:24 -1000 Subject: Substation: remove redundant `mActualStoredEU` `getEUVar()` etc. are fine. --- ...chMetaTileEntity_PowerSubStationController.java | 26 +++++----------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines') 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 e46e8be17c..af7217b131 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 @@ -96,7 +96,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe @Override public boolean checkRecipe(final ItemStack aStack) { - return (this.mActualStoredEU >= 0); + return true; } @Override @@ -316,15 +316,12 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe //NBT Power Storage handling long mPowerStorageBuffer = 0; int mPowerStorageMultiplier = 32; - long mActualStoredEU = 0; - //mTotalEnergyAdded @Override public void saveNBTData(NBTTagCompound aNBT) { aNBT.setLong("mPowerStorageBuffer", this.mPowerStorageBuffer); aNBT.setInteger("mPowerStorageMultiplier", this.mPowerStorageMultiplier); - aNBT.setLong("mActualStoredEU", this.mActualStoredEU); aNBT.setInteger("mAverageEuUsage", this.mAverageEuUsage); //Usage Stats @@ -340,7 +337,6 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe public void loadNBTData(NBTTagCompound aNBT) { this.mPowerStorageBuffer = aNBT.getLong("mPowerStorageBuffer"); this.mPowerStorageMultiplier = aNBT.getInteger("mPowerStorageMultiplier"); - this.mActualStoredEU = aNBT.getLong("mActualStoredEU"); this.mAverageEuUsage = aNBT.getInteger("mAverageEuUsage"); //Usage Stats @@ -356,17 +352,12 @@ 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); } //Handle Progress Time - if (this.mActualStoredEU >= 0 && this.getBaseMetaTileEntity().isAllowedToWork()){ + if (this.getBaseMetaTileEntity().isAllowedToWork()){ this.mProgresstime = 20; this.mMaxProgresstime = 40; //Use 10% of average EU determined by adding in/output voltage of all hatches and averaging. @@ -384,7 +375,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe if (this.getBaseMetaTileEntity().isAllowedToWork()){ //Input Power - if (this.mActualStoredEU < this.maxEUStore()){ + if (this.getEUVar() < this.maxEUStore()){ if (this.getBaseMetaTileEntity().isAllowedToWork()){ this.getBaseMetaTileEntity().enableWorking(); } @@ -414,9 +405,8 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe } //Output Power - if (this.mActualStoredEU > 0){ - addEnergyOutput(1); - } + addEnergyOutput(1); + } super.onPostTick(aBaseMetaTileEntity, aTick); } @@ -428,17 +418,13 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe long nStoredPower = this.getEUVar(); for (GT_MetaTileEntity_Hatch_OutputBattery tHatch : this.mDischargeHatches) { if ((isValidMetaTileEntity(tHatch)) && (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false))){ - if (this.mActualStoredEU Date: Wed, 7 Mar 2018 01:27:47 -1000 Subject: Substation: Pretty up the scanner and info panel readout --- ...chMetaTileEntity_PowerSubStationController.java | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines') 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 af7217b131..610ff9c964 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 @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; import java.util.ArrayList; import java.util.concurrent.TimeUnit; +import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -33,6 +34,7 @@ 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.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMeta_MultiBlockBase { @@ -476,7 +478,6 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe @Override public String[] getInfoData() { - long seconds = (this.mTotalRunTime/20); int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7); @@ -485,14 +486,22 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); + String mode; + if (mIsOutputtingPower) { + mode = EnumChatFormatting.GOLD + "Output" + EnumChatFormatting.RESET; + } else { + mode = EnumChatFormatting.BLUE + "Input" + EnumChatFormatting.RESET; + } return new String[]{ "Ergon Energy - District Sub-Station", - "Controller Mode: "+(mIsOutputtingPower ? "Output" : "Input"), - "EU Required: "+this.mAverageEuUsage+"EU/t", + "Stored EU:" + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET, + "Capacity: " + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(this.maxEUStore()) + EnumChatFormatting.RESET, + "Running Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.mAverageEuUsage) + EnumChatFormatting.RESET + " EU/t", + "Controller Mode: " + mode, "Stats for Nerds", - "Total Input: "+this.mTotalEnergyAdded+"EU", - "Total Output: "+this.mTotalEnergyConsumed+"EU", - "Total Wasted: "+this.mTotalEnergyLost+"EU", + "Total Input: " + EnumChatFormatting.BLUE + GT_Utility.formatNumbers(this.mTotalEnergyAdded) + EnumChatFormatting.RESET + " EU", + "Total Output: " + EnumChatFormatting.GOLD + GT_Utility.formatNumbers(this.mTotalEnergyConsumed) + EnumChatFormatting.RESET + " EU", + "Total Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.mTotalEnergyLost) + EnumChatFormatting.RESET + " EU", "Total Time Since Built: ", ""+weeks+" Weeks.", @@ -500,7 +509,8 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe ""+hours+" Hours.", ""+minutes+" Minutes.", ""+second+" Seconds.", - "Total Time in ticks: "+this.mTotalRunTime}; + "Total Time in ticks: "+this.mTotalRunTime + }; }; -- cgit From a6952eb0ab70440efcc7c8318ca49c53b3654f0e Mon Sep 17 00:00:00 2001 From: David Vierra Date: Wed, 7 Mar 2018 01:33:16 -1000 Subject: Substation: Autoformatting --- ...chMetaTileEntity_PowerSubStationController.java | 92 +++++++++++----------- 1 file changed, 45 insertions(+), 47 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines') 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 610ff9c964..6f610e12d3 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 @@ -126,47 +126,46 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe // Station Floor & Roof (Inner 5x5) + Mufflers, Dynamos and Fluid outputs. if ((h == 0 || h == 3) || (h == 2 || h == 1)) { - if (h == 2 || h == 1){ + if (h == 2 || h == 1) { //If not a hatch, continue, else add hatch and continue. if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasings2Misc) { Logger.INFO("Station Casing(s) Missing from one of the top layers inner 3x3."); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + Logger.INFO("Instead, found " + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 7) { - Logger.INFO("Station Casing(s) Missing from one of the top layers inner 3x3. Wrong Meta for Casing. Found:"+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()+" with meta:"+aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j)); + Logger.INFO("Station Casing(s) Missing from one of the top layers inner 3x3. Wrong Meta for Casing. Found:" + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName() + " with meta:" + aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j)); return false; } - } - else { - if (h==0){ + } else { + if (h == 0) { if (!this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(24))) { if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasings2Misc) { Logger.INFO("Station Casing(s) Missing from one of the bottom layers inner 3x3."); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + Logger.INFO("Instead, found " + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { - Logger.INFO("Station Casing(s) Missing from one of the bottom layers inner 3x3. Wrong Meta for Casing. Found:"+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()+" with meta:"+aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j)); + Logger.INFO("Station Casing(s) Missing from one of the bottom layers inner 3x3. Wrong Meta for Casing. Found:" + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName() + " with meta:" + aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j)); return false; } tAmount++; } } - if (h==3){ + if (h == 3) { if (!this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(24))) { if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasings2Misc) { Logger.INFO("Station Casing(s) Missing from one of the top layers inner 3x3."); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + Logger.INFO("Instead, found " + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { - Logger.INFO("Station Casing(s) Missing from one of the top layers inner 3x3. Wrong Meta for Casing. Found:"+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()+" with meta:"+aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j)); + Logger.INFO("Station Casing(s) Missing from one of the top layers inner 3x3. Wrong Meta for Casing. Found:" + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName() + " with meta:" + aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j)); return false; } tAmount++; } - } + } } } } @@ -176,46 +175,44 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe //Deal with all 4 sides (Station walls) if ((h == 1) || (h == 2) || (h == 3)) { - if (h == 3){ + if (h == 3) { if (!this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(24))) { if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasings2Misc) { Logger.INFO("Station Casings Missing from somewhere in the top layer edge. 3"); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + Logger.INFO("Instead, found " + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { Logger.INFO("Station Casings Missing from somewhere in the top layer edge. 3"); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + Logger.INFO("Instead, found " + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } tAmount++; } - } - else if (h == 2){ + } else if (h == 2) { if (!this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(24))) { if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasings2Misc) { Logger.INFO("Station Casings Missing from somewhere in the top layer edge. 2"); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + Logger.INFO("Instead, found " + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { Logger.INFO("Station Casings Missing from somewhere in the top layer edge. 2"); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + Logger.INFO("Instead, found " + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } tAmount++; } - } - else { + } else { if (!this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(24))) { if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasings2Misc) { Logger.INFO("Station Casings Missing from somewhere in the second layer. 1"); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + Logger.INFO("Instead, found " + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { Logger.INFO("Station Casings Missing from somewhere in the second layer. 1"); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + Logger.INFO("Instead, found " + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } tAmount++; @@ -230,18 +227,17 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasings2Misc) { Logger.INFO("Station Casing(s) Missing from one of the edges on the top layer."); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + Logger.INFO("Instead, found " + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { - Logger.INFO("Station Casing(s) Missing from one of the edges on the top layer. "+h); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); - if (h ==0){ - if (tTileEntity instanceof GregtechMetaTileEntity_PowerSubStationController){ + Logger.INFO("Station Casing(s) Missing from one of the edges on the top layer. " + h); + Logger.INFO("Instead, found " + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + if (h == 0) { + if (tTileEntity instanceof GregtechMetaTileEntity_PowerSubStationController) { } - } - else { + } else { return false; } } @@ -253,30 +249,30 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe } } } - + /** * TecTech Support, this allows adding Multi-Amp dynamos. */ - if (this.mDynamoHatches.size() > 0){ - for (GT_MetaTileEntity_Hatch_Dynamo o : this.mDynamoHatches){ + if (this.mDynamoHatches.size() > 0) { + for (GT_MetaTileEntity_Hatch_Dynamo o : this.mDynamoHatches) { mAllDynamoHatches.add(o); } } - if (LoadedMods.TecTech && this.mMultiDynamoHatches.size() > 0){ - for (GT_MetaTileEntity_Hatch o : this.mMultiDynamoHatches){ + if (LoadedMods.TecTech && this.mMultiDynamoHatches.size() > 0) { + for (GT_MetaTileEntity_Hatch o : this.mMultiDynamoHatches) { mAllDynamoHatches.add(o); } - } - - + } + + if ((this.mMaintenanceHatches.size() != 1) || (this.mEnergyHatches.size() < 1) || (this.mAllDynamoHatches.size() < 1)) { Logger.INFO("Returned False 3"); - Logger.INFO("Charge Buses: "+this.mChargeHatches.size()+" | expected: >= 1 | "+(this.mChargeHatches.size() >= 1)); - Logger.INFO("Discharge Buses: "+this.mDischargeHatches.size()+" | expected: >= 1 | "+(this.mDischargeHatches.size() >= 1)); - Logger.INFO("Energy Hatches: "+this.mEnergyHatches.size()+" | expected: >= 1 | "+(this.mEnergyHatches.size() < 1)); - Logger.INFO("Dynamo Hatches: "+this.mAllDynamoHatches.size()+" | expected: >= 1 | "+(this.mAllDynamoHatches.size() < 1)); - Logger.INFO("Maint. Hatches: "+this.mMaintenanceHatches.size()+" | expected: 1 | "+(this.mMaintenanceHatches.size() != 1)); + Logger.INFO("Charge Buses: " + this.mChargeHatches.size() + " | expected: >= 1 | " + (this.mChargeHatches.size() >= 1)); + Logger.INFO("Discharge Buses: " + this.mDischargeHatches.size() + " | expected: >= 1 | " + (this.mDischargeHatches.size() >= 1)); + Logger.INFO("Energy Hatches: " + this.mEnergyHatches.size() + " | expected: >= 1 | " + (this.mEnergyHatches.size() < 1)); + Logger.INFO("Dynamo Hatches: " + this.mAllDynamoHatches.size() + " | expected: >= 1 | " + (this.mAllDynamoHatches.size() < 1)); + Logger.INFO("Maint. Hatches: " + this.mMaintenanceHatches.size() + " | expected: 1 | " + (this.mMaintenanceHatches.size() != 1)); return false; } @@ -291,11 +287,13 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe tempAvg += re.getOutputTier(); hatchCount++; } - if (hatchCount > 0){ - this.mAverageEuUsage = (tempAvg/hatchCount); + if (hatchCount > 0) { + this.mAverageEuUsage = (tempAvg / hatchCount); + } else { + this.mAverageEuUsage = 0; } - Logger.INFO("Structure Built? "+""+tAmount+" | "+(tAmount>=35)); + Logger.INFO("Structure Built? " + "" + tAmount + " | " + (tAmount >= 35)); return tAmount >= 35; } @@ -346,7 +344,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe this.mTotalEnergyLost = aNBT.getLong("mTotalEnergyLost"); this.mTotalEnergyConsumed = aNBT.getLong("mTotalEnergyConsumed"); this.mTotalRunTime = aNBT.getLong("mTotalRunTime"); - + this.mIsOutputtingPower = aNBT.getBoolean("mIsOutputtingPower"); super.loadNBTData(aNBT); -- cgit From 6d48df5a67acd70d4116827fa7dba729c94b83b7 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Wed, 7 Mar 2018 03:11:11 -1000 Subject: Substation: Rewrite machine running logic Implement logic in `onRunningTick` instead of `onPostTick`, allowing the base maintenance/repair logic to take effect. Rewrite hatch draining/filling to consider the station's available energy and the hatch's capacity and throughput, including its amperage. Energy hatches now correctly supply 2A to the station, and multi-amp dynamos output the proper number of amps. Rewrite running costs to consider the actual average voltage instead of the voltage tier, and increase running costs according to maintenance problems. Running cost % is now configurable via a constant ENERGY_TAX, currently 2%. Running costs deliberately ignore hatch amperage to make multi-amp hatches more appealing. Also clear the dynamo hatch lists on each machine check to prevent them filling up with duplicate hatches. --- ...chMetaTileEntity_PowerSubStationController.java | 180 +++++++++------------ 1 file changed, 75 insertions(+), 105 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines') 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 6f610e12d3..e8cc24dff6 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 @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; import java.util.ArrayList; import java.util.concurrent.TimeUnit; +import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; @@ -39,13 +40,14 @@ import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMeta_MultiBlockBase { - private static boolean controller; protected int mAverageEuUsage = 0; protected long mTotalEnergyAdded = 0; protected long mTotalEnergyConsumed = 0; protected long mTotalEnergyLost = 0; protected boolean mIsOutputtingPower = false; - + + private final int ENERGY_TAX = 2; + //TecTech Support public ArrayList mAllDynamoHatches = new ArrayList(); @@ -61,7 +63,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe public String[] getDescription() { return new String[]{ "Controller Block for the Power Sub-Station", - "Consumes 1% of the average voltage of all energy type hatches", + "Consumes " + this.ENERGY_TAX + "% of the average voltage of all energy type hatches", "Power can be Input/Extracted from the rear face at any time, change with screwdriver", "Size(WxHxD): External 5x4x5, Sub-Station Casings, Controller (Bottom, Centre)", "Size(WxHxD): Internal 3x2x3, Vanadium Redox Batteries", @@ -96,11 +98,6 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); } - @Override - public boolean checkRecipe(final ItemStack aStack) { - return true; - } - @Override public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { Logger.INFO("Checking structure for Industrial Power Sub-Station."); @@ -112,8 +109,10 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe return false; }*/ + this.mMultiDynamoHatches.clear(); + this.mAllDynamoHatches.clear(); + int tAmount = 0; - controller = false; for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { for (int h = 0; h < 4; h++) { @@ -279,12 +278,12 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe //mAverageEuUsage int tempAvg = 0; int hatchCount = 0; - for (GT_MetaTileEntity_Hatch_Energy re : this.mEnergyHatches){ - tempAvg += re.getInputTier(); + for (GT_MetaTileEntity_Hatch_Energy re : this.mEnergyHatches) { + tempAvg += re.maxEUInput(); hatchCount++; } - for (GT_MetaTileEntity_Hatch re : this.mAllDynamoHatches){ - tempAvg += re.getOutputTier(); + for (GT_MetaTileEntity_Hatch re : this.mAllDynamoHatches) { + tempAvg += re.maxEUOutput(); hatchCount++; } if (hatchCount > 0) { @@ -351,117 +350,88 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe } @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (this.getEUVar() < 0){ - this.setEUVar(0); - } + public boolean checkRecipe(final ItemStack aStack) { + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEUt = 0; + this.mEfficiencyIncrease = 10000; + return true; + } - //Handle Progress Time - if (this.getBaseMetaTileEntity().isAllowedToWork()){ - this.mProgresstime = 20; - this.mMaxProgresstime = 40; - //Use 10% of average EU determined by adding in/output voltage of all hatches and averaging. - int mDecrease = MathUtils.roundToClosestInt(mAverageEuUsage); - this.mTotalEnergyLost+=mDecrease; - this.setEUVar(this.getEUVar()-mDecrease); - //this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mDecrease, false); - } - else { - this.mProgresstime = 0; - this.mMaxProgresstime = 0; + private void drawEnergyFromHatch(MetaTileEntity aHatch) { + if (!isValidMetaTileEntity(aHatch)) return; + + long stored = aHatch.getEUVar(); + long voltage = aHatch.maxEUInput() * aHatch.maxAmperesIn(); + + if (voltage > stored) return; + + if (this.getBaseMetaTileEntity().increaseStoredEnergyUnits(voltage, false)) { + aHatch.setEUVar((stored - voltage)); + this.mTotalEnergyAdded += voltage; } + } - //Do work - if (this.getBaseMetaTileEntity().isAllowedToWork()){ + private void addEnergyToHatch(MetaTileEntity aHatch) { + if (!isValidMetaTileEntity(aHatch)) return; - //Input Power - if (this.getEUVar() < this.maxEUStore()){ - 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(); - if (stored > 0){ - energy.setEUVar((stored-voltage)); - this.mTotalEnergyAdded+=voltage; - this.getBaseMetaTileEntity().increaseStoredEnergyUnits(voltage, false); - } - } - } - else { + long voltage = aHatch.maxEUOutput() * aHatch.maxAmperesOut(); - } + if (aHatch.getEUVar() > aHatch.maxEUStore() - voltage) return; + + if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(voltage, false)) { + aHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(voltage, false); + this.mTotalEnergyConsumed+=voltage; + } + + } - //Output Power - addEnergyOutput(1); + private long computeEnergyTax() { + float mTax = mAverageEuUsage * (ENERGY_TAX / 100f); - } - super.onPostTick(aBaseMetaTileEntity, aTick); + // Increase tax up to 2x if machine is not fully repaired + mTax = mTax * (1f + (10000f - mEfficiency) / 10000f); + + return MathUtils.roundToClosestInt(mTax); } @Override - 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))){ + public boolean onRunningTick(ItemStack aStack) { + // First, Pay Tax + long mDecrease = computeEnergyTax(); + this.mTotalEnergyLost += Math.min(mDecrease, this.getEUVar()); + this.setEUVar(Math.max(0, this.getEUVar() - mDecrease)); - Logger.INFO("Draining Discharge Hatch #2"); - } + // Input Power + for (GT_MetaTileEntity_Hatch_OutputBattery tHatch : this.mDischargeHatches) { + drawEnergyFromHatch(tHatch); } for (GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { - if ((isValidMetaTileEntity(tHatch)) && (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false))){ + drawEnergyFromHatch(tHatch); + } - } - } - long nNewStoredPower = this.getEUVar(); - if (nNewStoredPower < nStoredPower){ - Logger.ERROR("Used "+(nStoredPower-nNewStoredPower)+"eu."); - return true; + // Output Power + for (GT_MetaTileEntity_Hatch_InputBattery tHatch : this.mChargeHatches) { + addEnergyToHatch(tHatch); + } + for (GT_MetaTileEntity_Hatch tHatch : this.mAllDynamoHatches) { + addEnergyToHatch(tHatch); } - return false; + return true; + + } + + @Override + public boolean drainEnergyInput(long aEU) { + // Not applicable to this machine + return true; } @Override public boolean addEnergyOutput(long aEU) { - if (aEU <= 0L) - return true; - long nStoredPower = this.getEUVar(); - int hatchCount = 0; - for (GT_MetaTileEntity_Hatch_InputBattery tHatch : this.mChargeHatches) { - if ((isValidMetaTileEntity(tHatch)) && (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(tHatch.maxEUInput(), false))) { - this.setEUVar(this.getEUVar()-(tHatch.maxEUInput())); - this.mTotalEnergyConsumed+=(tHatch.maxEUInput()); - } - hatchCount++; - } - for (GT_MetaTileEntity_Hatch tHatch : this.mAllDynamoHatches) { - if ((isValidMetaTileEntity(tHatch)) && (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(GT_Values.V[(int) tHatch.getOutputTier()], false))) { - this.setEUVar(this.getEUVar()-(GT_Values.V[(int) tHatch.getOutputTier()])); - this.mTotalEnergyConsumed+=(GT_Values.V[(int) tHatch.getOutputTier()]); - } - hatchCount++; - } - long nNewStoredPower = this.getEUVar(); - if (nNewStoredPower < nStoredPower){ - Logger.ERROR("Used "+(nStoredPower-nNewStoredPower)+"eu."); - return true; - } - return false; + // Not applicable to this machine + return true; } @Override @@ -494,7 +464,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe "Ergon Energy - District Sub-Station", "Stored EU:" + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET, "Capacity: " + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(this.maxEUStore()) + EnumChatFormatting.RESET, - "Running Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.mAverageEuUsage) + EnumChatFormatting.RESET + " EU/t", + "Running Costs: " + EnumChatFormatting.RED + GT_Utility.formatNumbers(this.computeEnergyTax()) + EnumChatFormatting.RESET + " EU/t", "Controller Mode: " + mode, "Stats for Nerds", "Total Input: " + EnumChatFormatting.BLUE + GT_Utility.formatNumbers(this.mTotalEnergyAdded) + EnumChatFormatting.RESET + " EU", -- cgit