From 3b00fa07063bbdddf3f3f7ebbea94a641ddf2d39 Mon Sep 17 00:00:00 2001 From: miozune Date: Sun, 8 Oct 2023 18:18:58 +0900 Subject: [PATCH] Cleanup isValidMetaTileEntity and some more (#364) * updateBuildScript & updateDependencies * Update .gitignore * Cleanup isValidMetaTileEntity * Remove unused and obsolete members --- .gitignore | 12 +- build.gradle | 4 +- dependencies.gradle | 6 +- .../GT_TileEntity_CircuitAssemblyLine.java | 13 +- .../multis/GT_TileEntity_HTGR.java | 20 +-- .../multis/GT_TileEntity_THTR.java | 17 +- .../mega/GT_TileEntity_MegaBlastFurnace.java | 4 +- .../GT_TileEntity_MegaMultiBlockBase.java | 23 +-- .../mega/GT_TileEntity_MegaOilCracker.java | 51 +++--- .../bartimaeusnek/bartworks/util/BW_Util.java | 163 ------------------ .../bartworks/util/MegaUtils.java | 43 ----- .../tectech/TT_TileEntity_ManualTrafo.java | 146 ---------------- 12 files changed, 73 insertions(+), 429 deletions(-) delete mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/MegaUtils.java delete mode 100644 src/main/java/com/github/bartimaeusnek/crossmod/tectech/TT_TileEntity_ManualTrafo.java diff --git a/.gitignore b/.gitignore index 5fcf044de..5e80e0ae5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .gradle .settings /.idea/ +/.vscode/ /run/ /build/ /eclipse/ @@ -25,6 +26,13 @@ whitelist.json *.iml *.ipr *.iws -src/main/resources/mixins.*.json +src/main/resources/mixins.*([!.]).json *.bat -.vscode/ \ No newline at end of file +*.DS_Store +!gradlew.bat +.factorypath +addon.local.gradle +addon.local.gradle.kts +addon.late.local.gradle +addon.late.local.gradle.kts +layout.json diff --git a/build.gradle b/build.gradle index 6a54d13b0..621bc62fa 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1695474595 +//version: 1696265388 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. @@ -798,7 +798,7 @@ dependencies { java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}") } if (modId != 'hodgepodge') { - java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.5') + java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.7') } java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false} diff --git a/dependencies.gradle b/dependencies.gradle index ba2504f69..cf2c91842 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,13 +1,13 @@ // Add your dependencies here dependencies { - api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.23:dev') - api("com.github.GTNewHorizons:TecTech:5.3.3:dev") + api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.31:dev') + api("com.github.GTNewHorizons:TecTech:5.3.5:dev") api("com.github.GTNewHorizons:GalacticGregGT5:1.0.10:dev") { exclude group:"com.github.GTNewHorizons", module:"bartworks" } api("com.github.GTNewHorizons:Avaritia:1.46:dev") - implementation("com.github.GTNewHorizons:TinkersConstruct:1.10.3-GTNH:dev") + implementation("com.github.GTNewHorizons:TinkersConstruct:1.10.5-GTNH:dev") compileOnly("com.github.GTNewHorizons:TinkersGregworks:GTNH-1.0.24-pre:dev") {transitive = false} compileOnly("com.github.GTNewHorizons:OpenComputers:1.9.17-GTNH:api") {transitive = false} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java index e3543a533..6b9964e4d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java @@ -28,6 +28,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_GLOW; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_Utility.filterValidMTEs; import java.util.ArrayList; import java.util.List; @@ -246,14 +247,12 @@ protected SoundResource getProcessStartSound() { @Override public ArrayList getStoredInputs() { ArrayList rList = new ArrayList<>(); - for (GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) { + for (GT_MetaTileEntity_Hatch_InputBus tHatch : filterValidMTEs(mInputBusses)) { tHatch.mRecipeMap = this.getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { - if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) { - rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); - break; - } + for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) { + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + break; } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java index 8e6bcc85d..45b9b83fd 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java @@ -16,6 +16,7 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.GT_Values.AuthorKuba; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_Utility.filterValidMTEs; import java.util.ArrayList; import java.util.HashMap; @@ -334,8 +335,7 @@ public boolean onRunningTick(ItemStack aStack) { this.fuelsupply, HTGRMaterials.MATERIALS_PER_FUEL * this.fueltype + HTGRMaterials.USABLE_FUEL_INDEX); boolean storedAll = false; - for (GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) { - if (!isValidMetaTileEntity(tHatch)) continue; + for (GT_MetaTileEntity_Hatch_OutputBus tHatch : filterValidMTEs(mOutputBusses)) { if (tHatch.storeAll(iStack)) { storedAll = true; break; @@ -365,15 +365,13 @@ public boolean onRunningTick(ItemStack aStack) { int takecoolant = this.coolanttaking; int drainedamount = 0; - for (GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { - if (isValidMetaTileEntity(tHatch)) { - FluidStack tLiquid = tHatch.getFluid(); - if (tLiquid != null && tLiquid.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1))) { - FluidStack drained = tHatch.drain(takecoolant, true); - takecoolant -= drained.amount; - drainedamount += drained.amount; - if (takecoolant <= 0) break; - } + for (GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) { + FluidStack tLiquid = tHatch.getFluid(); + if (tLiquid != null && tLiquid.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1))) { + FluidStack drained = tHatch.drain(takecoolant, true); + takecoolant -= drained.amount; + drainedamount += drained.amount; + if (takecoolant <= 0) break; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java index 89f27cf41..447f21281 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java @@ -19,6 +19,7 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import static gregtech.api.util.GT_Utility.filterValidMTEs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -294,15 +295,13 @@ public boolean onRunningTick(ItemStack aStack) { int takecoolant = this.coolanttaking; int drainedamount = 0; - for (GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { - if (isValidMetaTileEntity(tHatch)) { - FluidStack tLiquid = tHatch.getFluid(); - if (tLiquid != null && tLiquid.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1))) { - FluidStack drained = tHatch.drain(takecoolant, true); - takecoolant -= drained.amount; - drainedamount += drained.amount; - if (takecoolant <= 0) break; - } + for (GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) { + FluidStack tLiquid = tHatch.getFluid(); + if (tLiquid != null && tLiquid.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1))) { + FluidStack drained = tHatch.drain(takecoolant, true); + takecoolant -= drained.amount; + drainedamount += drained.amount; + if (takecoolant <= 0) break; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java index bf80c80a1..5b4f3a1ec 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java @@ -24,6 +24,7 @@ import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gregtech.api.util.GT_Utility.filterValidMTEs; import java.util.ArrayList; import java.util.Arrays; @@ -337,8 +338,7 @@ public boolean addOutput(FluidStack aLiquid) { if (isOutputPollution) { tOutputHatches = this.mPollutionOutputHatches; int pollutionReduction = 0; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : this.mMufflerHatches) { - if (!isValidMetaTileEntity(tHatch)) continue; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : filterValidMTEs(mMufflerHatches)) { pollutionReduction = 100 - tHatch.calculatePollutionReduction(100); break; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java index e66604783..700dbb8e3 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java @@ -1,5 +1,7 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; +import static gregtech.api.util.GT_Utility.filterValidMTEs; + import java.util.Arrays; import net.minecraft.init.Blocks; @@ -20,7 +22,6 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.util.GT_Utility; public abstract class GT_TileEntity_MegaMultiBlockBase> @@ -50,10 +51,8 @@ protected String[] getExtendedInfoData() { protected long[] getCurrentInfoData() { long storedEnergy = 0, maxEnergy = 0; for (GT_MetaTileEntity_Hatch hatch : this.getExoticAndNormalEnergyHatchList()) { - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { - storedEnergy += hatch.getBaseMetaTileEntity().getStoredEU(); - maxEnergy += hatch.getBaseMetaTileEntity().getEUCapacity(); - } + storedEnergy += hatch.getBaseMetaTileEntity().getStoredEU(); + maxEnergy += hatch.getBaseMetaTileEntity().getEUCapacity(); } return new long[] { storedEnergy, maxEnergy }; } @@ -62,21 +61,17 @@ protected long[] getCurrentInfoData() { public String[] getInfoData() { int mPollutionReduction = 0; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : this.mMufflerHatches) { - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction); - } + for (GT_MetaTileEntity_Hatch_Muffler tHatch : filterValidMTEs(mMufflerHatches)) { + mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction); } long[] ttHatches = this.getCurrentInfoData(); long storedEnergy = ttHatches[0]; long maxEnergy = ttHatches[1]; - for (GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); - maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); - } + for (GT_MetaTileEntity_Hatch_Energy tHatch : filterValidMTEs(mEnergyHatches)) { + storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); } long nominalV = this.getMaxInputEu(); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java index e31b3563f..815b2a249 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java @@ -25,6 +25,7 @@ import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gregtech.api.util.GT_Utility.filterValidMTEs; import java.util.ArrayList; import java.util.List; @@ -327,38 +328,34 @@ private boolean addMiddleInputToMachineList(IGregTechTileEntity aTileEntity, int @Override public ArrayList getStoredFluids() { final ArrayList rList = new ArrayList<>(); - for (final GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { - if (isValidMetaTileEntity(tHatch)) { - tHatch.mRecipeMap = getRecipeMap(); - if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) { - for (final FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { - if (tFluid != null && !GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tFluid)) { - rList.add(tFluid); - } - } - } else { - if (tHatch.getFillableStack() != null) { - if (!GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tHatch.getFillableStack())) - rList.add(tHatch.getFillableStack()); + for (final GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) { + tHatch.mRecipeMap = getRecipeMap(); + if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) { + for (final FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { + if (tFluid != null && !GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tFluid)) { + rList.add(tFluid); } } + } else { + if (tHatch.getFillableStack() != null) { + if (!GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tHatch.getFillableStack())) + rList.add(tHatch.getFillableStack()); + } } } - for (final GT_MetaTileEntity_Hatch_Input tHatch : mMiddleInputHatches) { - if (isValidMetaTileEntity(tHatch)) { - tHatch.mRecipeMap = getRecipeMap(); - if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) { - for (final FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { - if (tFluid != null && GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tFluid)) { - rList.add(tFluid); - } + for (final GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mMiddleInputHatches)) { + tHatch.mRecipeMap = getRecipeMap(); + if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) { + for (final FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { + if (tFluid != null && GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tFluid)) { + rList.add(tFluid); } - } else { - if (tHatch.getFillableStack() != null) { - final FluidStack tStack = tHatch.getFillableStack(); - if (GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tStack)) { - rList.add(tStack); - } + } + } else { + if (tHatch.getFillableStack() != null) { + final FluidStack tStack = tHatch.getFillableStack(); + if (GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tStack)) { + rList.add(tStack); } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java index 69438bff9..bd9ee551c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java @@ -16,7 +16,6 @@ import static gregtech.api.enums.GT_Values.D1; import static gregtech.api.enums.GT_Values.E; import static gregtech.api.enums.GT_Values.M; -import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.VN; import static gregtech.api.enums.GT_Values.W; @@ -24,7 +23,6 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -64,11 +62,6 @@ import gregtech.api.enums.OreDictNames; import gregtech.api.enums.ToolDictNames; import gregtech.api.interfaces.IItemContainer; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.ItemData; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; @@ -222,26 +215,6 @@ public static byte specialToByte(int aSpecialValue) { return special; } - public static boolean addBlockToMachine(int x, int y, int z, int offsetsize, - IGregTechTileEntity aBaseMetaTileEntity, Block block) { - int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * offsetsize; - int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * offsetsize; - - return block == Blocks.air ? aBaseMetaTileEntity.getAirOffset(xDir + x, y, zDir + z) - : aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(block); - } - - public static boolean addBlockToMachine(int x, int y, int z, int offsetsize, - IGregTechTileEntity aBaseMetaTileEntity, Block block, int damage) { - byte dmg = (byte) damage; - int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * offsetsize; - int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * offsetsize; - - return block == Blocks.air ? aBaseMetaTileEntity.getAirOffset(xDir + x, y, zDir + z) - : aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(block) - && aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) == dmg; - } - public static int calculateSv(Materials materials) { for (BioVatLogicAdder.MaterialSvPair pair : BioVatLogicAdder.RadioHatch.getMaSv()) { if (pair.getMaterials().equals(materials)) return pair.getSievert(); @@ -264,19 +237,6 @@ public static boolean checkStackAndPrefix(ItemStack itemStack) { && GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial != null; } - public static Map getInputsFromOutput(Collection gt_recipes, - ItemStack... inputs) { - return gt_recipes.stream() - .filter(ar -> Arrays.stream(inputs).anyMatch(st -> GT_Utility.areStacksEqual(st, ar.mOutputs[0]))) - .collect(Collectors.toMap(k -> k.mOutputs[0], k -> k.mInputs)); - } - - public static Map getAsslineInputsFromOutputs(ItemStack... inputs) { - return GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.stream() - .filter(ar -> Arrays.stream(inputs).anyMatch(st -> GT_Utility.areStacksEqual(st, ar.mOutput))) - .collect(Collectors.toMap(k -> k.mOutput, k -> k.mInputs)); - } - public static int abstractHashGTRecipe(GT_Recipe recipe) { int hash = 31; hash += recipe.mDuration / 20 * 31; @@ -390,108 +350,6 @@ public static byte getTierFromGlasMeta(int meta) { }; } - /** - * Taken from the GTNH fork, made originally by Tec Calcualtes overclocked ness using long integers - * - * @param aEUt - recipe EUt - * @param aDuration - recipe Duration - * @param mAmperage - should be 1 ? - */ - public static void calculateOverclockedNessMulti(@Nonnegative int aEUt, @Nonnegative int aDuration, - @Nonnegative int mAmperage, @Nonnegative long maxInputVoltage, - @Nonnull GT_MetaTileEntity_MultiBlockBase base) { - calculateOverclockednessMultiInternal(aEUt, aDuration, mAmperage, maxInputVoltage, base, false); - } - - public static void calculatePerfectOverclockedNessMulti(@Nonnegative int aEUt, @Nonnegative int aDuration, - @Nonnegative int mAmperage, @Nonnegative long maxInputVoltage, - @Nonnull GT_MetaTileEntity_MultiBlockBase base) { - calculateOverclockednessMultiInternal(aEUt, aDuration, mAmperage, maxInputVoltage, base, true); - } - - private static void calculateOverclockednessMultiInternal(@Nonnegative int aEUt, @Nonnegative int aDuration, - @Nonnegative int mAmperage, @Nonnegative long maxInputVoltage, - @Nonnull GT_MetaTileEntity_MultiBlockBase base, @Nonnull boolean perfectOC) { - byte mTier = (byte) Math.max(0, GT_Utility.getTier(maxInputVoltage)); - if (mTier == 0) { - // Long time calculation - long xMaxProgresstime = (long) aDuration << 1; - if (xMaxProgresstime > Integer.MAX_VALUE - 1) { - // make impossible if too long - base.mEUt = Integer.MAX_VALUE - 1; - base.mMaxProgresstime = Integer.MAX_VALUE - 1; - } else { - base.mEUt = aEUt >> 2; - base.mMaxProgresstime = (int) xMaxProgresstime; - } - } else { - // Long EUt calculation - long xEUt = aEUt; - // Isnt too low EUt check? - long tempEUt = Math.max(xEUt, V[1]); - - base.mMaxProgresstime = aDuration; - - while (tempEUt <= V[mTier - 1] * mAmperage) { - tempEUt <<= 2; // this actually controls overclocking - // xEUt *= 4;//this is effect of everclocking - base.mMaxProgresstime >>= perfectOC ? 2 : 1; // this is effect of overclocking - xEUt = base.mMaxProgresstime <= 0 ? xEUt >> 1 : xEUt << 2; // U know, if the time is less than 1 tick - // make the machine use less power - } - - while (xEUt > maxInputVoltage && xEUt >= aEUt) { - // downclock one notch until we are good again, we have overshot. - xEUt >>= 2; - base.mMaxProgresstime <<= perfectOC ? 2 : 1; - } - - if (xEUt < aEUt) { - xEUt <<= 2; - base.mMaxProgresstime >>= perfectOC ? 2 : 1; - } - - if (xEUt > Integer.MAX_VALUE - 1) { - base.mEUt = Integer.MAX_VALUE - 1; - base.mMaxProgresstime = Integer.MAX_VALUE - 1; - } else { - base.mEUt = (int) xEUt; - if (base.mEUt == 0) base.mEUt = 1; - if (base.mMaxProgresstime <= 0) base.mMaxProgresstime = 1; // set time to 1 tick - } - } - } - - public static long getnominalVoltage(GT_MetaTileEntity_MultiBlockBase base) { - long rVoltage = 0L; - long rAmperage = 0L; - - for (GT_MetaTileEntity_Hatch_Energy tHatch : base.mEnergyHatches) { - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - rVoltage = Math.max(tHatch.getBaseMetaTileEntity().getInputVoltage(), rVoltage); - rAmperage += tHatch.getBaseMetaTileEntity().getInputAmperage(); - } - } - - return rVoltage * rAmperage; - } - - public static FluidStack[] getFluidsFromInputHatches(GT_MetaTileEntity_MultiBlockBase aBaseMetaTileEntity) { - ArrayList tmp = new ArrayList<>(); - for (GT_MetaTileEntity_Hatch_Input fip : aBaseMetaTileEntity.mInputHatches) { - tmp.add(fip.getFluid()); - } - return tmp.toArray(new FluidStack[0]); - } - - public static ItemStack[] getItemsFromInputBusses(GT_MetaTileEntity_MultiBlockBase aBaseMetaTileEntity) { - ArrayList tmp = new ArrayList<>(); - for (GT_MetaTileEntity_Hatch_InputBus fip : aBaseMetaTileEntity.mInputBusses) { - tmp.addAll(Arrays.asList(fip.mInventory)); - } - return tmp.toArray(new ItemStack[0]); - } - public static EnumRarity getRarityFromByte(byte b) { return switch (b) { case 1 -> EnumRarity.uncommon; @@ -501,27 +359,6 @@ public static EnumRarity getRarityFromByte(byte b) { }; } - public static List getMetasFromLayer(IGregTechTileEntity aBaseMetaTileEntity, int radius, int yLevel, - int height, int offset, boolean controllerLayer, boolean freeCorners, boolean insideCheck) { - ArrayList ret = new ArrayList<>(); - int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * offset; - int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * offset; - for (int x = -radius; x <= radius; x++) { - for (int y = yLevel; y < height; y++) { - for (int z = -radius; z <= radius; z++) { - if (freeCorners && Math.abs(x) == radius && Math.abs(z) == radius) continue; - if (controllerLayer && xDir + x == 0 && zDir + z == 0) continue; - final boolean inside = Math.abs(x) < radius && Math.abs(z) != radius; - if (insideCheck && inside) ret.add(aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)); - if (!inside) { - ret.add(aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)); - } - } - } - } - return ret; - } - public static byte getCircuitTierFromOreDictName(String name) { return switch (name) { case "circuitPrimitive" -> 0; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/MegaUtils.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/MegaUtils.java deleted file mode 100644 index d5c8be8a2..000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/MegaUtils.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following - * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial - * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -package com.github.bartimaeusnek.bartworks.util; - -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; - -public class MegaUtils { - - public static boolean drainEnergyMegaVanilla(GT_MetaTileEntity_MultiBlockBase multiBlockBase, long aEU) { - if (aEU <= 0) return true; - - long allTheEu = 0; - int hatches = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : multiBlockBase.mEnergyHatches) - if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { - allTheEu += tHatch.getEUVar(); - hatches++; - } - - if (allTheEu < aEU) return false; - - long euperhatch = aEU / hatches; - - boolean hasDrained = false; - - for (GT_MetaTileEntity_Hatch_Energy tHatch : multiBlockBase.mEnergyHatches) - hasDrained |= tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euperhatch, false); - - return hasDrained && multiBlockBase.mEnergyHatches.size() > 0; - } -} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TT_TileEntity_ManualTrafo.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TT_TileEntity_ManualTrafo.java deleted file mode 100644 index 35315b677..000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/TT_TileEntity_ManualTrafo.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following - * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial - * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -package com.github.bartimaeusnek.crossmod.tectech; - -import java.util.ArrayList; -import java.util.Iterator; - -import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ManualTrafo; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; - -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; - -public class TT_TileEntity_ManualTrafo extends GT_TileEntity_ManualTrafo { - - ArrayList mTTEnergyHatches = new ArrayList<>(); - ArrayList mTTDynamos = new ArrayList<>(); - - public TT_TileEntity_ManualTrafo(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public TT_TileEntity_ManualTrafo(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { - return new TT_TileEntity_ManualTrafo(this.mName); - } - - @Override - public boolean addEnergyOutput(long aEU) { - if (aEU <= 0L) { - return true; - } - return this.mTTDynamos.size() > 0 - || this.mDynamoHatches.size() > 0 && this.addEnergyOutputMultipleDynamos(aEU, true); - } - - @Override - public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { - int injected = 0; - long totalOutput = 0L; - long aFirstVoltageFound = -1L; - boolean aFoundMixedDynamos = false; - long aVoltage; - for (GT_MetaTileEntity_Hatch_Dynamo aDynamo : this.mDynamoHatches) { - if (aDynamo == null) { - return false; - } - - if (isValidMetaTileEntity(aDynamo)) { - aVoltage = aDynamo.maxEUOutput(); - long aTotal = aDynamo.maxAmperesOut() * aVoltage; - if (aFirstVoltageFound == -1L) { - aFirstVoltageFound = aVoltage; - } else if (aFirstVoltageFound != aVoltage) { - aFoundMixedDynamos = true; - } - - totalOutput += aTotal; - } - } - - if (totalOutput < aEU || aFoundMixedDynamos && !aAllowMixedVoltageDynamos) { - this.explodeMultiblock(); - return false; - } - Iterator var17 = this.mDynamoHatches.iterator(); - - while (true) { - GT_MetaTileEntity_Hatch_Dynamo aDynamo; - do { - if (!var17.hasNext()) { - return injected > 0; - } - - aDynamo = var17.next(); - } while (!isValidMetaTileEntity(aDynamo)); - - long leftToInject = aEU - injected; - aVoltage = aDynamo.maxEUOutput(); - int aAmpsToInject = (int) (leftToInject / aVoltage); - int aRemainder = (int) (leftToInject - aAmpsToInject * aVoltage); - int ampsOnCurrentHatch = (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject); - - for (int i = 0; i < ampsOnCurrentHatch; ++i) { - aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aVoltage, false); - } - - injected = (int) (injected + aVoltage * ampsOnCurrentHatch); - if (aRemainder > 0 && ampsOnCurrentHatch < aDynamo.maxAmperesOut()) { - aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aRemainder, false); - injected += aRemainder; - } - } - } - - @Override - public boolean drainEnergyInput(long aEU) { - if (aEU > 0L) { - { - Iterator var3 = this.mTTEnergyHatches.iterator(); - - GT_MetaTileEntity_Hatch_EnergyMulti tHatch; - do { - if (!var3.hasNext()) { - return false; - } - - tHatch = var3.next(); - } while (!isValidMetaTileEntity(tHatch) - || !tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)); - } - { - Iterator var3 = this.mEnergyHatches.iterator(); - - GT_MetaTileEntity_Hatch_Energy tHatch; - do { - if (!var3.hasNext()) { - return false; - } - - tHatch = var3.next(); - } while (!isValidMetaTileEntity(tHatch) - || !tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)); - } - } - return true; - } -}