aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/goodgenerator/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/goodgenerator/util')
-rw-r--r--src/main/java/goodgenerator/util/ItemRefer.java16
-rw-r--r--src/main/java/goodgenerator/util/Log.java8
-rw-r--r--src/main/java/goodgenerator/util/MyRecipeAdder.java111
-rw-r--r--src/main/java/goodgenerator/util/StackUtils.java81
4 files changed, 216 insertions, 0 deletions
diff --git a/src/main/java/goodgenerator/util/ItemRefer.java b/src/main/java/goodgenerator/util/ItemRefer.java
index 3cd1adf25a..86ac3db64d 100644
--- a/src/main/java/goodgenerator/util/ItemRefer.java
+++ b/src/main/java/goodgenerator/util/ItemRefer.java
@@ -151,6 +151,22 @@ public final class ItemRefer {
public static ItemRefer Compact_Fusion_MK5 = getItemStack(LFC[4]);
public static ItemRefer Large_Essentia_Smeltery = getItemStack(LES);
public static ItemRefer Coolant_Tower = getItemStack(CT);
+ public static ItemRefer Component_Assembly_Line = getItemStack(CompAssline);
+
+ public static ItemRefer Compassline_Casing_LV = getItemStack(componentAssemblylineCasing, 0);
+ public static ItemRefer Compassline_Casing_MV = getItemStack(componentAssemblylineCasing, 1);
+ public static ItemRefer Compassline_Casing_HV = getItemStack(componentAssemblylineCasing, 2);
+ public static ItemRefer Compassline_Casing_EV = getItemStack(componentAssemblylineCasing, 3);
+ public static ItemRefer Compassline_Casing_IV = getItemStack(componentAssemblylineCasing, 4);
+ public static ItemRefer Compassline_Casing_LuV = getItemStack(componentAssemblylineCasing, 5);
+ public static ItemRefer Compassline_Casing_ZPM = getItemStack(componentAssemblylineCasing, 6);
+ public static ItemRefer Compassline_Casing_UV = getItemStack(componentAssemblylineCasing, 7);
+ public static ItemRefer Compassline_Casing_UHV = getItemStack(componentAssemblylineCasing, 8);
+ public static ItemRefer Compassline_Casing_UEV = getItemStack(componentAssemblylineCasing, 9);
+ public static ItemRefer Compassline_Casing_UIV = getItemStack(componentAssemblylineCasing, 10);
+ public static ItemRefer Compassline_Casing_UMV = getItemStack(componentAssemblylineCasing, 11);
+ public static ItemRefer Compassline_Casing_UXV = getItemStack(componentAssemblylineCasing, 12);
+ public static ItemRefer Compassline_Casing_MAX = getItemStack(componentAssemblylineCasing, 13);
private Item mItem = null;
private Block mBlock = null;
diff --git a/src/main/java/goodgenerator/util/Log.java b/src/main/java/goodgenerator/util/Log.java
new file mode 100644
index 0000000000..8b88ddf5f1
--- /dev/null
+++ b/src/main/java/goodgenerator/util/Log.java
@@ -0,0 +1,8 @@
+package goodgenerator.util;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class Log {
+ public static final Logger LOGGER = LogManager.getLogger("GoodGenerator");
+}
diff --git a/src/main/java/goodgenerator/util/MyRecipeAdder.java b/src/main/java/goodgenerator/util/MyRecipeAdder.java
index 3e2c5371a3..58e0540340 100644
--- a/src/main/java/goodgenerator/util/MyRecipeAdder.java
+++ b/src/main/java/goodgenerator/util/MyRecipeAdder.java
@@ -1,8 +1,11 @@
package goodgenerator.util;
+import static gregtech.api.enums.GT_Values.NI;
+
import codechicken.nei.PositionedStack;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
+import gregtech.nei.GT_NEI_DefaultHandler;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -467,6 +470,7 @@ public class MyRecipeAdder {
}
}
+ @SuppressWarnings("deprecation")
public static class PreciseAssemblerRecipe extends GT_Recipe {
public PreciseAssemblerRecipe(
ItemStack[] input1, FluidStack[] input2, ItemStack output, int EUt, int ticks, int tier) {
@@ -511,4 +515,111 @@ public class MyRecipeAdder {
PA.addRecipe(
false, aItemInputs, new ItemStack[] {aOutput}, null, null, aFluidInputs, null, aDuration, aEUt, aTier);
}
+
+ public static class ComponentAssemblyLineMapper extends GT_Recipe.GT_Recipe_Map {
+
+ public ComponentAssemblyLineMapper(
+ Collection<GT_Recipe> aRecipeList,
+ String aUnlocalizedName,
+ String aLocalName,
+ String aNEIName,
+ String aNEIGUIPath,
+ int aUsualInputCount,
+ int aUsualOutputCount,
+ int aMinimalInputItems,
+ int aMinimalInputFluids,
+ int aAmperage,
+ String aNEISpecialValuePre,
+ int aNEISpecialValueMultiplier,
+ String aNEISpecialValuePost,
+ boolean aShowVoltageAmperageInNEI,
+ boolean aNEIAllowed) {
+
+ super(
+ aRecipeList,
+ aUnlocalizedName,
+ aLocalName,
+ aNEIName,
+ aNEIGUIPath,
+ aUsualInputCount,
+ aUsualOutputCount,
+ aMinimalInputItems,
+ aMinimalInputFluids,
+ aAmperage,
+ aNEISpecialValuePre,
+ aNEISpecialValueMultiplier,
+ aNEISpecialValuePost,
+ aShowVoltageAmperageInNEI,
+ aNEIAllowed,
+ true);
+ }
+
+ @Override
+ public ArrayList<PositionedStack> getInputPositionedStacks(GT_Recipe recipe) {
+ ArrayList<PositionedStack> inputStacks = new ArrayList<>();
+
+ if (recipe.mInputs != null) {
+ for (int j = 0; j < recipe.mInputs.length; j++) {
+ if (recipe.mInputs[j] == NI) continue;
+ inputStacks.add(new GT_NEI_DefaultHandler.FixedPositionedStack(
+ recipe.mInputs[j].copy(), 12 + 18 * (j % 3), 5 + 18 * (j / 3)));
+ }
+ }
+ if (recipe.mFluidInputs != null) {
+ for (int j = 0; j < recipe.mFluidInputs.length; j++) {
+
+ inputStacks.add(new GT_NEI_DefaultHandler.FixedPositionedStack(
+ GT_Utility.getFluidDisplayStack(recipe.mFluidInputs[j], true),
+ 84 + 18 * (j % 4),
+ 27 + 18 * (j / 4)));
+ }
+ }
+ return inputStacks;
+ }
+
+ @Override
+ public ArrayList<PositionedStack> getOutputPositionedStacks(GT_Recipe recipe) {
+ ArrayList<PositionedStack> outputStacks = new ArrayList<>();
+ if (recipe.mOutputs != null) {
+ outputStacks.add(new GT_NEI_DefaultHandler.FixedPositionedStack(recipe.mOutputs[0].copy(), 138, 5));
+ }
+ return outputStacks;
+ }
+ }
+
+ public final ComponentAssemblyLineMapper COMPASSLINE_RECIPES = new ComponentAssemblyLineMapper(
+ new HashSet<>(110),
+ "gg.recipe.componentassemblyline",
+ "Component Assembly Line",
+ null,
+ "goodgenerator:textures/gui/ComponentAssline",
+ 9,
+ 1,
+ 0,
+ 0,
+ 1,
+ "Casing Tier: ",
+ 1,
+ "",
+ false,
+ false);
+
+ public GT_Recipe addComponentAssemblyLineRecipe(
+ ItemStack[] ItemInputArray,
+ FluidStack[] FluidInputArray,
+ ItemStack OutputItem,
+ int aDuration,
+ int aEUt,
+ int casingLevel) {
+ return COMPASSLINE_RECIPES.addRecipe(
+ false,
+ ItemInputArray,
+ new ItemStack[] {OutputItem},
+ null,
+ FluidInputArray,
+ null,
+ aDuration,
+ aEUt,
+ casingLevel);
+ }
}
diff --git a/src/main/java/goodgenerator/util/StackUtils.java b/src/main/java/goodgenerator/util/StackUtils.java
new file mode 100644
index 0000000000..1d7dcc3ac8
--- /dev/null
+++ b/src/main/java/goodgenerator/util/StackUtils.java
@@ -0,0 +1,81 @@
+package goodgenerator.util;
+
+import gregtech.api.util.GT_Utility;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import net.minecraft.item.ItemStack;
+
+public class StackUtils {
+
+ /**
+ * Multiplies one ItemStack by a multiplier, and splits it into as many full stacks as it needs to.
+ * @param stack The ItemStack you want to multiply
+ * @param multiplier The number the stack is multiplied by
+ * @return A List of stacks that, in total, are the same as the input ItemStack after it has been multiplied.
+ */
+ public static List<ItemStack> multiplyAndSplitIntoStacks(ItemStack stack, int multiplier) {
+ int totalItems = stack.stackSize * multiplier;
+ ArrayList<ItemStack> stacks = new ArrayList<>();
+ if (totalItems >= 64) {
+ for (int i = 0; i < totalItems / 64; i++) {
+ stacks.add(GT_Utility.copyAmount(64, stack));
+ }
+ }
+ if (totalItems % 64 > 0) {
+ stacks.add(GT_Utility.copyAmount(totalItems % 64, stack));
+ }
+ return stacks;
+ }
+
+ /**
+ * Merges the ItemStacks in the array into full stacks.
+ * */
+ public static ArrayList<ItemStack> mergeStacks(List<ItemStack> stacks) {
+ ArrayList<ItemStack> output = new ArrayList<>();
+ for (int index = 0; index < stacks.size(); index++) {
+ ItemStack i = stacks.get(index);
+ boolean hasDupe = false;
+ int newSize = i.stackSize;
+ for (int j = index + 1; j < stacks.size(); j++) {
+ ItemStack is2 = stacks.get(j);
+ if (GT_Utility.areStacksEqual(i, is2)) {
+ hasDupe = true;
+ newSize += is2.stackSize;
+ stacks.remove(j);
+ j--;
+ }
+ }
+ if (hasDupe) {
+ if (newSize >= 64) {
+ for (int k = 0; k < newSize / 64; k++) {
+ output.add(GT_Utility.copyAmount(64, i));
+ }
+ }
+ if (newSize % 64 > 0) {
+ output.add(GT_Utility.copyAmount(newSize > 64 ? newSize % 64 : newSize, i));
+ }
+ } else output.add(i);
+ }
+ return output;
+ }
+
+ public static HashMap<ItemStack, Integer> getTotalItems(List<ItemStack> items) {
+ HashMap<ItemStack, Integer> totals = new HashMap<>();
+ itemLoop:
+ for (ItemStack item : items) {
+ int t = items.stream()
+ .filter(i2 -> GT_Utility.areStacksEqual(item, i2))
+ .mapToInt(i -> i.stackSize)
+ .sum();
+ for (ItemStack i2 : totals.keySet()) if (GT_Utility.areStacksEqual(item, i2)) continue itemLoop;
+ totals.put(GT_Utility.copyAmount(1, item), t);
+ }
+ return totals;
+ }
+
+ public static HashMap<ItemStack, Integer> getTotalItems(ItemStack[] items) {
+ return getTotalItems(Arrays.asList(items));
+ }
+}