diff options
Diffstat (limited to 'src/Java/gtPlusPlus')
7 files changed, 248 insertions, 190 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 9c3abb8625..afbf68d8a6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -166,7 +166,10 @@ public enum GregtechItemList implements GregtechItemContainer { Casing_SifterGrate, //Power Substation - Casing_Vanadium_Redox, + Casing_Vanadium_Redox, + Casing_Vanadium_Redox_T2, + Casing_Vanadium_Redox_T3, + Casing_Vanadium_Redox_T4, 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 2f64b943b7..e80d9e2110 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java @@ -1,5 +1,9 @@ package gtPlusPlus.xmod.gregtech.common.blocks; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_PowerSubStationController; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; @@ -11,13 +15,33 @@ import gregtech.common.blocks.GT_Material_Casings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler2; +import java.util.List; + public class GregtechMetaCasingBlocks2 extends GregtechMetaCasingBlocksAbstract { CasingTextureHandler2 TextureHandler = new CasingTextureHandler2(); + public static class GregtechMetaCasingItemBlocks2 extends GregtechMetaCasingItems { + + public GregtechMetaCasingItemBlocks2(Block par1) { + super(par1); + } + + @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); + aList.add("Energy Storage: " + GT_Utility.formatNumbers(capacity)); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } + public GregtechMetaCasingBlocks2() { - super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.2", GT_Material_Casings.INSTANCE); + super(GregtechMetaCasingItemBlocks2.class, "gtplusplus.blockcasings.2", GT_Material_Casings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java index 0204b08b2e..f13a0b786e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java @@ -1,5 +1,9 @@ package gtPlusPlus.xmod.gregtech.common.blocks; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.storage.GregtechMetaTileEntity_PowerSubStationController; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; @@ -11,13 +15,41 @@ import gregtech.common.blocks.GT_Material_Casings; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.blocks.textures.CasingTextureHandler3; +import java.util.List; + public class GregtechMetaCasingBlocks3 extends GregtechMetaCasingBlocksAbstract { CasingTextureHandler3 TextureHandler = new CasingTextureHandler3(); + public static class GregtechMetaCasingItemBlocks3 extends GregtechMetaCasingItems { + + public GregtechMetaCasingItemBlocks3(Block par1) { + super(par1); + } + + @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) { + aList.add("Energy Storage: " + GT_Utility.formatNumbers(capacity)); + } + super.addInformation(aStack, aPlayer, aList, aF3_H); + } + } + public GregtechMetaCasingBlocks3() { - super(GregtechMetaCasingItems.class, "gtplusplus.blockcasings.3", GT_Material_Casings.INSTANCE); + super(GregtechMetaCasingItemBlocks3.class, "gtplusplus.blockcasings.3", GT_Material_Casings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); } @@ -25,9 +57,9 @@ 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", "Placeholder"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Placeholder"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Placeholder"); + 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() + ".9.name", "Placeholder"); @@ -41,6 +73,9 @@ 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_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/CasingTextureHandler2.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java index 96f13dbd5f..8f107b8ab6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java @@ -33,7 +33,7 @@ public class CasingTextureHandler2 { //Vanadium Radox Battery case 7: - return TexturesGtBlock.Overlay_Machine_Cyber_B.getIcon(); + return TexturesGtBlock.Casing_Redox_1.getIcon(); //Power Sub-Station Casing case 8: return TexturesGtBlock.Casing_Machine_Metal_Sheet_A.getIcon(); 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 51fb289b61..d6844a1eed 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java @@ -7,46 +7,39 @@ public class CasingTextureHandler3 { public static IIcon getIcon(final int aSide, final int aMeta) { //Texture ID's. case 0 == ID[57] if ((aMeta >= 0) && (aMeta < 16)) { switch (aMeta) { - //Centrifuge - case 0: - return TexturesGtBlock.TEXTURE_METAL_PANEL_B.getIcon(); - //Coke Oven Frame + case 0: + //Aquatic Casing + return TexturesGtBlock.TEXTURE_METAL_PANEL_B.getIcon(); case 1: + //Inconel Reinforced Casing return TexturesGtBlock.TEXTURE_METAL_PANEL_D.getIcon(); - //Coke Oven Casing Tier 1 case 2: + //Multi-Use Casing return TexturesGtBlock.TEXTURE_METAL_PANEL_C.getIcon(); - //Coke Oven Casing Tier 2 case 3: + //Trinium Plated Mining Platform Casing return TexturesGtBlock.Casing_Staballoy_Firebox.getIcon(); - //Material Press Casings case 4: - return TexturesGtBlock._PlaceHolder.getIcon(); - //Sifter Structural + //Vanadium Redox T2 + return TexturesGtBlock.Casing_Redox_2.getIcon(); case 5: - return TexturesGtBlock._PlaceHolder.getIcon(); - //Sifter Sieve + //Vanadium Redox T3 + return TexturesGtBlock.Casing_Redox_3.getIcon(); case 6: - return TexturesGtBlock._PlaceHolder.getIcon(); - //Vanadium Radox Battery + //Vanadium Redox T4 + return TexturesGtBlock.Casing_Redox_4.getIcon(); case 7: return TexturesGtBlock._PlaceHolder.getIcon(); - //Power Sub-Station Casing case 8: return TexturesGtBlock._PlaceHolder.getIcon(); - //Cyclotron Coil case 9: return TexturesGtBlock._PlaceHolder.getIcon(); - //Cyclotron External Casing case 10: return TexturesGtBlock._PlaceHolder.getIcon(); - //Multitank Exterior Casing case 11: return TexturesGtBlock._PlaceHolder.getIcon(); - //Reactor Casing I case 12: return TexturesGtBlock._PlaceHolder.getIcon(); - //Reactor Casing II case 13: if (aSide <2) { return TexturesGtBlock._PlaceHolder.getIcon(); @@ -57,7 +50,7 @@ public class CasingTextureHandler3 { case 14: return TexturesGtBlock._PlaceHolder.getIcon(); case 15: - return TexturesGtBlock._PlaceHolder.getIcon(); //Tree Farmer Textures + return TexturesGtBlock._PlaceHolder.getIcon(); default: return TexturesGtBlock._PlaceHolder.getIcon(); 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 a93cff61b2..0f8c8d44c5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -163,6 +163,12 @@ public class TexturesGtBlock { private static final CustomIcon Internal_Casing_Machine_Redstone_On = new CustomIcon("TileEntities/cover_redstone_emitter"); public static final CustomIcon Casing_Machine_Redstone_On = Internal_Casing_Machine_Redstone_On; + //Redox Cells + public static final CustomIcon Casing_Redox_1 = new CustomIcon("redox/redox1"); + 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"); + //Centrifuge Casing private static final CustomIcon Internal_Casing_Centrifuge = new CustomIcon("TileEntities/MACHINE_CASING_CENTRIFUGE"); public static final CustomIcon Casing_Material_Centrifuge = Internal_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 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() { |