From 739b1b7676db0d7b302a82722c2c8e1d440e1194 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Sat, 31 Mar 2018 13:51:35 -1000 Subject: Rewrite Power Sub-Station machine structure Machine now allows variable height with 2-16 layers of cells (configurable via CELL_HEIGHT_MIN/MAX constants). Machine now affords more cell types for its interior (as detected in `getCellTier()`). Three more tiers of cells are added. Machine now computes energy storage from the number and type of cells in its interior. Base energy storage drastically reduced. Energy storage is now computed using a base value for the lowest tier of cells along with a tier multiplier. If the machine fails to form, stored energy is conserved. When the machine successfully forms, any energy above the storage capacity is deleted. Machine fails to form if not all cells are identical, or if dynamo/energy hatches are above the cells' tier. TODO: Add more tiers of energy cells, add crafting recipes for all new energy cells, rename and retexture cells to match tier and/or recipe, maybe adjust energy storage values. --- ...chMetaTileEntity_PowerSubStationController.java | 323 ++++++++++----------- 1 file changed, 160 insertions(+), 163 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities') 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 8d57eb5fd0..1bed942cc1 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 @@ -11,18 +11,14 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Config; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; @@ -45,6 +41,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe protected long mTotalEnergyConsumed = 0; protected long mTotalEnergyLost = 0; protected boolean mIsOutputtingPower = false; + protected long mBatteryCapacity = 0; private final int ENERGY_TAX = 2; @@ -65,13 +62,15 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe "Controller Block for the Power Sub-Station", "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", + "Can be built with variable height between " + (CELL_HEIGHT_MIN + 2) + "-" + (CELL_HEIGHT_MAX + 2) + "", + "Size(WxHxD): External 5xHx5, Sub-Station Casings, Controller (Bottom, Centre)", + "Size(WxHxD): Internal 3x(H-2)x3, Energy Storage Cells", + "Number and quality of cells determines power storage", "Hatches can be placed nearly anywhere", "(Dis) Charging Hatches are valid", "1x Energy Input Hatch (Minimum)", "1x Energy Dynamo Hatch (Minimum)", - "1x Maintenance hatch", + "1x Maintenance Hatch", CORE.GT_Tooltip}; } @@ -98,149 +97,113 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); } + private void checkMachineProblem(String msg, int xOff, int yOff, int zOff) { + final IGregTechTileEntity te = this.getBaseMetaTileEntity(); + final Block tBlock = te.getBlockOffset(xOff, yOff, zOff); + final byte tMeta = te.getMetaIDOffset(xOff, yOff, zOff); + String name = tBlock.getLocalizedName(); + String problem = msg + ": (" + xOff + ", " + yOff + ", " + zOff + ") " + name + ":" + tMeta; + checkMachineProblem(problem); + } + private void checkMachineProblem(String msg) { + Logger.INFO("Power Sub-Station problem: " + msg); + } + + private int getCellTier(Block aBlock, int aMeta) { + if (aBlock == ModBlocks.blockCasings2Misc && aMeta == 7) { + return 3; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 4) { + return 4; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 5) { + return 5; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 6) { + return 6; + } else { + return -1; + } + } + + public static final int CELL_HEIGHT_MAX = 16; + public static final int CELL_HEIGHT_MIN = 2; + @Override public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { Logger.INFO("Checking structure for Industrial Power Sub-Station."); final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; - /*if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { - Utils.LOG_INFO("Don't know why this exists?"); - return false; - }*/ - this.mMultiDynamoHatches.clear(); this.mAllDynamoHatches.clear(); - int tAmount = 0; - for (int i = -2; i < 3; i++) { - for (int j = -2; j < 3; j++) { - for (int h = 0; h < 4; h++) { + boolean tFoundCeiling = false; + int tCasingCount = 0; + int tOverallCellTier = -1; + int tCellCount = 0; + + for (int yOff = 0; yOff < CELL_HEIGHT_MAX + 2; yOff++) { + if (tFoundCeiling) continue; + if (yOff == CELL_HEIGHT_MAX + 1) tFoundCeiling = true; - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + for (int i = -2; i < 3; i++) { + for (int j = -2; j < 3; j++) { + int xOff = xDir + i, zOff = zDir + j; - // Station Floor/Roof inner 5x5 - if (((i != -2) && (i != 2)) && ((j != -2) && (j != 2))) { + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, yOff, zOff); + if (tTileEntity == aBaseMetaTileEntity) continue; - // Station Floor & Roof (Inner 5x5) + Mufflers, Dynamos and Fluid outputs. - if ((h == 0 || h == 3) || (h == 2 || h == 1)) { + final Block tBlock = aBaseMetaTileEntity.getBlockOffset(xOff, yOff, zOff); + final byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xOff, yOff, zOff); - 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()); + if (yOff == 0) { + if (tBlock == ModBlocks.blockCasings2Misc && tMeta == 8) { + tCasingCount++; + } else if (!this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(24))) { + checkMachineProblem("Unexpected block in machine floor", xOff, yOff, zOff); + return false; + } + } else { + int tCellTier = -1; + if (i == -2 || i == 2 || j == -2 || j == 2) { + if (tBlock == ModBlocks.blockCasings2Misc && tMeta == 8) { + tCasingCount++; + } else if (!this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(24))) { + checkMachineProblem("Unexpected block in machine wall", xOff, yOff, zOff); + return false; + } + } else { + if (tBlock == ModBlocks.blockCasings2Misc && tMeta == 8) { + if (yOff > CELL_HEIGHT_MIN && i == -1 && j == -1) { + tFoundCeiling = true; + } else if (!tFoundCeiling) { + checkMachineProblem("Casing found where cell expected", xOff, yOff, zOff); 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)); + tCasingCount++; + } else if (this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(24))) { + if (yOff > 2 && i == -1 && j == -1) { + tFoundCeiling = true; + } else if (!tFoundCeiling) { + checkMachineProblem("Hatch found where cell expected", xOff, yOff, zOff); return false; } - } 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()); - 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)); - return false; - } - tAmount++; - } - } - 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()); - 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)); - return false; - } - tAmount++; - } - } - } - } - } - - //Dealt with inner 5x5, now deal with the exterior. - else { - - //Deal with all 4 sides (Station walls) - if ((h == 1) || (h == 2) || (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()); - 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()); - return false; - } - tAmount++; - } - } 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()); - 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()); + } else if ((tCellTier = getCellTier(tBlock, tMeta)) != -1) { + if (tFoundCeiling) { + checkMachineProblem("Cell found where casing/hatch expected", xOff, yOff, zOff); + return false; + } else { + if (tOverallCellTier == -1) { + tOverallCellTier = tCellTier; + tCellCount++; + } else if (tOverallCellTier != tCellTier) { + checkMachineProblem("Mismatched cell found, expected tier " + tOverallCellTier + " cell", xOff, yOff, zOff); return false; + } else { + tCellCount++; } - tAmount++; } } 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()); - 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()); - return false; - } - tAmount++; - } - } - } - - //Deal with top and Bottom edges (Inner 5x5) - else if ((h == 0) || (h == 3)) { - if (!this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(24))) { - if (((xDir + i) != 0) || ((zDir + j) != 0)) {//no controller - - 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()); - 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) { - - } - } else { - return false; - } - } - } + checkMachineProblem("Unexpected block in battery core", xOff, yOff, zOff); + return false; } } } @@ -249,52 +212,91 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe } } + if (tOverallCellTier == -1) { + checkMachineProblem("No cells in machine (this really shouldn't happen!)"); + return false; + } + + if (tCasingCount < 35) { + checkMachineProblem("Not enough casings (needed 35, found " + tCasingCount + ")"); + return false; + } + /** * TecTech Support, this allows adding Multi-Amp dynamos. */ - 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) { - mAllDynamoHatches.add(o); - } + mAllDynamoHatches.addAll(this.mDynamoHatches); + + if (LoadedMods.TecTech) { + mAllDynamoHatches.addAll(this.mMultiDynamoHatches); } - 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)); + if (this.mMaintenanceHatches.size() != 1) { + checkMachineProblem("Needed 1 maintenance hatch, found " + this.mMaintenanceHatches.size()); + return false; + } + if (this.mEnergyHatches.size() < 1) { + checkMachineProblem("Needed at least 1 energy hatch, found 0"); + return false; + } + if (this.mAllDynamoHatches.size() < 1) { + checkMachineProblem("Needed at least 1 dynamo hatch, found 0"); return false; } - //mAverageEuUsage - int tempAvg = 0; + // Find average EU throughput + int totalEuThroughput = 0; int hatchCount = 0; + for (GT_MetaTileEntity_Hatch_Energy re : this.mEnergyHatches) { - tempAvg += re.maxEUInput(); + long tier = re.getOutputTier(); + if(tier > tOverallCellTier) { + checkMachineProblem("Energy hatch (tier " + tier + ") is too strong for cells (tier " + tOverallCellTier + ")"); + return false; + } + totalEuThroughput += re.maxEUInput(); hatchCount++; } + for (GT_MetaTileEntity_Hatch re : this.mAllDynamoHatches) { - tempAvg += re.maxEUOutput(); + long tier = re.getInputTier(); + if(tier > tOverallCellTier) { + checkMachineProblem("Dynamo hatch (tier " + tier + ") is too strong for cells (tier " + tOverallCellTier + ")"); + return false; + } + totalEuThroughput += re.maxEUOutput(); hatchCount++; } + if (hatchCount > 0) { - this.mAverageEuUsage = (tempAvg / hatchCount); + this.mAverageEuUsage = (totalEuThroughput / hatchCount); } else { + // Shouldn't happen this.mAverageEuUsage = 0; } - Logger.INFO("Structure Built? " + "" + tAmount + " | " + (tAmount >= 35)); + // Only set these here, after the machine check is 100% passed. - return tAmount >= 35; + this.mBatteryCapacity = getCapacityFromCellTier(tOverallCellTier) * tCellCount; + this.setEUVar(Math.min(this.getEUVar(), this.mBatteryCapacity)); + return true; + } + + // Define storage capacity of smallest cell tier (HV) and compute higher tiers from it + private static final long CELL_TIER_HV_CAPACITY = 10 * 1000 * 1000; // one lapotron crystal + private static final long CELL_TIER_MULTIPLIER = 4; // each tier's capacity is this many times the previous tier + + public static long getCapacityFromCellTier(int aOverallCellTier) { + // Use integer math instead of `Math.pow` to avoid range/precision errors + if (aOverallCellTier < 3) return 0; + aOverallCellTier -= 3; + long capacity = CELL_TIER_HV_CAPACITY; + while (aOverallCellTier > 0) { + capacity *= CELL_TIER_MULTIPLIER; + aOverallCellTier--; + } + return capacity; } @Override @@ -312,15 +314,9 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe return new GregtechMetaTileEntity_PowerSubStationController(this.mName); } - //NBT Power Storage handling - long mPowerStorageBuffer = 0; - int mPowerStorageMultiplier = 32; - //mTotalEnergyAdded @Override public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setLong("mPowerStorageBuffer", this.mPowerStorageBuffer); - aNBT.setInteger("mPowerStorageMultiplier", this.mPowerStorageMultiplier); aNBT.setInteger("mAverageEuUsage", this.mAverageEuUsage); //Usage Stats @@ -329,13 +325,12 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe aNBT.setLong("mTotalEnergyConsumed", this.mTotalEnergyConsumed); aNBT.setLong("mTotalRunTime", this.mTotalRunTime); aNBT.setBoolean("mIsOutputtingPower", this.mIsOutputtingPower); + aNBT.setLong("mBatteryCapacity", this.mBatteryCapacity); super.saveNBTData(aNBT); } @Override public void loadNBTData(NBTTagCompound aNBT) { - this.mPowerStorageBuffer = aNBT.getLong("mPowerStorageBuffer"); - this.mPowerStorageMultiplier = aNBT.getInteger("mPowerStorageMultiplier"); this.mAverageEuUsage = aNBT.getInteger("mAverageEuUsage"); //Usage Stats @@ -346,6 +341,8 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe this.mIsOutputtingPower = aNBT.getBoolean("mIsOutputtingPower"); + this.mBatteryCapacity = aNBT.getLong("mBatteryCapacity"); + super.loadNBTData(aNBT); } @@ -436,7 +433,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe @Override public long maxEUStore() { - return 9200000000000000000L; + return mBatteryCapacity; } @Override @@ -480,7 +477,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe "Total Time in ticks: "+this.mTotalRunTime }; - }; + } @Override public boolean isGivingInformation() { -- cgit 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/gtPlusPlus/xmod/gregtech/common/tileentities') 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 From 2cf95a2b3e82ceb3a8eec69e33262cf36b797ae6 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Thu, 5 Apr 2018 22:26:38 -1000 Subject: Add energy cell tiers up to MAX voltage, make lowest cell EV tier Renamed cells to the voltage tiers Added textures for new cells, adjusted existing textures. Texture colors are vaguely similar to pump/robot arm colors Legacy power stations will have 1.8 billion EU storage --- .../xmod/gregtech/api/enums/GregtechItemList.java | 9 ++++-- .../common/blocks/GregtechMetaCasingBlocks2.java | 8 +++--- .../common/blocks/GregtechMetaCasingBlocks3.java | 32 +++++++++------------ .../blocks/textures/CasingTextureHandler3.java | 12 ++++---- .../common/blocks/textures/TexturesGtBlock.java | 4 +++ ...chMetaTileEntity_PowerSubStationController.java | 20 ++++++------- .../miscutils/textures/blocks/redox/redox1.png | Bin 717 -> 562 bytes .../miscutils/textures/blocks/redox/redox2.png | Bin 741 -> 721 bytes .../miscutils/textures/blocks/redox/redox3.png | Bin 693 -> 776 bytes .../miscutils/textures/blocks/redox/redox4.png | Bin 708 -> 781 bytes .../miscutils/textures/blocks/redox/redox5.png | Bin 0 -> 794 bytes .../miscutils/textures/blocks/redox/redox6.png | Bin 0 -> 779 bytes 12 files changed, 44 insertions(+), 41 deletions(-) create mode 100644 src/resources/assets/miscutils/textures/blocks/redox/redox5.png create mode 100644 src/resources/assets/miscutils/textures/blocks/redox/redox6.png (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index afbf68d8a6..2b9860ef1c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -167,9 +167,12 @@ public enum GregtechItemList implements GregtechItemContainer { //Power Substation Casing_Vanadium_Redox, - Casing_Vanadium_Redox_T2, - Casing_Vanadium_Redox_T3, - Casing_Vanadium_Redox_T4, + Casing_Vanadium_Redox_IV, + Casing_Vanadium_Redox_LuV, + Casing_Vanadium_Redox_ZPM, + Casing_Vanadium_Redox_UV, + Casing_Vanadium_Redox_MAX, + Casing_Power_SubStation, //Cyclotron diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java index e80d9e2110..8dd52c7074 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java @@ -31,9 +31,9 @@ extends GregtechMetaCasingBlocksAbstract { @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { int meta = aStack.getItemDamage(); - long capacity = 0; - if (meta == 7) { - capacity = GregtechMetaTileEntity_PowerSubStationController.getCapacityFromCellTier(3); + int tier = GregtechMetaTileEntity_PowerSubStationController.getCellTier(field_150939_a, meta); + if (tier > 0) { + long capacity = GregtechMetaTileEntity_PowerSubStationController.getCapacityFromCellTier(tier); aList.add("Energy Storage: " + GT_Utility.formatNumbers(capacity)); } super.addInformation(aStack, aPlayer, aList, aF3_H); @@ -52,7 +52,7 @@ extends GregtechMetaCasingBlocksAbstract { GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Wash Plant Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Industrial Sieve Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Large Sieve Grate"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Vanadium Redox Power Cell"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Vanadium Redox Power Cell (EV)"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Sub-Station External Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Cyclotron Coil"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Cyclotron Outer Casing"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java index f13a0b786e..7baa8ec36a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java @@ -31,17 +31,9 @@ extends GregtechMetaCasingBlocksAbstract { @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { int meta = aStack.getItemDamage(); - long capacity = 0; - switch (meta) { - case 4: - case 5: - case 6: - capacity = GregtechMetaTileEntity_PowerSubStationController.getCapacityFromCellTier(meta); - break; - default: - break; - } - if (capacity > 0) { + int tier = GregtechMetaTileEntity_PowerSubStationController.getCellTier(field_150939_a, meta); + if (tier > 0) { + long capacity = GregtechMetaTileEntity_PowerSubStationController.getCapacityFromCellTier(tier); aList.add("Energy Storage: " + GT_Utility.formatNumbers(capacity)); } super.addInformation(aStack, aPlayer, aList, aF3_H); @@ -57,11 +49,11 @@ extends GregtechMetaCasingBlocksAbstract { GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Inconel Reinforced Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Multi-Use Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Trinium Plated Mining Platform Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Vanadium Redox Cell (Lapotron Fortified)"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Vanadium Redox Cell (Naquadah Doped)"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Vanadium Redox Cell (Neutronium Laced)"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Placeholder");; - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Vanadium Redox Power Cell (IV)"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Vanadium Redox Power Cell (LuV)"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Vanadium Redox Power Cell (ZPM)"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Vanadium Redox Power Cell (UV)");; + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Vanadium Redox Power Cell (MAX)"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Placeholder"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Placeholder"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Placeholder"); @@ -73,9 +65,11 @@ extends GregtechMetaCasingBlocksAbstract { GregtechItemList.Casing_Extruder.set(new ItemStack(this, 1, 1)); GregtechItemList.Casing_Multi_Use.set(new ItemStack(this, 1, 2)); GregtechItemList.Casing_BedrockMiner.set(new ItemStack(this, 1, 3)); - GregtechItemList.Casing_Vanadium_Redox_T2.set(new ItemStack(this, 1, 4)); - GregtechItemList.Casing_Vanadium_Redox_T3.set(new ItemStack(this, 1, 5)); - GregtechItemList.Casing_Vanadium_Redox_T4.set(new ItemStack(this, 1, 6)); + GregtechItemList.Casing_Vanadium_Redox_IV.set(new ItemStack(this, 1, 4)); + GregtechItemList.Casing_Vanadium_Redox_LuV.set(new ItemStack(this, 1, 5)); + GregtechItemList.Casing_Vanadium_Redox_ZPM.set(new ItemStack(this, 1, 6)); + GregtechItemList.Casing_Vanadium_Redox_UV.set(new ItemStack(this, 1, 7)); + GregtechItemList.Casing_Vanadium_Redox_MAX.set(new ItemStack(this, 1, 8)); //GregtechItemList.Casing_WashPlant.set(new ItemStack(this, 1, 4)); //GregtechItemList.Casing_Sifter.set(new ItemStack(this, 1, 5)); //GregtechItemList.Casing_SifterGrate.set(new ItemStack(this, 1, 6)); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java index d6844a1eed..e83ce098c8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java @@ -20,18 +20,20 @@ public class CasingTextureHandler3 { //Trinium Plated Mining Platform Casing return TexturesGtBlock.Casing_Staballoy_Firebox.getIcon(); case 4: - //Vanadium Redox T2 + //Vanadium Redox IV return TexturesGtBlock.Casing_Redox_2.getIcon(); case 5: - //Vanadium Redox T3 + //Vanadium Redox LuV return TexturesGtBlock.Casing_Redox_3.getIcon(); case 6: - //Vanadium Redox T4 + //Vanadium Redox ZPM return TexturesGtBlock.Casing_Redox_4.getIcon(); case 7: - return TexturesGtBlock._PlaceHolder.getIcon(); + //Vanadium Redox UV + return TexturesGtBlock.Casing_Redox_5.getIcon(); case 8: - return TexturesGtBlock._PlaceHolder.getIcon(); + //Vanadium Redox MAX + return TexturesGtBlock.Casing_Redox_6.getIcon(); case 9: return TexturesGtBlock._PlaceHolder.getIcon(); case 10: diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index 0f8c8d44c5..0c187480bb 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -168,6 +168,10 @@ public class TexturesGtBlock { public static final CustomIcon Casing_Redox_2 = new CustomIcon("redox/redox2"); public static final CustomIcon Casing_Redox_3 = new CustomIcon("redox/redox3"); public static final CustomIcon Casing_Redox_4 = new CustomIcon("redox/redox4"); + public static final CustomIcon Casing_Redox_5 = new CustomIcon("redox/redox5"); + public static final CustomIcon Casing_Redox_6 = new CustomIcon("redox/redox6"); + public static final CustomIcon Casing_Redox_7 = new CustomIcon("redox/redox7"); + public static final CustomIcon Casing_Redox_8 = new CustomIcon("redox/redox8"); //Centrifuge Casing private static final CustomIcon Internal_Casing_Centrifuge = new CustomIcon("TileEntities/MACHINE_CASING_CENTRIFUGE"); 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 2aa30a0c30..4746dc2728 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 @@ -109,15 +109,15 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe Logger.INFO("Power Sub-Station problem: " + msg); } - private int getCellTier(Block aBlock, int aMeta) { + public static int getCellTier(Block aBlock, int aMeta) { if (aBlock == ModBlocks.blockCasings2Misc && aMeta == 7) { - return 3; - } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 4) { return 4; - } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 5) { + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 4) { return 5; - } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 6) { + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 5) { return 6; + } else if (aBlock == ModBlocks.blockCasings3Misc && aMeta == 6) { + return 7; } else { return -1; } @@ -282,15 +282,15 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMe return true; } - // Define storage capacity of smallest cell tier (HV) and compute higher tiers from it - private static final long CELL_TIER_HV_CAPACITY = 10 * 1000 * 1000; // one lapotron crystal + // Define storage capacity of smallest cell tier (EV) and compute higher tiers from it + private static final long CELL_TIER_EV_CAPACITY = 100 * 1000 * 1000; // one lapotronic orb private static final long CELL_TIER_MULTIPLIER = 4; // each tier's capacity is this many times the previous tier public static long getCapacityFromCellTier(int aOverallCellTier) { // Use integer math instead of `Math.pow` to avoid range/precision errors - if (aOverallCellTier < 3) return 0; - aOverallCellTier -= 3; - long capacity = CELL_TIER_HV_CAPACITY; + if (aOverallCellTier < 4) return 0; + aOverallCellTier -= 4; + long capacity = CELL_TIER_EV_CAPACITY; while (aOverallCellTier > 0) { capacity *= CELL_TIER_MULTIPLIER; aOverallCellTier--; diff --git a/src/resources/assets/miscutils/textures/blocks/redox/redox1.png b/src/resources/assets/miscutils/textures/blocks/redox/redox1.png index f3a48f72f8..05b752e0e7 100644 Binary files a/src/resources/assets/miscutils/textures/blocks/redox/redox1.png and b/src/resources/assets/miscutils/textures/blocks/redox/redox1.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/redox/redox2.png b/src/resources/assets/miscutils/textures/blocks/redox/redox2.png index 0456dbe20b..231b6b17af 100644 Binary files a/src/resources/assets/miscutils/textures/blocks/redox/redox2.png and b/src/resources/assets/miscutils/textures/blocks/redox/redox2.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/redox/redox3.png b/src/resources/assets/miscutils/textures/blocks/redox/redox3.png index ab2b3b27e9..88cb664c41 100644 Binary files a/src/resources/assets/miscutils/textures/blocks/redox/redox3.png and b/src/resources/assets/miscutils/textures/blocks/redox/redox3.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/redox/redox4.png b/src/resources/assets/miscutils/textures/blocks/redox/redox4.png index b925ffc26b..a627b64eef 100644 Binary files a/src/resources/assets/miscutils/textures/blocks/redox/redox4.png and b/src/resources/assets/miscutils/textures/blocks/redox/redox4.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/redox/redox5.png b/src/resources/assets/miscutils/textures/blocks/redox/redox5.png new file mode 100644 index 0000000000..9564596329 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/redox/redox5.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/redox/redox6.png b/src/resources/assets/miscutils/textures/blocks/redox/redox6.png new file mode 100644 index 0000000000..1023b718cc Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/redox/redox6.png differ -- cgit