aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil/xmod/gregtech/api/util
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-08-27 01:34:08 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-08-27 01:34:08 +1000
commit072f6322fb789703f163030edf4b60bf5a0201af (patch)
tree9d2d9c2ba6fe3bc5139a9868ee4eca95629fdd95 /src/Java/miscutil/xmod/gregtech/api/util
parentf555ac2e146e572155e176131c23e73cd74684f1 (diff)
downloadGT5-Unofficial-072f6322fb789703f163030edf4b60bf5a0201af.tar.gz
GT5-Unofficial-072f6322fb789703f163030edf4b60bf5a0201af.tar.bz2
GT5-Unofficial-072f6322fb789703f163030edf4b60bf5a0201af.zip
+ Attempted to add custom IC2 generators.
% Refactored the xmod package to be a parent, beside core. No longer is it a child, it needs room to grow.
Diffstat (limited to 'src/Java/miscutil/xmod/gregtech/api/util')
-rw-r--r--src/Java/miscutil/xmod/gregtech/api/util/GregtechOreDictUnificator.java366
-rw-r--r--src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipe.java751
-rw-r--r--src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipeRegistrator.java339
3 files changed, 1456 insertions, 0 deletions
diff --git a/src/Java/miscutil/xmod/gregtech/api/util/GregtechOreDictUnificator.java b/src/Java/miscutil/xmod/gregtech/api/util/GregtechOreDictUnificator.java
new file mode 100644
index 0000000000..1ffc88b4ba
--- /dev/null
+++ b/src/Java/miscutil/xmod/gregtech/api/util/GregtechOreDictUnificator.java
@@ -0,0 +1,366 @@
+package miscutil.xmod.gregtech.api.util;
+
+import static gregtech.api.enums.GT_Values.E;
+import static gregtech.api.enums.GT_Values.M;
+import static gregtech.api.enums.GT_Values.W;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Dyes;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.enums.SubTag;
+import gregtech.api.objects.GT_HashSet;
+import gregtech.api.objects.GT_ItemStack;
+import gregtech.api.util.GT_Log;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.GT_Proxy.OreDictEventContainer;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map.Entry;
+
+import miscutil.xmod.gregtech.api.enums.GregtechOrePrefixes;
+import miscutil.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials;
+import miscutil.xmod.gregtech.api.objects.GregtechItemData;
+import miscutil.xmod.gregtech.api.objects.GregtechMaterialStack;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.OreDictionary;
+
+/**
+ * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
+ * <p/>
+ * This is the Core of my OreDict Unification Code
+ * <p/>
+ * If you just want to use this to unificate your Items, then use the Function in the GregTech_API File
+ * <p/>
+ * P.S. It is intended to be named "Unificator" and not "Unifier", because that sounds more awesome.
+ */
+public class GregtechOreDictUnificator {
+ private static final HashMap<String, ItemStack> sName2StackMap = new HashMap<String, ItemStack>();
+ private static final HashMap<GT_ItemStack, GregtechItemData> sItemStack2DataMap = new HashMap<GT_ItemStack, GregtechItemData>();
+ private static final GT_HashSet<GT_ItemStack> sNoUnificationList = new GT_HashSet<GT_ItemStack>();
+ public static volatile int VERSION = 508;
+ private static int isRegisteringOre = 0, isAddingOre = 0;
+ private static boolean mRunThroughTheList = true;
+
+ static {
+ GregTech_API.sItemStackMappings.add(sItemStack2DataMap);
+ }
+
+ /**
+ * The Blacklist just prevents the Item from being unificated into something else.
+ * Useful if you have things like the Industrial Diamond, which is better than regular Diamond, but also usable in absolutely all Diamond Recipes.
+ */
+ public static void addToBlacklist(ItemStack aStack) {
+ if (GT_Utility.isStackValid(aStack) && !GT_Utility.isStackInList(aStack, sNoUnificationList))
+ sNoUnificationList.add(aStack);
+ }
+
+ public static boolean isBlacklisted(ItemStack aStack) {
+ return GT_Utility.isStackInList(aStack, sNoUnificationList);
+ }
+
+ public static void add(GregtechOrePrefixes aPrefix, GT_Materials aMaterial, ItemStack aStack) {
+ set(aPrefix, aMaterial, aStack, false, false);
+ }
+
+ public static void set(GregtechOrePrefixes aPrefix, GT_Materials aMaterial, ItemStack aStack) {
+ set(aPrefix, aMaterial, aStack, true, false);
+ }
+
+ public static void set(GregtechOrePrefixes aPrefix, GT_Materials aMaterial, ItemStack aStack, boolean aOverwrite, boolean aAlreadyRegistered) {
+ if (aMaterial == null || aPrefix == null || GT_Utility.isStackInvalid(aStack) || Items.feather.getDamage(aStack) == W)
+ return;
+ isAddingOre++;
+ aStack = GT_Utility.copyAmount(1, aStack);
+ if (!aAlreadyRegistered) registerOre(aPrefix.get(aMaterial), aStack);
+ addAssociation(aPrefix, aMaterial, aStack, isBlacklisted(aStack));
+ if (aOverwrite || GT_Utility.isStackInvalid(sName2StackMap.get(aPrefix.get(aMaterial).toString())))
+ sName2StackMap.put(aPrefix.get(aMaterial).toString(), aStack);
+ isAddingOre--;
+ }
+
+ public static ItemStack getFirstOre(Object aName, long aAmount) {
+ if (GT_Utility.isStringInvalid(aName)) return null;
+ ItemStack tStack = sName2StackMap.get(aName.toString());
+ if (GT_Utility.isStackValid(tStack)) return GT_Utility.copyAmount(aAmount, tStack);
+ return GT_Utility.copyAmount(aAmount, getOres(aName).toArray());
+ }
+
+ public static ItemStack get(Object aName, long aAmount) {
+ return get(aName, null, aAmount, true, true);
+ }
+
+ public static ItemStack get(Object aName, ItemStack aReplacement, long aAmount) {
+ return get(aName, aReplacement, aAmount, true, true);
+ }
+
+ public static ItemStack get(GregtechOrePrefixes aPrefix, Object aMaterial, long aAmount) {
+ return get(aPrefix, aMaterial, null, aAmount);
+ }
+
+ public static ItemStack get(GregtechOrePrefixes aPrefix, Object aMaterial, ItemStack aReplacement, long aAmount) {
+ return get(aPrefix.get(aMaterial), aReplacement, aAmount, false, true);
+ }
+
+ public static ItemStack get(Object aName, ItemStack aReplacement, long aAmount, boolean aMentionPossibleTypos, boolean aNoInvalidAmounts) {
+ if (aNoInvalidAmounts && aAmount < 1) return null;
+ if (!sName2StackMap.containsKey(aName.toString()) && aMentionPossibleTypos)
+ GT_Log.err.println("Unknown Key for Unification, Typo? " + aName);
+ return GT_Utility.copyAmount(aAmount, sName2StackMap.get(aName.toString()), getFirstOre(aName, aAmount), aReplacement);
+ }
+
+ public static ItemStack[] setStackArray(boolean aUseBlackList, ItemStack... aStacks) {
+ for (int i = 0; i < aStacks.length; i++) aStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i]));
+ return aStacks;
+ }
+
+ public static ItemStack[] getStackArray(boolean aUseBlackList, Object... aStacks) {
+ ItemStack[] rStacks = new ItemStack[aStacks.length];
+ for (int i = 0; i < aStacks.length; i++) rStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i]));
+ return rStacks;
+ }
+
+ public static ItemStack setStack(ItemStack aStack) {
+ return setStack(true, aStack);
+ }
+
+ public static ItemStack setStack(boolean aUseBlackList, ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return aStack;
+ ItemStack tStack = get(aUseBlackList, aStack);
+ if (GT_Utility.areStacksEqual(aStack, tStack)) return aStack;
+ aStack.func_150996_a(tStack.getItem());
+ Items.feather.setDamage(aStack, Items.feather.getDamage(tStack));
+ return aStack;
+ }
+
+ public static ItemStack get(ItemStack aStack) {
+ return get(true, aStack);
+ }
+
+ public static ItemStack get(boolean aUseBlackList, ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return null;
+ GregtechItemData tPrefixMaterial = getAssociation(aStack);
+ ItemStack rStack = null;
+ if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData() || (aUseBlackList && tPrefixMaterial.mBlackListed))
+ return GT_Utility.copy(aStack);
+ if (aUseBlackList && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) {
+ tPrefixMaterial.mBlackListed = true;
+ return GT_Utility.copy(aStack);
+ }
+ if (tPrefixMaterial.mUnificationTarget == null)
+ tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString());
+ rStack = tPrefixMaterial.mUnificationTarget;
+ if (GT_Utility.isStackInvalid(rStack)) return GT_Utility.copy(aStack);
+ assert rStack != null;
+ rStack.setTagCompound(aStack.getTagCompound());
+ return GT_Utility.copyAmount(aStack.stackSize, rStack);
+ }
+
+ public static void addItemData(ItemStack aStack, GregtechItemData aData) {
+ if (GT_Utility.isStackValid(aStack) && getItemData(aStack) == null && aData != null) setItemData(aStack, aData);
+ }
+
+ public static void setItemData(ItemStack aStack, GregtechItemData aData) {
+ if (GT_Utility.isStackInvalid(aStack) || aData == null) return;
+ GregtechItemData tData = getItemData(aStack);
+ if (tData == null || !tData.hasValidPrefixMaterialData()) {
+ if (tData != null) for (Object tObject : tData.mExtraData)
+ if (!aData.mExtraData.contains(tObject)) aData.mExtraData.add(tObject);
+ if (aStack.stackSize > 1) {
+ if (aData.mMaterial != null) aData.mMaterial.mAmount /= aStack.stackSize;
+ for (GregtechMaterialStack tMaterial : aData.mByProducts) tMaterial.mAmount /= aStack.stackSize;
+ aStack = GT_Utility.copyAmount(1, aStack);
+ }
+ sItemStack2DataMap.put(new GT_ItemStack(aStack), aData);
+ if (aData.hasValidMaterialData()) {
+ long tValidMaterialAmount = aData.mMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 : aData.mMaterial.mAmount >= 0 ? aData.mMaterial.mAmount : M;
+ for (GregtechMaterialStack tMaterial : aData.mByProducts)
+ tValidMaterialAmount += tMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 : tMaterial.mAmount >= 0 ? tMaterial.mAmount : M;
+ if (tValidMaterialAmount < M) GT_ModHandler.addToRecyclerBlackList(aStack);
+ }
+ if (mRunThroughTheList) {
+ if (GregTech_API.sLoadStarted) {
+ mRunThroughTheList = false;
+ for (Entry<GT_ItemStack, GregtechItemData> tEntry : sItemStack2DataMap.entrySet())
+ if (!tEntry.getValue().hasValidPrefixData() || tEntry.getValue().mPrefix.mAllowNormalRecycling)
+ GregtechRecipeRegistrator.registerMaterialRecycling(tEntry.getKey().toStack(), tEntry.getValue());
+ }
+ } else {
+ if (!aData.hasValidPrefixData() || aData.mPrefix.mAllowNormalRecycling)
+ GregtechRecipeRegistrator.registerMaterialRecycling(aStack, aData);
+ }
+ } else {
+ for (Object tObject : aData.mExtraData)
+ if (!tData.mExtraData.contains(tObject)) tData.mExtraData.add(tObject);
+ }
+ }
+
+ public static void addAssociation(GregtechOrePrefixes aPrefix, GT_Materials aMaterial, ItemStack aStack, boolean aBlackListed) {
+ if (aPrefix == null || aMaterial == null || GT_Utility.isStackInvalid(aStack)) return;
+ if (Items.feather.getDamage(aStack) == W) for (byte i = 0; i < 16; i++)
+ setItemData(GT_Utility.copyAmountAndMetaData(1, i, aStack), new GregtechItemData(aPrefix, aMaterial, aBlackListed));
+ setItemData(aStack, new GregtechItemData(aPrefix, aMaterial, aBlackListed));
+ }
+
+ public static GregtechItemData getItemData(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return null;
+ GregtechItemData rData = sItemStack2DataMap.get(new GT_ItemStack(aStack));
+ if (rData == null) rData = sItemStack2DataMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, aStack)));
+ return rData;
+ }
+
+ public static GregtechItemData getAssociation(ItemStack aStack) {
+ GregtechItemData rData = getItemData(aStack);
+ return rData != null && rData.hasValidPrefixMaterialData() ? rData : null;
+ }
+
+ public static boolean isItemStackInstanceOf(ItemStack aStack, Object aName) {
+ if (GT_Utility.isStringInvalid(aName) || GT_Utility.isStackInvalid(aStack)) return false;
+ for (ItemStack tOreStack : getOres(aName.toString()))
+ if (GT_Utility.areStacksEqual(tOreStack, aStack, true)) return true;
+ return false;
+ }
+
+ public static boolean isItemStackDye(ItemStack aStack) {
+ if (GT_Utility.isStackInvalid(aStack)) return false;
+ for (Dyes tDye : Dyes.VALUES) if (isItemStackInstanceOf(aStack, tDye.toString())) return true;
+ return false;
+ }
+
+ public static boolean registerOre(GregtechOrePrefixes aPrefix, Object aMaterial, ItemStack aStack) {
+ return registerOre(aPrefix.get(aMaterial), aStack);
+ }
+
+ public static boolean registerOre(Object aName, ItemStack aStack) {
+ if (aName == null || GT_Utility.isStackInvalid(aStack)) return false;
+ String tName = aName.toString();
+ if (GT_Utility.isStringInvalid(tName)) return false;
+ ArrayList<ItemStack> tList = getOres(tName);
+ for (int i = 0; i < tList.size(); i++) if (GT_Utility.areStacksEqual(tList.get(i), aStack, true)) return false;
+ isRegisteringOre++;
+ OreDictionary.registerOre(tName, GT_Utility.copyAmount(1, aStack));
+ isRegisteringOre--;
+ return true;
+ }
+
+ public static boolean isRegisteringOres() {
+ return isRegisteringOre > 0;
+ }
+
+ public static boolean isAddingOres() {
+ return isAddingOre > 0;
+ }
+
+ public static void resetUnificationEntries() {
+ for (GregtechItemData tPrefixMaterial : sItemStack2DataMap.values()) tPrefixMaterial.mUnificationTarget = null;
+ }
+
+ public static ItemStack getGem(GregtechMaterialStack aMaterial) {
+ return aMaterial == null ? null : getGem(aMaterial.mMaterial, aMaterial.mAmount);
+ }
+
+ public static ItemStack getGem(GT_Materials aMaterial, OrePrefixes aPrefix) {
+ return aMaterial == null ? null : getGem(aMaterial, aPrefix.mMaterialAmount);
+ }
+
+ public static ItemStack getGem(GT_Materials aMaterial, long aMaterialAmount) {
+ ItemStack rStack = null;
+ if (((aMaterialAmount >= M) || aMaterialAmount >= M * 32))
+ rStack = get(GregtechOrePrefixes.gem, aMaterial, aMaterialAmount / M);
+ if (rStack == null && (((aMaterialAmount * 2) % M == 0) || aMaterialAmount >= M * 16))
+ rStack = get(GregtechOrePrefixes.gemFlawed, aMaterial, (aMaterialAmount * 2) / M);
+ if (rStack == null && (((aMaterialAmount * 4) >= M)))
+ rStack = get(GregtechOrePrefixes.gemChipped, aMaterial, (aMaterialAmount * 4) / M);
+ return rStack;
+ }
+
+ public static ItemStack getDust(GregtechMaterialStack aMaterial) {
+ return aMaterial == null ? null : getDust(aMaterial.mMaterial, aMaterial.mAmount);
+ }
+
+ public static ItemStack getDust(GT_Materials aMaterial, OrePrefixes aPrefix) {
+ return aMaterial == null ? null : getDust(aMaterial, aPrefix.mMaterialAmount);
+ }
+
+ public static ItemStack getDust(GT_Materials aMaterial, long aMaterialAmount) {
+ if (aMaterialAmount <= 0) return null;
+ ItemStack rStack = null;
+ if (((aMaterialAmount % M == 0) || aMaterialAmount >= M * 16))
+ rStack = get(GregtechOrePrefixes.dust, aMaterial, aMaterialAmount / M);
+ if (rStack == null && (((aMaterialAmount * 4) % M == 0) || aMaterialAmount >= M * 8))
+ rStack = get(GregtechOrePrefixes.dustSmall, aMaterial, (aMaterialAmount * 4) / M);
+ if (rStack == null && (((aMaterialAmount * 9) >= M)))
+ rStack = get(GregtechOrePrefixes.dustTiny, aMaterial, (aMaterialAmount * 9) / M);
+ return rStack;
+ }
+
+ public static ItemStack getIngot(GregtechMaterialStack aMaterial) {
+ return aMaterial == null ? null : getIngot(aMaterial.mMaterial, aMaterial.mAmount);
+ }
+
+ public static ItemStack getIngot(GT_Materials aMaterial, OrePrefixes aPrefix) {
+ return aMaterial == null ? null : getIngot(aMaterial, aPrefix.mMaterialAmount);
+ }
+
+ public static ItemStack getIngot(GT_Materials aMaterial, long aMaterialAmount) {
+ if (aMaterialAmount <= 0) return null;
+ ItemStack rStack = null;
+ if (((aMaterialAmount % (M * 9) == 0 && aMaterialAmount / (M * 9) > 1) || aMaterialAmount >= M * 72))
+ rStack = get(GregtechOrePrefixes.block, aMaterial, aMaterialAmount / (M * 9));
+ if (rStack == null && ((aMaterialAmount % M == 0) || aMaterialAmount >= M * 8))
+ rStack = get(GregtechOrePrefixes.ingot, aMaterial, aMaterialAmount / M);
+ if (rStack == null && (((aMaterialAmount * 9) >= M)))
+ rStack = get(GregtechOrePrefixes.nugget, aMaterial, (aMaterialAmount * 9) / M);
+ return rStack;
+ }
+
+ public static ItemStack getIngotOrDust(GT_Materials aMaterial, long aMaterialAmount) {
+ if (aMaterialAmount <= 0) return null;
+ ItemStack rStack = getIngot(aMaterial, aMaterialAmount);
+ if (rStack == null) rStack = getDust(aMaterial, aMaterialAmount);
+ return rStack;
+ }
+
+ public static ItemStack getIngotOrDust(GregtechMaterialStack aMaterial) {
+ ItemStack rStack = getIngot(aMaterial);
+ if(aMaterial!=null&&aMaterial.mMaterial!=null)rStack = getDust(aMaterial);
+ if (rStack == null) rStack = getDust(aMaterial);
+ return rStack;
+ }
+
+ public static ItemStack getDustOrIngot(GT_Materials aMaterial, long aMaterialAmount) {
+ if (aMaterialAmount <= 0) return null;
+ ItemStack rStack = getDust(aMaterial, aMaterialAmount);
+ if (rStack == null) rStack = getIngot(aMaterial, aMaterialAmount);
+ return rStack;
+ }
+
+ public static ItemStack getDustOrIngot(GregtechMaterialStack aMaterial) {
+ ItemStack rStack = getDust(aMaterial);
+ if (rStack == null) rStack = getIngot(aMaterial);
+ return rStack;
+ }
+
+ /**
+ * @return a Copy of the OreDictionary.getOres() List
+ */
+ public static ArrayList<ItemStack> getOres(OrePrefixes aPrefix, Object aMaterial) {
+ return getOres(aPrefix.get(aMaterial));
+ }
+
+ /**
+ * @return a Copy of the OreDictionary.getOres() List
+ */
+ public static ArrayList<ItemStack> getOres(Object aOreName) {
+ String aName = aOreName == null ? E : aOreName.toString();
+ ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
+ if (GT_Utility.isStringValid(aName)) rList.addAll(OreDictionary.getOres(aName));
+ return rList;
+ }
+
+ public static void registerRecipes(OreDictEventContainer tOre) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipe.java b/src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipe.java
new file mode 100644
index 0000000000..96359550a3
--- /dev/null
+++ b/src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipe.java
@@ -0,0 +1,751 @@
+package miscutil.xmod.gregtech.api.util;
+
+import static gregtech.api.enums.GT_Values.E;
+import static gregtech.api.enums.GT_Values.RES_PATH_GUI;
+import static gregtech.api.enums.GT_Values.W;
+import gregtech.api.GregTech_API;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords;
+import gregtech.api.objects.GT_FluidStack;
+import gregtech.api.objects.GT_ItemStack;
+import gregtech.api.util.GT_LanguageManager;
+import gregtech.api.util.GT_Log;
+import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import gregtech.api.util.GT_Utility;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import miscutil.core.util.Utils;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+
+/**
+ * NEVER INCLUDE THIS FILE IN YOUR MOD!!!
+ * <p/>
+ * This File contains the functions used for Recipes. Please do not include this File AT ALL in your Moddownload as it ruins compatibility
+ * This is just the Core of my Recipe System, if you just want to GET the Recipes I add, then you can access this File.
+ * Do NOT add Recipes using the Constructors inside this Class, The GregTech_API File calls the correct Functions for these Constructors.
+ * <p/>
+ * I know this File causes some Errors, because of missing Main Functions, but if you just need to compile Stuff, then remove said erroreous Functions.
+ */
+public class GregtechRecipe {
+
+ public static volatile int VERSION = 508;
+ /**
+ * If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs, please add a new Recipe, because of the HashMaps.
+ */
+ public ItemStack[] mInputs, mOutputs;
+ /**
+ * If you want to change the Output, feel free to modify or even replace the whole ItemStack Array, for Inputs, please add a new Recipe, because of the HashMaps.
+ */
+ public FluidStack[] mFluidInputs, mFluidOutputs;
+ /**
+ * If you changed the amount of Array-Items inside the Output Array then the length of this Array must be larger or equal to the Output Array. A chance of 10000 equals 100%
+ */
+ public int[] mChances;
+ /**
+ * An Item that needs to be inside the Special Slot, like for example the Copy Slot inside the Printer. This is only useful for Fake Recipes in NEI, since findRecipe() and containsInput() don't give a shit about this Field. Lists are also possible.
+ */
+ public Object mSpecialItems;
+ public int mDuration, mEUt, mSpecialValue;
+ /**
+ * Use this to just disable a specific Recipe, but the Configuration enables that already for every single Recipe.
+ */
+ public boolean mEnabled = true;
+ /**
+ * If this Recipe is hidden from NEI
+ */
+ public boolean mHidden = false;
+ /**
+ * If this Recipe is Fake and therefore doesn't get found by the findRecipe Function (It is still in the HashMaps, so that containsInput does return T on those fake Inputs)
+ */
+ public boolean mFakeRecipe = false;
+ /**
+ * If this Recipe can be stored inside a Machine in order to make Recipe searching more Efficient by trying the previously used Recipe first. In case you have a Recipe Map overriding things and returning one time use Recipes, you have to set this to F.
+ */
+ public boolean mCanBeBuffered = true;
+ /**
+ * If this Recipe needs the Output Slots to be completely empty. Needed in case you have randomised Outputs
+ */
+ public boolean mNeedsEmptyOutput = false;
+ private GregtechRecipe(GregtechRecipe aRecipe) {
+ mInputs = GT_Utility.copyStackArray((Object[]) aRecipe.mInputs);
+ mOutputs = GT_Utility.copyStackArray((Object[]) aRecipe.mOutputs);
+ mSpecialItems = aRecipe.mSpecialItems;
+ mChances = aRecipe.mChances;
+ mFluidInputs = GT_Utility.copyFluidArray(aRecipe.mFluidInputs);
+ mFluidOutputs = GT_Utility.copyFluidArray(aRecipe.mFluidOutputs);
+ mDuration = aRecipe.mDuration;
+ mSpecialValue = aRecipe.mSpecialValue;
+ mEUt = aRecipe.mEUt;
+ mNeedsEmptyOutput = aRecipe.mNeedsEmptyOutput;
+ mCanBeBuffered = aRecipe.mCanBeBuffered;
+ mFakeRecipe = aRecipe.mFakeRecipe;
+ mEnabled = aRecipe.mEnabled;
+ mHidden = aRecipe.mHidden;
+ }
+ protected GregtechRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ if (aInputs == null) aInputs = new ItemStack[0];
+ if (aOutputs == null) aOutputs = new ItemStack[0];
+ if (aFluidInputs == null) aFluidInputs = new FluidStack[0];
+ if (aFluidOutputs == null) aFluidOutputs = new FluidStack[0];
+ if (aChances == null) aChances = new int[aOutputs.length];
+ if (aChances.length < aOutputs.length) aChances = Arrays.copyOf(aChances, aOutputs.length);
+
+ aInputs = GT_Utility.getArrayListWithoutTrailingNulls(aInputs).toArray(new ItemStack[0]);
+ aOutputs = GT_Utility.getArrayListWithoutTrailingNulls(aOutputs).toArray(new ItemStack[0]);
+ aFluidInputs = GT_Utility.getArrayListWithoutNulls(aFluidInputs).toArray(new FluidStack[0]);
+ aFluidOutputs = GT_Utility.getArrayListWithoutNulls(aFluidOutputs).toArray(new FluidStack[0]);
+
+ GT_OreDictUnificator.setStackArray(true, aInputs);
+ GT_OreDictUnificator.setStackArray(true, aOutputs);
+
+ for (ItemStack tStack : aOutputs) GT_Utility.updateItemStack(tStack);
+
+ for (int i = 0; i < aChances.length; i++) if (aChances[i] <= 0) aChances[i] = 10000;
+ for (int i = 0; i < aFluidInputs.length; i++) aFluidInputs[i] = new GT_FluidStack(aFluidInputs[i]);
+ for (int i = 0; i < aFluidOutputs.length; i++) aFluidOutputs[i] = new GT_FluidStack(aFluidOutputs[i]);
+
+ for (int i = 0; i < aInputs.length; i++)
+ if (aInputs[i] != null && Items.feather.getDamage(aInputs[i]) != W)
+ for (int j = 0; j < aOutputs.length; j++) {
+ if (GT_Utility.areStacksEqual(aInputs[i], aOutputs[j])) {
+ if (aInputs[i].stackSize >= aOutputs[j].stackSize) {
+ aInputs[i].stackSize -= aOutputs[j].stackSize;
+ aOutputs[j] = null;
+ } else {
+ aOutputs[j].stackSize -= aInputs[i].stackSize;
+ }
+ }
+ }
+
+ if (aOptimize && aDuration >= 32) {
+ ArrayList<ItemStack> tList = new ArrayList<ItemStack>();
+ tList.addAll(Arrays.asList(aInputs));
+ tList.addAll(Arrays.asList(aOutputs));
+ for (int i = 0; i < tList.size(); i++) if (tList.get(i) == null) tList.remove(i--);
+
+ for (byte i = (byte) Math.min(64, aDuration / 16); i > 1; i--)
+ if (aDuration / i >= 16) {
+ boolean temp = true;
+ for (int j = 0, k = tList.size(); temp && j < k; j++)
+ if (tList.get(j).stackSize % i != 0) temp = false;
+ for (int j = 0; temp && j < aFluidInputs.length; j++)
+ if (aFluidInputs[j].amount % i != 0) temp = false;
+ for (int j = 0; temp && j < aFluidOutputs.length; j++)
+ if (aFluidOutputs[j].amount % i != 0) temp = false;
+ if (temp) {
+ for (int j = 0, k = tList.size(); j < k; j++) tList.get(j).stackSize /= i;
+ for (int j = 0; j < aFluidInputs.length; j++) aFluidInputs[j].amount /= i;
+ for (int j = 0; j < aFluidOutputs.length; j++) aFluidOutputs[j].amount /= i;
+ aDuration /= i;
+ }
+ }
+ }
+
+ mInputs = aInputs;
+ mOutputs = aOutputs;
+ mSpecialItems = aSpecialItems;
+ mChances = aChances;
+ mFluidInputs = aFluidInputs;
+ mFluidOutputs = aFluidOutputs;
+ mDuration = aDuration;
+ mSpecialValue = aSpecialValue;
+ mEUt = aEUt;
+
+ // checkCellBalance();
+ }
+
+ public GregtechRecipe(ItemStack aInput1, ItemStack aOutput1, int aFuelValue, int aType) {
+ this(aInput1, aOutput1, null, null, null, aFuelValue, aType);
+ }
+
+ // aSpecialValue = EU per Liter! If there is no Liquid for this Object, then it gets multiplied with 1000!
+ public GregtechRecipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aSpecialValue, int aType) {
+ this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4}, null, null, null, null, 0, 0, Math.max(1, aSpecialValue));
+
+ Utils.LOG_INFO("Switch case method for adding fuels");
+ if (mInputs.length > 0 && aSpecialValue > 0) {
+ switch (aType) {
+ // Diesel Generator
+ case 0:
+ Utils.LOG_INFO("Added fuel "+aInput1.getDisplayName()+" is ROCKET FUEL - continuing");
+ Gregtech_Recipe_Map.sRocketFuels.addRecipe(this);
+ break;
+ // Gas Turbine
+ case 1:
+ Gregtech_Recipe_Map.sGeoThermalFuels.addRecipe(this);
+ break;
+ // Thermal Generator
+ case 2:
+ //Gregtech_Recipe_Map.sHotFuels.addRecipe(this);
+ break;
+ // Plasma Generator
+ case 4:
+ //Gregtech_Recipe_Map.sPlasmaFuels.addRecipe(this);
+ break;
+ // Magic Generator
+ case 5:
+ //Gregtech_Recipe_Map.sMagicFuels.addRecipe(this);
+ break;
+ // Fluid Generator. Usually 3. Every wrong Type ends up in the Semifluid Generator
+ default:
+ //Gregtech_Recipe_Map.sDenseLiquidFuels.addRecipe(this);
+ break;
+ }
+ }
+ }
+
+ public static void reInit() {
+ GT_Log.out.println("GT_Mod: Re-Unificating Recipes.");
+ for (Gregtech_Recipe_Map tMapEntry : Gregtech_Recipe_Map.sMappings) tMapEntry.reInit();
+ }
+
+ public ItemStack getRepresentativeInput(int aIndex) {
+ if (aIndex < 0 || aIndex >= mInputs.length) return null;
+ return GT_Utility.copy(mInputs[aIndex]);
+ }
+
+ public ItemStack getOutput(int aIndex) {
+ if (aIndex < 0 || aIndex >= mOutputs.length) return null;
+ return GT_Utility.copy(mOutputs[aIndex]);
+ }
+
+ public int getOutputChance(int aIndex) {
+ if (aIndex < 0 || aIndex >= mChances.length) return 10000;
+ return mChances[aIndex];
+ }
+
+ public FluidStack getRepresentativeFluidInput(int aIndex) {
+ if (aIndex < 0 || aIndex >= mFluidInputs.length || mFluidInputs[aIndex] == null) return null;
+ return mFluidInputs[aIndex].copy();
+ }
+
+ public FluidStack getFluidOutput(int aIndex) {
+ if (aIndex < 0 || aIndex >= mFluidOutputs.length || mFluidOutputs[aIndex] == null) return null;
+ return mFluidOutputs[aIndex].copy();
+ }
+
+ public GregtechRecipe copy() {
+ return new GregtechRecipe(this);
+ }
+
+ public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, FluidStack[] aFluidInputs, ItemStack... aInputs) {
+ return isRecipeInputEqual(aDecreaseStacksizeBySuccess, false, aFluidInputs, aInputs);
+ }
+
+ public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] aFluidInputs, ItemStack... aInputs) {
+ if (mFluidInputs.length > 0 && aFluidInputs == null) return false;
+ for (FluidStack tFluid : mFluidInputs)
+ if (tFluid != null) {
+ boolean temp = true;
+ for (FluidStack aFluid : aFluidInputs)
+ if (aFluid != null && aFluid.isFluidEqual(tFluid) && (aDontCheckStackSizes || aFluid.amount >= tFluid.amount)) {
+ temp = false;
+ break;
+ }
+ if (temp) return false;
+ }
+
+ if (mInputs.length > 0 && aInputs == null) return false;
+
+ for (ItemStack tStack : mInputs)
+ if (tStack != null) {
+ boolean temp = true;
+ for (ItemStack aStack : aInputs)
+ if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) && (aDontCheckStackSizes || aStack.stackSize >= tStack.stackSize)) {
+ temp = false;
+ break;
+ }
+ if (temp) return false;
+ }
+
+ if (aDecreaseStacksizeBySuccess) {
+ if (aFluidInputs != null) {
+ for (FluidStack tFluid : mFluidInputs)
+ if (tFluid != null) {
+ for (FluidStack aFluid : aFluidInputs)
+ if (aFluid != null && aFluid.isFluidEqual(tFluid) && (aDontCheckStackSizes || aFluid.amount >= tFluid.amount)) {
+ aFluid.amount -= tFluid.amount;
+ break;
+ }
+ }
+ }
+
+ if (aInputs != null) {
+ for (ItemStack tStack : mInputs)
+ if (tStack != null) {
+ for (ItemStack aStack : aInputs)
+ if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) && (aDontCheckStackSizes || aStack.stackSize >= tStack.stackSize)) {
+ aStack.stackSize -= tStack.stackSize;
+ break;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public static class Gregtech_Recipe_Map {
+ /**
+ * Contains all Recipe Maps
+ */
+ public static final Collection<Gregtech_Recipe_Map> sMappings = new ArrayList<Gregtech_Recipe_Map>();
+ //public static final GT_Recipe_Map sChemicalBathRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.chemicalbath", "Chemical Bath", null, RES_PATH_GUI + "basicmachines/ChemicalBath", 1, 3, 1, 1, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sCokeOvenRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.cokeoven", "Coke Oven", null, RES_PATH_GUI + "basicmachines/ChemicalBath", 2, 2, 1, 0, 1, E, 1, E, true, true);
+ public static final GT_Recipe_Map sMatterFab2Recipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.matterfab2", "Matter Fabricator", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, E, 1, E, true, true);
+ //public static final Gregtech_Recipe_Map sMatterFabRecipes = new Gregtech_Recipe_Map(new HashSet<GregtechRecipe>(200), "gt.recipe.matterfab", "Matter Fabricator", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 3, 1, 1, 1, E, 1, E, true, true);
+ public static final Gregtech_Recipe_Map_Fuel sRocketFuels = new Gregtech_Recipe_Map_Fuel(new HashSet<GregtechRecipe>(10), "gt.recipe.rocketenginefuel", "Rocket Engine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 3000, " EU", true, true);
+ public static final Gregtech_Recipe_Map_Fuel sGeoThermalFuels = new Gregtech_Recipe_Map_Fuel(new HashSet<GregtechRecipe>(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true);
+
+ /**
+ * HashMap of Recipes based on their Items
+ */
+ public final Map<GT_ItemStack, Collection<GregtechRecipe>> mRecipeItemMap = new HashMap<GT_ItemStack, Collection<GregtechRecipe>>();
+ /**
+ * HashMap of Recipes based on their Fluids
+ */
+ public final Map<Fluid, Collection<GregtechRecipe>> mRecipeFluidMap = new HashMap<Fluid, Collection<GregtechRecipe>>();
+ /**
+ * The List of all Recipes
+ */
+ public final Collection<GregtechRecipe> mRecipeList;
+ /**
+ * String used as an unlocalised Name.
+ */
+ public final String mUnlocalizedName;
+ /**
+ * String used in NEI for the Recipe Lists. If null it will use the unlocalised Name instead
+ */
+ public final String mNEIName;
+ /**
+ * GUI used for NEI Display. Usually the GUI of the Machine itself
+ */
+ public final String mNEIGUIPath;
+ public final String mNEISpecialValuePre, mNEISpecialValuePost;
+ public final int mUsualInputCount, mUsualOutputCount, mNEISpecialValueMultiplier, mMinimalInputItems, mMinimalInputFluids, mAmperage;
+ public final boolean mNEIAllowed, mShowVoltageAmperageInNEI;
+
+ /**
+ * Initialises a new type of Recipe Handler.
+ *
+ * @param aRecipeList a List you specify as Recipe List. Usually just an ArrayList with a pre-initialised Size.
+ * @param aUnlocalizedName the unlocalised Name of this Recipe Handler, used mainly for NEI.
+ * @param aLocalName the displayed Name inside the NEI Recipe GUI.
+ * @param aNEIGUIPath the displayed GUI Texture, usually just a Machine GUI. Auto-Attaches ".png" if forgotten.
+ * @param aUsualInputCount the usual amount of Input Slots this Recipe Class has.
+ * @param aUsualOutputCount the usual amount of Output Slots this Recipe Class has.
+ * @param aNEISpecialValuePre the String in front of the Special Value in NEI.
+ * @param aNEISpecialValueMultiplier the Value the Special Value is getting Multiplied with before displaying
+ * @param aNEISpecialValuePost the String after the Special Value. Usually for a Unit or something.
+ * @param aNEIAllowed if NEI is allowed to display this Recipe Handler in general.
+ */
+ public Gregtech_Recipe_Map(Collection<GregtechRecipe> 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) {
+ sMappings.add(this);
+ mNEIAllowed = aNEIAllowed;
+ mShowVoltageAmperageInNEI = aShowVoltageAmperageInNEI;
+ mRecipeList = aRecipeList;
+ mNEIName = aNEIName == null ? aUnlocalizedName : aNEIName;
+ mNEIGUIPath = aNEIGUIPath.endsWith(".png") ? aNEIGUIPath : aNEIGUIPath + ".png";
+ mNEISpecialValuePre = aNEISpecialValuePre;
+ mNEISpecialValueMultiplier = aNEISpecialValueMultiplier;
+ mNEISpecialValuePost = aNEISpecialValuePost;
+ mAmperage = aAmperage;
+ mUsualInputCount = aUsualInputCount;
+ mUsualOutputCount = aUsualOutputCount;
+ mMinimalInputItems = aMinimalInputItems;
+ mMinimalInputFluids = aMinimalInputFluids;
+ GregTech_API.sFluidMappings.add(mRecipeFluidMap);
+ GregTech_API.sItemStackMappings.add(mRecipeItemMap);
+ GT_LanguageManager.addStringLocalization(mUnlocalizedName = aUnlocalizedName, aLocalName);
+ }
+
+ public GregtechRecipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return addRecipe(new GregtechRecipe(aOptimize, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
+ }
+
+ public GregtechRecipe addRecipe(int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return addRecipe(new GregtechRecipe(false, null, null, null, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue), false, false, false);
+ }
+
+ public GregtechRecipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return addRecipe(new GregtechRecipe(aOptimize, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
+ }
+
+ public GregtechRecipe addRecipe(boolean aOptimize, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return addRecipe(new GregtechRecipe(aOptimize, null, null, null, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
+ }
+
+ /*public GregtechRecipe addRecipe(boolean aOptimize, FluidStack aInput1, FluidStack aOutput1, ItemStack[] bInput1, ItemStack[] bOutput1, int aDuration, int aEUt, int aSpecialValue) {
+ return addRecipe(new GregtechRecipe(aOptimize, aInput1, aOutput1, bInput1,bOutput1, aDuration, aEUt, aSpecialValue));
+
+ }*/
+
+ public GregtechRecipe addRecipe(GregtechRecipe aRecipe) {
+ Utils.LOG_INFO("Adding Recipe Method 1");
+ return addRecipe(aRecipe, true, false, false);
+ }
+
+ protected GregtechRecipe addRecipe(GregtechRecipe aRecipe, boolean aCheckForCollisions, boolean aFakeRecipe, boolean aHidden) {
+ Utils.LOG_INFO("Adding Recipe Method 2");
+ aRecipe.mHidden = aHidden;
+ aRecipe.mFakeRecipe = aFakeRecipe;
+ if (aRecipe.mFluidInputs.length < mMinimalInputFluids && aRecipe.mInputs.length < mMinimalInputItems){
+ Utils.LOG_INFO("Step 2 failed");
+ return null;}
+ if (aCheckForCollisions && findRecipe(null, false, Long.MAX_VALUE, aRecipe.mFluidInputs, aRecipe.mInputs) != null){
+ Utils.LOG_INFO("Step 2 failed - 2");
+ return null;
+ }
+ return add(aRecipe);
+ }
+
+
+
+ /**
+ * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes
+ */
+ public GregtechRecipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return addFakeRecipe(aCheckForCollisions, new GregtechRecipe(false, aInputs, aOutputs, aSpecial, aOutputChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
+ }
+
+ /**
+ * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes
+ */
+ public GregtechRecipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return addFakeRecipe(aCheckForCollisions, new GregtechRecipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue));
+ }
+
+ /**
+ * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes
+ */
+ public GregtechRecipe addFakeRecipe(boolean aCheckForCollisions, GregtechRecipe aRecipe) {
+ return addRecipe(aRecipe, aCheckForCollisions, true, false);
+ }
+
+ public GregtechRecipe add(GregtechRecipe aRecipe) {
+ Utils.LOG_INFO("Adding Recipe Method 3");
+ mRecipeList.add(aRecipe);
+ for (FluidStack aFluid : aRecipe.mFluidInputs)
+ if (aFluid != null) {
+ Utils.LOG_INFO("Fluid is valid - getting some kind of fluid instance to add to the recipe hashmap.");
+ Collection<GregtechRecipe> tList = mRecipeFluidMap.get(aFluid.getFluid());
+ if (tList == null) mRecipeFluidMap.put(aFluid.getFluid(), tList = new HashSet<GregtechRecipe>(1));
+ tList.add(aRecipe);
+ }
+ return addToItemMap(aRecipe);
+ }
+
+ public void reInit() {
+ Map<GT_ItemStack, Collection<GregtechRecipe>> tMap = mRecipeItemMap;
+ if (tMap != null) tMap.clear();
+ for (GregtechRecipe tRecipe : mRecipeList) {
+ GT_OreDictUnificator.setStackArray(true, tRecipe.mInputs);
+ GT_OreDictUnificator.setStackArray(true, tRecipe.mOutputs);
+ if (tMap != null) addToItemMap(tRecipe);
+ }
+ }
+
+ /**
+ * @return if this Item is a valid Input for any for the Recipes
+ */
+ public boolean containsInput(ItemStack aStack) {
+ return aStack != null && (mRecipeItemMap.containsKey(new GT_ItemStack(aStack)) || mRecipeItemMap.containsKey(new GT_ItemStack(GT_Utility.copyMetaData(W, aStack))));
+ }
+
+ /**
+ * @return if this Fluid is a valid Input for any for the Recipes
+ */
+ public boolean containsInput(FluidStack aFluid) {
+ return aFluid != null && containsInput(aFluid.getFluid());
+ }
+
+ /**
+ * @return if this Fluid is a valid Input for any for the Recipes
+ */
+ public boolean containsInput(Fluid aFluid) {
+ return aFluid != null && mRecipeFluidMap.containsKey(aFluid);
+ }
+
+ public GregtechRecipe findRecipe(IHasWorldObjectAndCoords aTileEntity, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) {
+ return findRecipe(aTileEntity, null, aNotUnificated, aVoltage, aFluids, null, aInputs);
+ }
+
+ public GregtechRecipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GregtechRecipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack... aInputs) {
+ return findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, null, aInputs);
+ }
+
+ /**
+ * finds a Recipe matching the aFluid and ItemStack Inputs.
+ *
+ * @param aTileEntity an Object representing the current coordinates of the executing Block/Entity/Whatever. This may be null, especially during Startup.
+ * @param aRecipe in case this is != null it will try to use this Recipe first when looking things up.
+ * @param aNotUnificated if this is T the Recipe searcher will unificate the ItemStack Inputs
+ * @param aVoltage Voltage of the Machine or Long.MAX_VALUE if it has no Voltage
+ * @param aFluids the Fluid Inputs
+ * @param aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with this, but some custom ones do.
+ * @param aInputs the Item Inputs
+ * @return the Recipe it has found or null for no matching Recipe
+ */
+ public GregtechRecipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GregtechRecipe aRecipe, boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) {
+ // No Recipes? Well, nothing to be found then.
+ if (mRecipeList.isEmpty()) return null;
+
+ // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or "at least 2 Stacks" before they start searching for Recipes.
+ // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in their Machines to select Sub Recipes.
+ if (GregTech_API.sPostloadFinished) {
+ if (mMinimalInputFluids > 0) {
+ if (aFluids == null) return null;
+ int tAmount = 0;
+ for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++;
+ if (tAmount < mMinimalInputFluids) return null;
+ }
+ if (mMinimalInputItems > 0) {
+ if (aInputs == null) return null;
+ int tAmount = 0;
+ for (ItemStack aInput : aInputs) if (aInput != null) tAmount++;
+ if (tAmount < mMinimalInputItems) return null;
+ }
+ }
+
+ // Unification happens here in case the Input isn't already unificated.
+ if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs);
+
+ // Check the Recipe which has been used last time in order to not have to search for it again, if possible.
+ if (aRecipe != null)
+ if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs))
+ return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null;
+
+ // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items.
+ if (mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs)
+ if (tStack != null) {
+ Collection<GregtechRecipe>
+ tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack));
+ if (tRecipes != null) for (GregtechRecipe tRecipe : tRecipes)
+ if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs))
+ return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
+ tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, tStack)));
+ if (tRecipes != null) for (GregtechRecipe tRecipe : tRecipes)
+ if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs))
+ return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
+ }
+
+ // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that Map too.
+ if (mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids)
+ if (aFluid != null) {
+ Collection<GregtechRecipe>
+ tRecipes = mRecipeFluidMap.get(aFluid.getFluid());
+ if (tRecipes != null) for (GregtechRecipe tRecipe : tRecipes)
+ if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs))
+ return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
+ }
+
+ // And nothing has been found.
+ return null;
+ }
+
+ protected GregtechRecipe addToItemMap(GregtechRecipe aRecipe) {
+ Utils.LOG_INFO("Adding Recipe Method 4");
+ for (ItemStack aStack : aRecipe.mInputs)
+ if (aStack != null) {
+ Utils.LOG_INFO("Method 4 - Manipulating "+aStack.getDisplayName());
+ GT_ItemStack tStack = new GT_ItemStack(aStack);
+ Utils.LOG_INFO("Method 4 - Made gt stack of item "+tStack.toStack().getDisplayName());
+ Collection<GregtechRecipe> tList = mRecipeItemMap.get(tStack);
+ if (tList != null){
+ Utils.LOG_INFO("Method 4 - Gt Recipe Hashmap: "+tList.toString());
+ }
+ if (tList == null){
+ Utils.LOG_INFO("Method 4 - brrr list was NUll");
+ mRecipeItemMap.put(tStack, tList = new HashSet<GregtechRecipe>(1));
+ }
+ tList.add(aRecipe);
+ Utils.LOG_INFO("Method 4 - Added recipe to map? I think.");
+ }
+ return aRecipe;
+ }
+
+ public GregtechRecipe findRecipe(IGregTechTileEntity baseMetaTileEntity, GregtechRecipe aRecipe, boolean aNotUnificated,
+ long aVoltage, FluidStack[] aFluids, FluidStack[] fluidStacks) {
+
+ ItemStack aInputs[] = null;
+ // No Recipes? Well, nothing to be found then.
+ if (mRecipeList.isEmpty()) return null;
+
+ // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or "at least 2 Stacks" before they start searching for Recipes.
+ // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in their Machines to select Sub Recipes.
+ if (GregTech_API.sPostloadFinished) {
+ if (mMinimalInputFluids > 0) {
+ if (aFluids == null) return null;
+ int tAmount = 0;
+ for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++;
+ if (tAmount < mMinimalInputFluids) return null;
+ }
+ if (mMinimalInputItems > 0) {
+ if (aInputs == null) return null;
+ int tAmount = 0;
+ for (ItemStack aInput : aInputs) if (aInput != null) tAmount++;
+ if (tAmount < mMinimalInputItems) return null;
+ }
+ }
+
+ // Unification happens here in case the Input isn't already unificated.
+ if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs);
+
+ // Check the Recipe which has been used last time in order to not have to search for it again, if possible.
+ if (aRecipe != null)
+ if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs))
+ return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null;
+
+ // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items.
+ if (mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs)
+ if (tStack != null) {
+ Collection<GregtechRecipe>
+ tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack));
+ if (tRecipes != null) for (GregtechRecipe tRecipe : tRecipes)
+ if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs))
+ return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
+ tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, tStack)));
+ if (tRecipes != null) for (GregtechRecipe tRecipe : tRecipes)
+ if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs))
+ return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
+ }
+
+ // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that Map too.
+ if (mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids)
+ if (aFluid != null) {
+ Collection<GregtechRecipe>
+ tRecipes = mRecipeFluidMap.get(aFluid.getFluid());
+ if (tRecipes != null) for (GregtechRecipe tRecipe : tRecipes)
+ if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs))
+ return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null;
+ }
+
+ // And nothing has been found.
+ return null;
+ }
+ }
+
+ // -----------------------------------------------------------------------------------------------------------------
+ // Here are a few Classes I use for Special Cases in some Machines without having to write a separate Machine Class.
+ // -----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Abstract Class for general Recipe Handling of non GT Recipes
+ */
+ public static abstract class GT_Recipe_Map_NonGTRecipes extends Gregtech_Recipe_Map {
+ public GT_Recipe_Map_NonGTRecipes(Collection<GregtechRecipe> 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);
+ }
+
+ @Override
+ public boolean containsInput(ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean containsInput(FluidStack aFluid) {
+ return false;
+ }
+
+ @Override
+ public boolean containsInput(Fluid aFluid) {
+ return false;
+ }
+
+ @Override
+ public GregtechRecipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return null;
+ }
+
+ @Override
+ public GregtechRecipe addRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return null;
+ }
+
+ @Override
+ public GregtechRecipe addRecipe(GregtechRecipe aRecipe) {
+ return null;
+ }
+
+ @Override
+ public GregtechRecipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, int[] aOutputChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return null;
+ }
+
+ @Override
+ public GregtechRecipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ return null;
+ }
+
+ @Override
+ public GregtechRecipe addFakeRecipe(boolean aCheckForCollisions, GregtechRecipe aRecipe) {
+ return null;
+ }
+
+ @Override
+ public GregtechRecipe add(GregtechRecipe aRecipe) {
+ return null;
+ }
+
+ @Override
+ public void reInit() {/**/}
+
+ @Override
+ protected GregtechRecipe addToItemMap(GregtechRecipe aRecipe) {
+ return null;
+ }
+ }
+
+ /**
+ * Just a Recipe Map with Utility specifically for Fuels.
+ */
+ public static class Gregtech_Recipe_Map_Fuel extends Gregtech_Recipe_Map {
+ public Gregtech_Recipe_Map_Fuel(Collection<GregtechRecipe> 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);
+ }
+
+ public GregtechRecipe addFuel(ItemStack aInput, ItemStack aOutput, int aFuelValueInEU) {
+ Utils.LOG_INFO("Adding Fuel using method 1");
+ return addFuel(aInput, aOutput, null, null, 10000, aFuelValueInEU);
+ }
+
+ public GregtechRecipe addFuel(ItemStack aInput, ItemStack aOutput, int aChance, int aFuelValueInEU) {
+ Utils.LOG_INFO("Adding Fuel using method 2");
+ return addFuel(aInput, aOutput, null, null, aChance, aFuelValueInEU);
+ }
+
+ public GregtechRecipe addFuel(FluidStack aFluidInput, FluidStack aFluidOutput, int aFuelValueInEU) {
+ Utils.LOG_INFO("Adding Fuel using method 3");
+ return addFuel(null, null, aFluidInput, aFluidOutput, 10000, aFuelValueInEU);
+ }
+
+ public GregtechRecipe addFuel(ItemStack aInput, ItemStack aOutput, FluidStack aFluidInput, FluidStack aFluidOutput, int aFuelValueInEU) {
+ Utils.LOG_INFO("Adding Fuel using method 4");
+ return addFuel(aInput, aOutput, aFluidInput, aFluidOutput, 10000, aFuelValueInEU);
+ }
+
+ public GregtechRecipe addFuel(ItemStack aInput, ItemStack aOutput, FluidStack aFluidInput, FluidStack aFluidOutput, int aChance, int aFuelValueInEU) {
+ Utils.LOG_INFO("Adding Fuel using method 5");
+ return addRecipe(true, new ItemStack[]{aInput}, new ItemStack[]{aOutput}, null, new int[]{aChance}, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, 0, 0, aFuelValueInEU);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipeRegistrator.java b/src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipeRegistrator.java
new file mode 100644
index 0000000000..b402fe500f
--- /dev/null
+++ b/src/Java/miscutil/xmod/gregtech/api/util/GregtechRecipeRegistrator.java
@@ -0,0 +1,339 @@
+package miscutil.xmod.gregtech.api.util;
+
+import static gregtech.api.enums.GT_Values.L;
+import static gregtech.api.enums.GT_Values.M;
+import static gregtech.api.enums.GT_Values.RA;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.ConfigCategories;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.enums.SubTag;
+import gregtech.api.enums.TC_Aspects;
+import gregtech.api.enums.TC_Aspects.TC_AspectStack;
+import gregtech.api.interfaces.internal.IThaumcraftCompat;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_Utility;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import miscutil.xmod.gregtech.api.enums.GregtechOrePrefixes;
+import miscutil.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials;
+import miscutil.xmod.gregtech.api.objects.GregtechItemData;
+import miscutil.xmod.gregtech.api.objects.GregtechMaterialStack;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Class for Automatic Recipe registering.
+ */
+public class GregtechRecipeRegistrator {
+ /**
+ * List of GT_Materials, which are used in the Creation of Sticks. All Rod GT_Materials are automatically added to this List.
+ */
+ public static final List<GT_Materials> sRodMaterialList = new ArrayList<GT_Materials>();
+ private static final ItemStack sMt1 = new ItemStack(Blocks.dirt, 1, 0), sMt2 = new ItemStack(Blocks.dirt, 1, 0);
+ private static final String s_H = "h", s_F = "f", s_I = "I", s_P = "P", s_R = "R";
+ private static final ItemStack[][]
+ sShapes1 = new ItemStack[][]{
+ {sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1, null},
+ {sMt1, null, sMt1, sMt1, null, sMt1, sMt1, sMt1, sMt1},
+ {null, sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1},
+ {sMt1, sMt1, sMt1, sMt1, null, sMt1, null, null, null},
+ {sMt1, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1},
+ {sMt1, sMt1, sMt1, sMt1, null, sMt1, sMt1, null, sMt1},
+ {null, null, null, sMt1, null, sMt1, sMt1, null, sMt1},
+ {null, sMt1, null, null, sMt1, null, null, sMt2, null},
+ {sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2, null},
+ {null, sMt1, null, null, sMt2, null, null, sMt2, null},
+ {sMt1, sMt1, null, sMt1, sMt2, null, null, sMt2, null},
+ {null, sMt1, sMt1, null, sMt2, sMt1, null, sMt2, null},
+ {sMt1, sMt1, null, null, sMt2, null, null, sMt2, null},
+ {null, sMt1, sMt1, null, sMt2, null, null, sMt2, null},
+ {null, sMt1, null, sMt1, null, null, null, sMt1, sMt2},
+ {null, sMt1, null, null, null, sMt1, sMt2, sMt1, null},
+ {null, sMt1, null, sMt1, null, sMt1, null, null, sMt2},
+ {null, sMt1, null, sMt1, null, sMt1, sMt2, null, null},
+ {null, sMt2, null, null, sMt1, null, null, sMt1, null},
+ {null, sMt2, null, null, sMt2, null, sMt1, sMt1, sMt1},
+ {null, sMt2, null, null, sMt2, null, null, sMt1, null},
+ {null, sMt2, null, sMt1, sMt2, null, sMt1, sMt1, null},
+ {null, sMt2, null, null, sMt2, sMt1, null, sMt1, sMt1},
+ {null, sMt2, null, null, sMt2, null, sMt1, sMt1, null},
+ {sMt1, null, null, null, sMt2, null, null, null, sMt2},
+ {null, null, sMt1, null, sMt2, null, sMt2, null, null},
+ {sMt1, null, null, null, sMt2, null, null, null, null},
+ {null, null, sMt1, null, sMt2, null, null, null, null},
+ {sMt1, sMt2, null, null, null, null, null, null, null},
+ {sMt2, sMt1, null, null, null, null, null, null, null},
+ {sMt1, null, null, sMt2, null, null, null, null, null},
+ {sMt2, null, null, sMt1, null, null, null, null, null},
+ {sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, null, sMt2, null},
+ {sMt1, sMt1, null, sMt1, sMt1, sMt2, sMt1, sMt1, null},
+ {null, sMt1, sMt1, sMt2, sMt1, sMt1, null, sMt1, sMt1},
+ {null, sMt2, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1},
+ {sMt1, sMt1, sMt1, sMt1, sMt2, sMt1, null, sMt2, null},
+ {sMt1, sMt1, null, sMt1, sMt2, sMt2, sMt1, sMt1, null},
+ {null, sMt1, sMt1, sMt2, sMt2, sMt1, null, sMt1, sMt1},
+ {null, sMt2, null, sMt1, sMt2, sMt1, sMt1, sMt1, sMt1},
+ {sMt1, null, null, null, sMt1, null, null, null, null},
+ {null, sMt1, null, sMt1, null, null, null, null, null},
+ {sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null},
+ {null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2}
+ };
+ private static final String[][] sShapesA = new String[][]{
+ null,
+ null,
+ null,
+ {"Helmet", s_P + s_P + s_P, s_P + s_H + s_P},
+ {"ChestPlate", s_P + s_H + s_P, s_P + s_P + s_P, s_P + s_P + s_P},
+ {"Pants", s_P + s_P + s_P, s_P + s_H + s_P, s_P + " " + s_P},
+ {"Boots", s_P + " " + s_P, s_P + s_H + s_P},
+ {"Sword", " " + s_P + " ", s_F + s_P + s_H, " " + s_R + " "},
+ {"Pickaxe", s_P + s_I + s_I, s_F + s_R + s_H, " " + s_R + " "},
+ {"Shovel", s_F + s_P + s_H, " " + s_R + " ", " " + s_R + " "},
+ {"Axe", s_P + s_I + s_H, s_P + s_R + " ", s_F + s_R + " "},
+ {"Axe", s_P + s_I + s_H, s_P + s_R + " ", s_F + s_R + " "},
+ {"Hoe", s_P + s_I + s_H, s_F + s_R + " ", " " + s_R + " "},
+ {"Hoe", s_P + s_I + s_H, s_F + s_R + " ", " " + s_R + " "},
+ {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R},
+ {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R},
+ {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R},
+ {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R},
+ {"Sword", " " + s_R + " ", s_F + s_P + s_H, " " + s_P + " "},
+ {"Pickaxe", " " + s_R + " ", s_F + s_R + s_H, s_P + s_I + s_I},
+ {"Shovel", " " + s_R + " ", " " + s_R + " ", s_F + s_P + s_H},
+ {"Axe", s_F + s_R + " ", s_P + s_R + " ", s_P + s_I + s_H},
+ {"Axe", s_F + s_R + " ", s_P + s_R + " ", s_P + s_I + s_H},
+ {"Hoe", " " + s_R + " ", s_F + s_R + " ", s_P + s_I + s_H},
+ {"Hoe", " " + s_R + " ", s_F + s_R + " ", s_P + s_I + s_H},
+ {"Spear", s_P + s_H + " ", s_F + s_R + " ", " " + " " + s_R},
+ {"Spear", s_P + s_H + " ", s_F + s_R + " ", " " + " " + s_R},
+ {"Knive", s_H + s_P, s_R + s_F},
+ {"Knive", s_F + s_H, s_P + s_R},
+ {"Knive", s_F + s_H, s_P + s_R},
+ {"Knive", s_P + s_F, s_R + s_H},
+ {"Knive", s_P + s_F, s_R + s_H},
+ null,
+ null,
+ null,
+ null,
+ {"WarAxe", s_P + s_P + s_P, s_P + s_R + s_P, s_F + s_R + s_H},
+ null,
+ null,
+ null,
+ {"Shears", s_H + s_P, s_P + s_F},
+ {"Shears", s_H + s_P, s_P + s_F},
+ {"Scythe", s_I + s_P + s_H, s_R + s_F + s_P, s_R + " " + " "},
+ {"Scythe", s_H + s_P + s_I, s_P + s_F + s_R, " " + " " + s_R}
+ };
+ public static volatile int VERSION = 508;
+
+ public static void registerMaterialRecycling(ItemStack aStack, GT_Materials aMaterial, long aMaterialAmount, GregtechMaterialStack aByproduct) {
+ if (GT_Utility.isStackInvalid(aStack)) return;
+ if (aByproduct != null) {
+ aByproduct = aByproduct.clone();
+ aByproduct.mAmount /= aStack.stackSize;
+ }
+ GregtechOreDictUnificator.addItemData(GT_Utility.copyAmount(1, aStack), new GregtechItemData(aMaterial, aMaterialAmount / aStack.stackSize, aByproduct));
+ }
+
+ public static void registerMaterialRecycling(ItemStack aStack, GregtechItemData aData) {
+ if (GT_Utility.isStackInvalid(aStack) || GT_Utility.areStacksEqual(new ItemStack(Items.blaze_rod), aStack) || aData == null || !aData.hasValidMaterialData() || aData.mMaterial.mAmount <= 0 || GT_Utility.getFluidForFilledItem(aStack, false) != null)
+ return;
+ registerReverseMacerating(GT_Utility.copyAmount(1, aStack), aData, aData.mPrefix == null);
+ registerReverseSmelting(GT_Utility.copyAmount(1, aStack), aData.mMaterial.mMaterial, aData.mMaterial.mAmount, true);
+ registerReverseFluidSmelting(GT_Utility.copyAmount(1, aStack), aData.mMaterial.mMaterial, aData.mMaterial.mAmount, aData.getByProduct(0));
+ registerReverseArcSmelting(GT_Utility.copyAmount(1, aStack), aData);
+ }
+
+ /**
+ * @param aStack the stack to be recycled.
+ * @param aMaterial the Material.
+ * @param aMaterialAmount the amount of it in Material Units.
+ */
+ public static void registerReverseFluidSmelting(ItemStack aStack, GT_Materials aMaterial, long aMaterialAmount, GregtechMaterialStack aByproduct) {
+ if (aStack == null || aMaterial == null || aMaterial.mSmeltInto.mStandardMoltenFluid == null || !aMaterial.contains(SubTag.SMELTING_TO_FLUID) || (L * aMaterialAmount) / (M * aStack.stackSize) <= 0)
+ return;
+ RA.addFluidSmelterRecipe(GT_Utility.copyAmount(1, aStack), aByproduct == null ? null : aByproduct.mMaterial.contains(SubTag.NO_SMELTING) || !aByproduct.mMaterial.contains(SubTag.METAL) ? aByproduct.mMaterial.contains(SubTag.FLAMMABLE) ? GregtechOreDictUnificator.getDust(GT_Materials._NULL, aByproduct.mAmount / 2) : aByproduct.mMaterial.contains(SubTag.UNBURNABLE) ? GregtechOreDictUnificator.getDustOrIngot(aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount) : null : GregtechOreDictUnificator.getIngotOrDust(aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount), aMaterial.mSmeltInto.getMolten((L * aMaterialAmount) / (M * aStack.stackSize)), 10000, (int) Math.max(1, (24 * aMaterialAmount) / M), Math.max(8, (int) Math.sqrt(2 * aMaterial.mSmeltInto.mStandardMoltenFluid.getTemperature())));
+ }
+
+ /**
+ * @param aStack the stack to be recycled.
+ * @param aMaterial the Material.
+ * @param aMaterialAmount the amount of it in Material Units.
+ * @param aAllowAlloySmelter if it is allowed to be recycled inside the Alloy Smelter.
+ */
+ public static void registerReverseSmelting(ItemStack aStack, GT_Materials aMaterial, long aMaterialAmount, boolean aAllowAlloySmelter) {
+ if (aStack == null || aMaterial == null || aMaterialAmount <= 0 || aMaterial.contains(SubTag.NO_SMELTING) || (aMaterialAmount > M && aMaterial.contains(SubTag.METAL)))
+ return;
+ aMaterialAmount /= aStack.stackSize;
+
+ if (aAllowAlloySmelter)
+ GT_ModHandler.addSmeltingAndAlloySmeltingRecipe(GT_Utility.copyAmount(1, aStack), GregtechOreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount));
+ else
+ GT_ModHandler.addSmeltingRecipe(GT_Utility.copyAmount(1, aStack), GregtechOreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount));
+ }
+
+ public static void registerReverseArcSmelting(ItemStack aStack, GT_Materials aMaterial, long aMaterialAmount, GregtechMaterialStack aByProduct01, GregtechMaterialStack aByProduct02, GregtechMaterialStack aByProduct03) {
+ registerReverseArcSmelting(aStack, new GregtechItemData(aMaterial == null ? null : new GregtechMaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03));
+ }
+
+ public static void registerReverseArcSmelting(ItemStack aStack, GregtechItemData aData) {
+ if (aStack == null || aData == null) return;
+ aData = new GregtechItemData(aData);
+
+ if (!aData.hasValidMaterialData()) return;
+
+ for (GregtechMaterialStack tMaterial : aData.getAllGT_MaterialStacks()) {
+ if (tMaterial.mMaterial.contains(SubTag.UNBURNABLE)) {
+ tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto;
+ continue;
+ }
+ if (tMaterial.mMaterial.contains(SubTag.EXPLOSIVE)) {
+ tMaterial.mAmount /= 4;
+ continue;
+ }
+ if (tMaterial.mMaterial.contains(SubTag.FLAMMABLE)) {
+ tMaterial.mAmount /= 2;
+ continue;
+ }
+ if (tMaterial.mMaterial.contains(SubTag.NO_SMELTING)) {
+ tMaterial.mAmount = 0;
+ continue;
+ }
+ if (tMaterial.mMaterial.contains(SubTag.METAL)) {
+ tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto;
+ continue;
+ }
+ tMaterial.mAmount = 0;
+ }
+
+ aData = new GregtechItemData(aData);
+
+ if (aData.mByProducts.length > 3) for (GregtechMaterialStack tMaterial : aData.getAllGT_MaterialStacks())
+
+ aData = new GregtechItemData(aData);
+
+ if (!aData.hasValidMaterialData()) return;
+
+ long tAmount = 0;
+ for (GregtechMaterialStack tMaterial : aData.getAllGT_MaterialStacks())
+ tAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass();
+
+ RA.addArcFurnaceRecipe(aStack, new ItemStack[]{GregtechOreDictUnificator.getIngotOrDust(aData.mMaterial), GregtechOreDictUnificator.getIngotOrDust(aData.getByProduct(0)), GregtechOreDictUnificator.getIngotOrDust(aData.getByProduct(1)), GregtechOreDictUnificator.getIngotOrDust(aData.getByProduct(2))}, null, (int) Math.max(16, tAmount / M), 96);
+ }
+
+ public static void registerReverseMacerating(ItemStack aStack, GT_Materials aMaterial, long aMaterialAmount, GregtechMaterialStack aByProduct01, GregtechMaterialStack aByProduct02, GregtechMaterialStack aByProduct03, boolean aAllowHammer) {
+ registerReverseMacerating(aStack, new GregtechItemData(aMaterial == null ? null : new GregtechMaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03), aAllowHammer);
+ }
+
+ public static void registerReverseMacerating(ItemStack aStack, GregtechItemData aData, boolean aAllowHammer) {
+ if (aStack == null || aData == null) return;
+ aData = new GregtechItemData(aData);
+
+ if (!aData.hasValidMaterialData()) return;
+
+ for (GregtechMaterialStack tMaterial : aData.getAllGT_MaterialStacks())
+ tMaterial.mMaterial = tMaterial.mMaterial.mMacerateInto;
+
+ aData = new GregtechItemData(aData);
+
+ if (!aData.hasValidMaterialData()) return;
+
+ long tAmount = 0;
+ for (GregtechMaterialStack tMaterial : aData.getAllGT_MaterialStacks())
+ tAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass();
+
+ RA.addPulveriserRecipe(aStack, new ItemStack[]{GregtechOreDictUnificator.getDust(aData.mMaterial), GregtechOreDictUnificator.getDust(aData.getByProduct(0)), GregtechOreDictUnificator.getDust(aData.getByProduct(1)), GregtechOreDictUnificator.getDust(aData.getByProduct(2))}, null, (int) Math.max(16, tAmount / M), 4);
+
+ if (aAllowHammer) for (GregtechMaterialStack tMaterial : aData.getAllGT_MaterialStacks())
+ if (tMaterial.mMaterial.contains(SubTag.CRYSTAL) && !tMaterial.mMaterial.contains(SubTag.METAL)) {
+ if (RA.addForgeHammerRecipe(GT_Utility.copyAmount(1, aStack), GregtechOreDictUnificator.getDust(aData.mMaterial), 200, 32))
+ break;
+ }
+ ItemStack tDust = GregtechOreDictUnificator.getDust(aData.mMaterial);
+ if (tDust != null && GT_ModHandler.addPulverisationRecipe(GT_Utility.copyAmount(1, aStack), tDust, GregtechOreDictUnificator.getDust(aData.getByProduct(0)), 100, GregtechOreDictUnificator.getDust(aData.getByProduct(1)), 100, true)) {
+ if (GregTech_API.sThaumcraftCompat != null)
+ GregTech_API.sThaumcraftCompat.addCrucibleRecipe(IThaumcraftCompat.ADVANCEDENTROPICPROCESSING, aStack, tDust, Arrays.asList(new TC_AspectStack(TC_Aspects.PERDITIO, Math.max(1, (aData.mMaterial.mAmount * 2) / M))));
+ }
+ }
+
+ /**
+ * You give this Function a Material and it will scan almost everything for adding recycling Recipes
+ *
+ * @param aMat a Material, for example an Ingot or a Gem.
+ * @param aOutput the Dust you usually get from macerating aMat
+ * @param aRecipeReplacing allows to replace the Recipe with a Plate variant
+ */
+ public static synchronized void registerUsagesForGT_Materials(ItemStack aMat, String aPlate, boolean aRecipeReplacing) {
+ if (aMat == null) return;
+ aMat = GT_Utility.copy(aMat);
+ ItemStack tStack;
+ GregtechItemData aItemData = GregtechOreDictUnificator.getItemData(aMat);
+ if (aItemData == null || aItemData.mPrefix != GregtechOrePrefixes.ingot) aPlate = null;
+ if (aPlate != null && GregtechOreDictUnificator.getFirstOre(aPlate, 1) == null) aPlate = null;
+
+ sMt1.func_150996_a(aMat.getItem());
+ sMt1.stackSize = 1;
+ Items.feather.setDamage(sMt1, Items.feather.getDamage(aMat));
+
+ sMt2.func_150996_a(new ItemStack(Blocks.dirt).getItem());
+ sMt2.stackSize = 1;
+ Items.feather.setDamage(sMt2, 0);
+
+ for (ItemStack[] tRecipe : sShapes1) {
+ int tAmount1 = 0;
+ for (ItemStack tMat : tRecipe) {
+ if (tMat == sMt1) tAmount1++;
+ }
+ if (aItemData != null && aItemData.hasValidPrefixMaterialData())
+ for (ItemStack tCrafted : GT_ModHandler.getRecipeOutputs(tRecipe)) {
+ GregtechOreDictUnificator.addItemData(tCrafted, new GregtechItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1));
+ }
+ }
+
+ for (GT_Materials tMaterial : sRodMaterialList) {
+ ItemStack tMt2 = GregtechOreDictUnificator.get(GregtechOrePrefixes.stick, tMaterial, 1);
+ if (tMt2 != null) {
+ sMt2.func_150996_a(tMt2.getItem());
+ sMt2.stackSize = 1;
+ Items.feather.setDamage(sMt2, Items.feather.getDamage(tMt2));
+
+ for (int i = 0; i < sShapes1.length; i++) {
+ ItemStack[] tRecipe = sShapes1[i];
+
+ int tAmount1 = 0, tAmount2 = 0;
+ for (ItemStack tMat : tRecipe) {
+ if (tMat == sMt1) tAmount1++;
+ if (tMat == sMt2) tAmount2++;
+ }
+ for (ItemStack tCrafted : GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe)) {
+ if (aItemData != null && aItemData.hasValidPrefixMaterialData())
+ GregtechOreDictUnificator.addItemData(tCrafted, new GregtechItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1, new GregtechMaterialStack(tMaterial, OrePrefixes.stick.mMaterialAmount * tAmount2)));
+
+ if (aRecipeReplacing && aPlate != null && sShapesA[i] != null && sShapesA[i].length > 1) {
+ assert aItemData != null;
+ if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.recipereplacements, aItemData.mMaterial.mMaterial + "." + sShapesA[i][0], true)) {
+ if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe))) {
+ switch (sShapesA[i].length) {
+ case 2:
+ GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData});
+ break;
+ case 3:
+ GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], sShapesA[i][2], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData});
+ break;
+ default:
+ GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], sShapesA[i][2], sShapesA[i][3], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData});
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}