aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil/gregtech/api
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-06-30 03:42:21 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-06-30 03:42:21 +1000
commitb705cd62b037f8bf40c74d130177b5b2524d2e1b (patch)
treee16f65ddbb5d215f7a53618c6716e83e011449b3 /src/Java/miscutil/gregtech/api
parent3304d37df6a306fa0b554ee25e99c78115b46c2b (diff)
downloadGT5-Unofficial-b705cd62b037f8bf40c74d130177b5b2524d2e1b.tar.gz
GT5-Unofficial-b705cd62b037f8bf40c74d130177b5b2524d2e1b.tar.bz2
GT5-Unofficial-b705cd62b037f8bf40c74d130177b5b2524d2e1b.zip
% More Work on the GT Material System implementation.
Diffstat (limited to 'src/Java/miscutil/gregtech/api')
-rw-r--r--src/Java/miscutil/gregtech/api/objects/GregtechItemData.java130
-rw-r--r--src/Java/miscutil/gregtech/api/util/GregtechOreDictUnificator.java8
2 files changed, 137 insertions, 1 deletions
diff --git a/src/Java/miscutil/gregtech/api/objects/GregtechItemData.java b/src/Java/miscutil/gregtech/api/objects/GregtechItemData.java
new file mode 100644
index 0000000000..35c0eb2c74
--- /dev/null
+++ b/src/Java/miscutil/gregtech/api/objects/GregtechItemData.java
@@ -0,0 +1,130 @@
+package miscutil.gregtech.api.objects;
+
+import gregtech.api.objects.GT_ArrayList;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import miscutil.gregtech.api.enums.GregtechOrePrefixes;
+import miscutil.gregtech.api.enums.GregtechOrePrefixes.GT_Materials;
+import net.minecraft.item.ItemStack;
+
+public class GregtechItemData {
+ private static final GregtechMaterialStack[] EMPTY_GT_MaterialStack_ARRAY = new GregtechMaterialStack[0];
+
+ public final List<Object> mExtraData = new GT_ArrayList<Object>(false, 1);
+ public final GregtechOrePrefixes mPrefix;
+ public final GregtechMaterialStack mMaterial;
+ public final GregtechMaterialStack[] mByProducts;
+ public boolean mBlackListed = false;
+ public ItemStack mUnificationTarget = null;
+
+ public GregtechItemData(GregtechOrePrefixes aPrefix, GT_Materials aMaterial, boolean aBlackListed) {
+ mPrefix = aPrefix;
+ mMaterial = aMaterial == null ? null : new GregtechMaterialStack(aMaterial, aPrefix.mMaterialAmount);
+ mBlackListed = aBlackListed;
+ mByProducts = aPrefix.mSecondaryMaterial == null || aPrefix.mSecondaryMaterial.mMaterial == null ? EMPTY_GT_MaterialStack_ARRAY : new GregtechMaterialStack[]{aPrefix.mSecondaryMaterial.clone()};
+ }
+
+ public GregtechItemData(GregtechOrePrefixes aPrefix, GT_Materials aMaterial) {
+ this(aPrefix, aMaterial, false);
+ }
+
+ public GregtechItemData(GregtechMaterialStack aMaterial, GregtechMaterialStack... aByProducts) {
+ mPrefix = null;
+ mMaterial = aMaterial.mMaterial == null ? null : aMaterial.clone();
+ mBlackListed = true;
+ if (aByProducts == null) {
+ mByProducts = EMPTY_GT_MaterialStack_ARRAY;
+ } else {
+ GregtechMaterialStack[] tByProducts = aByProducts.length < 1 ? EMPTY_GT_MaterialStack_ARRAY : new GregtechMaterialStack[aByProducts.length];
+ int j = 0;
+ for (int i = 0; i < aByProducts.length; i++)
+ if (aByProducts[i] != null && aByProducts[i].mMaterial != null)
+ tByProducts[j++] = aByProducts[i].clone();
+ mByProducts = j > 0 ? new GregtechMaterialStack[j] : EMPTY_GT_MaterialStack_ARRAY;
+ for (int i = 0; i < mByProducts.length; i++) mByProducts[i] = tByProducts[i];
+ }
+ }
+
+ public GregtechItemData(GT_Materials aMaterial, long aAmount, GregtechMaterialStack... aByProducts) {
+ this(new GregtechMaterialStack(aMaterial, aAmount), aByProducts);
+ }
+
+ public GregtechItemData(GT_Materials aMaterial, long aAmount, GT_Materials aByProduct, long aByProductAmount) {
+ this(new GregtechMaterialStack(aMaterial, aAmount), new GregtechMaterialStack(aByProduct, aByProductAmount));
+ }
+
+ public GregtechItemData(GregtechItemData... aData) {
+ mPrefix = null;
+ mBlackListed = true;
+
+ ArrayList<GregtechMaterialStack> aList = new ArrayList<GregtechMaterialStack>(), rList = new ArrayList<GregtechMaterialStack>();
+
+ for (GregtechItemData tData : aData)
+ if (tData != null) {
+ if (tData.hasValidMaterialData() && tData.mMaterial.mAmount > 0) aList.add(tData.mMaterial.clone());
+ for (GregtechMaterialStack tMaterial : tData.mByProducts)
+ if (tMaterial.mAmount > 0) aList.add(tMaterial.clone());
+ }
+
+ for (GregtechMaterialStack aMaterial : aList) {
+ boolean temp = true;
+ for (GregtechMaterialStack tMaterial : rList)
+ if (aMaterial.mMaterial == tMaterial.mMaterial) {
+ tMaterial.mAmount += aMaterial.mAmount;
+ temp = false;
+ break;
+ }
+ if (temp) rList.add(aMaterial.clone());
+ }
+
+ Collections.sort(rList, new Comparator<GregtechMaterialStack>() {
+ @Override
+ public int compare(GregtechMaterialStack a, GregtechMaterialStack b) {
+ return a.mAmount == b.mAmount ? 0 : a.mAmount > b.mAmount ? -1 : +1;
+ }
+ });
+
+ if (rList.isEmpty()) {
+ mMaterial = null;
+ } else {
+ mMaterial = rList.get(0);
+ rList.remove(0);
+ }
+
+ mByProducts = rList.toArray(new GregtechMaterialStack[rList.size()]);
+ }
+
+ public boolean hasValidPrefixMaterialData() {
+ return mPrefix != null && mMaterial != null && mMaterial.mMaterial != null;
+ }
+
+ public boolean hasValidPrefixData() {
+ return mPrefix != null;
+ }
+
+ public boolean hasValidMaterialData() {
+ return mMaterial != null && mMaterial.mMaterial != null;
+ }
+
+ public ArrayList<GregtechMaterialStack> getAllGT_MaterialStacks() {
+ ArrayList<GregtechMaterialStack> rList = new ArrayList();
+ if (hasValidMaterialData()) rList.add(mMaterial);
+ rList.addAll(Arrays.asList(mByProducts));
+ return rList;
+ }
+
+ public GregtechMaterialStack getByProduct(int aIndex) {
+ return aIndex >= 0 && aIndex < mByProducts.length ? mByProducts[aIndex] : null;
+ }
+
+ @Override
+ public String toString() {
+ if (mPrefix == null || mMaterial == null || mMaterial.mMaterial == null) return "";
+ return mPrefix.name() + mMaterial.mMaterial.name();
+ }
+} \ No newline at end of file
diff --git a/src/Java/miscutil/gregtech/api/util/GregtechOreDictUnificator.java b/src/Java/miscutil/gregtech/api/util/GregtechOreDictUnificator.java
index 60b8be6dcd..6f24217110 100644
--- a/src/Java/miscutil/gregtech/api/util/GregtechOreDictUnificator.java
+++ b/src/Java/miscutil/gregtech/api/util/GregtechOreDictUnificator.java
@@ -12,6 +12,7 @@ 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;
@@ -227,7 +228,7 @@ public class GregtechOreDictUnificator {
return false;
}
- public static boolean registerOre(OrePrefixes aPrefix, Object aMaterial, ItemStack aStack) {
+ public static boolean registerOre(GregtechOrePrefixes aPrefix, Object aMaterial, ItemStack aStack) {
return registerOre(aPrefix.get(aMaterial), aStack);
}
@@ -357,4 +358,9 @@ public class GregtechOreDictUnificator {
if (GT_Utility.isStringValid(aName)) rList.addAll(OreDictionary.getOres(aName));
return rList;
}
+
+ public static void registerRecipes(OreDictEventContainer tOre) {
+ // TODO Auto-generated method stub
+
+ }
}