aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2023-10-08 18:18:58 +0900
committerGitHub <noreply@github.com>2023-10-08 18:18:58 +0900
commitab65ab2afbf180c6c52c61145acc9e1803426d76 (patch)
tree1497ad40e4c150132f579a47691ea90b8606be57 /src
parent48248e0dbf0e5b80b9ffdfe34d5c25f9079a991a (diff)
downloadGT5-Unofficial-ab65ab2afbf180c6c52c61145acc9e1803426d76.tar.gz
GT5-Unofficial-ab65ab2afbf180c6c52c61145acc9e1803426d76.tar.bz2
GT5-Unofficial-ab65ab2afbf180c6c52c61145acc9e1803426d76.zip
Cleanup isValidMetaTileEntity and some more (#364)
* updateBuildScript & updateDependencies * Update .gitignore * Cleanup isValidMetaTileEntity * Remove unused and obsolete members Former-commit-id: 916b7ea9e708857b2efb50c3387fb7643dfa1796
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java13
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java20
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java17
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java4
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaMultiBlockBase.java23
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java51
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java163
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/MegaUtils.java43
-rw-r--r--src/main/java/com/github/bartimaeusnek/crossmod/tectech/TT_TileEntity_ManualTrafo.java146
9 files changed, 58 insertions, 422 deletions
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 e3543a5332..6b9964e4d8 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
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 @@ public class GT_TileEntity_CircuitAssemblyLine extends
@Override
public ArrayList<ItemStack> getStoredInputs() {
ArrayList<ItemStack> 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 8e6bcc85d9..45b9b83fdd 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.onElement
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 class GT_TileEntity_HTGR extends GT_MetaTileEntity_EnhancedMultiBlockBase
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 class GT_TileEntity_HTGR extends GT_MetaTileEntity_EnhancedMultiBlockBase
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 89f27cf41e..447f21281a 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.ofChain;
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 class GT_TileEntity_THTR extends GT_MetaTileEntity_EnhancedMultiBlockBase
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 bf80c80a11..5b4f3a1ece 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.OVERLAY_FRONT_ELECTRIC_BLAS
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 class GT_TileEntity_MegaBlastFurnace extends GT_TileEntity_MegaMultiBlock
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 e666047839..700dbb8e36 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_ExtendedPow
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<T extends GT_TileEntity_MegaMultiBlockBase<T>>
@@ -50,10 +51,8 @@ public abstract class GT_TileEntity_MegaMultiBlockBase<T extends GT_TileEntity_M
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 @@ public abstract class GT_TileEntity_MegaMultiBlockBase<T extends GT_TileEntity_M
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 e31b3563ff..815b2a2496 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.OVERLAY_FRONT_OIL_CRACKER_G
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 @@ public class GT_TileEntity_MegaOilCracker extends GT_TileEntity_MegaMultiBlockBa
@Override
public ArrayList<FluidStack> getStoredFluids() {
final ArrayList<FluidStack> 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 69438bff91..bd9ee551ce 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 @@ package com.github.bartimaeusnek.bartworks.util;
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.Array;
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.Materials;
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 class BW_Util {
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 class BW_Util {
&& GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial != null;
}
- public static Map<ItemStack, ItemStack[]> getInputsFromOutput(Collection<GT_Recipe> 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<ItemStack, ItemStack[]> 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 class BW_Util {
};
}
- /**
- * 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<FluidStack> 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<ItemStack> 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 class BW_Util {
};
}
- public static List<Byte> getMetasFromLayer(IGregTechTileEntity aBaseMetaTileEntity, int radius, int yLevel,
- int height, int offset, boolean controllerLayer, boolean freeCorners, boolean insideCheck) {
- ArrayList<Byte> 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 d5c8be8a28..0000000000
--- 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 35315b677c..0000000000
--- 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<GT_MetaTileEntity_Hatch_EnergyMulti> mTTEnergyHatches = new ArrayList<>();
- ArrayList<GT_MetaTileEntity_Hatch_DynamoMulti> 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<GT_MetaTileEntity_Hatch_Dynamo> 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<GT_MetaTileEntity_Hatch_EnergyMulti> 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<GT_MetaTileEntity_Hatch_Energy> 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;
- }
-}