aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util/recipe
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-11-06 19:32:27 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-11-06 19:32:27 +1000
commitcbe0e497be8e466c380a5b4fa781b314ede9ada3 (patch)
treeb85848b432adf458e3abda466ee46d9dfc3e454b /src/Java/gtPlusPlus/core/util/recipe
parentc40416b036c0e89451e1558253ccf07bbee028d0 (diff)
downloadGT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.tar.gz
GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.tar.bz2
GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.zip
Revert "$ Cleaned up the entire project."
This reverts commit 0669f5eb9d5029a8b94ec552171b0837605f7747. # Conflicts: # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java Revert "% Cleaned up Imports." This reverts commit 3654052fb63a571c5eaca7f20714b87c17f7e966.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/recipe')
-rw-r--r--src/Java/gtPlusPlus/core/util/recipe/RecipeUtils.java648
-rw-r--r--src/Java/gtPlusPlus/core/util/recipe/shapeless/ShapelessUtils.java46
2 files changed, 294 insertions, 400 deletions
diff --git a/src/Java/gtPlusPlus/core/util/recipe/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/recipe/RecipeUtils.java
index 82ed05db2a..39a118e440 100644
--- a/src/Java/gtPlusPlus/core/util/recipe/RecipeUtils.java
+++ b/src/Java/gtPlusPlus/core/util/recipe/RecipeUtils.java
@@ -1,8 +1,5 @@
package gtPlusPlus.core.util.recipe;
-import java.util.*;
-
-import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.util.GT_ModHandler;
import gtPlusPlus.core.handler.COMPAT_HANDLER;
import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler;
@@ -11,245 +8,102 @@ import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.item.ItemUtils;
import gtPlusPlus.core.util.recipe.shapeless.ShapelessUtils;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
-import net.minecraftforge.oredict.*;
+import net.minecraftforge.oredict.OreDictionary;
+import net.minecraftforge.oredict.ShapedOreRecipe;
+import net.minecraftforge.oredict.ShapelessOreRecipe;
+import cpw.mods.fml.common.registry.GameRegistry;
public class RecipeUtils {
- public static boolean addShapedGregtechRecipe(final Object InputItem1, final Object InputItem2,
- final Object InputItem3, final Object InputItem4, final Object InputItem5, final Object InputItem6,
- final Object InputItem7, final Object InputItem8, final Object InputItem9, final ItemStack OutputItem) {
-
- if (!(InputItem1 instanceof ItemStack) && !(InputItem1 instanceof String) && InputItem1 != null
- || !(InputItem2 instanceof ItemStack) && !(InputItem2 instanceof String) && InputItem2 != null
- || !(InputItem3 instanceof ItemStack) && !(InputItem3 instanceof String) && InputItem3 != null
- || !(InputItem4 instanceof ItemStack) && !(InputItem4 instanceof String) && InputItem4 != null
- || !(InputItem5 instanceof ItemStack) && !(InputItem5 instanceof String) && InputItem5 != null
- || !(InputItem6 instanceof ItemStack) && !(InputItem6 instanceof String) && InputItem6 != null
- || !(InputItem7 instanceof ItemStack) && !(InputItem7 instanceof String) && InputItem7 != null
- || !(InputItem8 instanceof ItemStack) && !(InputItem8 instanceof String) && InputItem8 != null
- || !(InputItem9 instanceof ItemStack) && !(InputItem9 instanceof String) && InputItem9 != null) {
- Utils.LOG_INFO("One Input item was not an ItemStack of an OreDict String.");
- return false;
- }
-
- if (GT_ModHandler.addCraftingRecipe(OutputItem,
- GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE
- | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED,
- new Object[] {
- "ABC", "DEF", "GHI", 'A', InputItem1, 'B', InputItem2, 'C', InputItem3, 'D', InputItem4, 'E',
- InputItem5, 'F', InputItem6, 'G', InputItem7, 'H', InputItem8, 'I', InputItem9
- })) {
- Utils.LOG_INFO("Success! Added a recipe for " + OutputItem.getDisplayName());
- RegistrationHandler.recipesSuccess++;
- return true;
- }
- return false;
- }
-
- public static void addShapelessGregtechRecipe(final ItemStack OutputItem, final Object... inputItems) {
-
- for (final Object whatever : inputItems) {
- if (!(whatever instanceof ItemStack) && !(whatever instanceof String)) {
- Utils.LOG_INFO("One Input item was not an ItemStack of an OreDict String.");
- return;
- }
- }
-
- GT_ModHandler.addShapelessCraftingRecipe(OutputItem,
- GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[] {
- inputItems
- });
- }
-
- private static boolean attemptRecipeRemoval(final Item I) {
- Utils.LOG_WARNING("Create list of recipes.");
- final List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
- final Iterator<IRecipe> items = recipes.iterator();
- Utils.LOG_WARNING("Begin list iteration.");
- while (items.hasNext()) {
- final ItemStack is = items.next().getRecipeOutput();
- if (is != null && is.getItem() == I) {
- items.remove();
- Utils.LOG_INFO("Remove a recipe with " + I.getUnlocalizedName() + " as output.");
- continue;
- }
- }
- Utils.LOG_WARNING("All recipes should be gone?");
- if (!items.hasNext()) {
- Utils.LOG_WARNING("We iterated once, let's try again to double check.");
- final Iterator<IRecipe> items2 = recipes.iterator();
- while (items2.hasNext()) {
- final ItemStack is = items2.next().getRecipeOutput();
- if (is != null && is.getItem() == I) {
- items.remove();
- Utils.LOG_WARNING("REMOVING MISSED RECIPE - RECHECK CONSTRUCTORS");
- return true;
- }
- }
- Utils.LOG_WARNING("Should be all gone now after double checking, so return true.");
- return true;
- }
- Utils.LOG_INFO("Return false, because something went wrong.");
- return false;
- }
-
- public static boolean buildShapelessRecipe(final ItemStack output, final Object[] input) {
- return ShapelessUtils.addShapelessRecipe(output, input);
- }
+ public static boolean recipeBuilder(Object slot_1, Object slot_2, Object slot_3, Object slot_4, Object slot_5, Object slot_6, Object slot_7, Object slot_8, Object slot_9, ItemStack resultItem){
- public static ItemStack getItemStackFromOreDict(final String oredictName) {
- final ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName);
- return oreDictList.get(0);
- }
+ ArrayList<Object> validSlots = new ArrayList<Object>();
- public static boolean recipeBuilder(final Object slot_1, final Object slot_2, final Object slot_3,
- final Object slot_4, final Object slot_5, final Object slot_6, final Object slot_7, final Object slot_8,
- final Object slot_9, final ItemStack resultItem) {
-
- final ArrayList<Object> validSlots = new ArrayList<Object>();
-
- Utils.LOG_INFO("Trying to add a recipe for " + resultItem.toString());
- String a, b, c, d, e, f, g, h, i;
- if (slot_1 == null) {
- a = " ";
- }
- else {
- a = "1";
- validSlots.add('1');
- validSlots.add(slot_1);
- }
+ Utils.LOG_INFO("Trying to add a recipe for "+resultItem.toString());
+ String a,b,c,d,e,f,g,h,i;
+ if (slot_1 == null){ a = " ";} else { a = "1";validSlots.add('1');validSlots.add(slot_1);}
Utils.LOG_WARNING(a);
- if (slot_2 == null) {
- b = " ";
- }
- else {
- b = "2";
- validSlots.add('2');
- validSlots.add(slot_2);
- }
+ if (slot_2 == null){ b = " ";} else { b = "2";validSlots.add('2');validSlots.add(slot_2);}
Utils.LOG_WARNING(b);
- if (slot_3 == null) {
- c = " ";
- }
- else {
- c = "3";
- validSlots.add('3');
- validSlots.add(slot_3);
- }
+ if (slot_3 == null){ c = " ";} else { c = "3";validSlots.add('3');validSlots.add(slot_3);}
Utils.LOG_WARNING(c);
- if (slot_4 == null) {
- d = " ";
- }
- else {
- d = "4";
- validSlots.add('4');
- validSlots.add(slot_4);
- }
+ if (slot_4 == null){ d = " ";} else { d = "4";validSlots.add('4');validSlots.add(slot_4);}
Utils.LOG_WARNING(d);
- if (slot_5 == null) {
- e = " ";
- }
- else {
- e = "5";
- validSlots.add('5');
- validSlots.add(slot_5);
- }
+ if (slot_5 == null){ e = " ";} else { e = "5";validSlots.add('5');validSlots.add(slot_5);}
Utils.LOG_WARNING(e);
- if (slot_6 == null) {
- f = " ";
- }
- else {
- f = "6";
- validSlots.add('6');
- validSlots.add(slot_6);
- }
+ if (slot_6 == null){ f = " ";} else { f = "6";validSlots.add('6');validSlots.add(slot_6);}
Utils.LOG_WARNING(f);
- if (slot_7 == null) {
- g = " ";
- }
- else {
- g = "7";
- validSlots.add('7');
- validSlots.add(slot_7);
- }
+ if (slot_7 == null){ g = " ";} else { g = "7";validSlots.add('7');validSlots.add(slot_7);}
Utils.LOG_WARNING(g);
- if (slot_8 == null) {
- h = " ";
- }
- else {
- h = "8";
- validSlots.add('8');
- validSlots.add(slot_8);
- }
+ if (slot_8 == null){ h = " ";} else { h = "8";validSlots.add('8');validSlots.add(slot_8);}
Utils.LOG_WARNING(h);
- if (slot_9 == null) {
- i = " ";
- }
- else {
- i = "9";
- validSlots.add('9');
- validSlots.add(slot_9);
- }
+ if (slot_9 == null){ i = " ";} else { i = "9";validSlots.add('9');validSlots.add(slot_9);}
Utils.LOG_WARNING(i);
+
Utils.LOG_ERROR("_______");
- final String lineOne = a + b + c;
- Utils.LOG_ERROR("|" + a + "|" + b + "|" + c + "|");
+ String lineOne = a+b+c;
+ Utils.LOG_ERROR("|"+a+"|"+b+"|"+c+"|");
Utils.LOG_ERROR("_______");
- final String lineTwo = d + e + f;
- Utils.LOG_ERROR("|" + d + "|" + e + "|" + f + "|");
+ String lineTwo = d+e+f;
+ Utils.LOG_ERROR("|"+d+"|"+e+"|"+f+"|");
Utils.LOG_ERROR("_______");
- final String lineThree = g + h + i;
- Utils.LOG_ERROR("|" + g + "|" + h + "|" + i + "|");
+ String lineThree = g+h+i;
+ Utils.LOG_ERROR("|"+g+"|"+h+"|"+i+"|");
Utils.LOG_ERROR("_______");
validSlots.add(0, lineOne);
validSlots.add(1, lineTwo);
validSlots.add(2, lineThree);
boolean advancedLog = false;
- if (CORE.DEBUG) {
+ if (CORE.DEBUG){
advancedLog = true;
- }
- if (advancedLog) {
+ }
+ if (advancedLog){
int j = 0;
- final int l = validSlots.size();
- Utils.LOG_WARNING("l:" + l);
+ int l = validSlots.size();
+ Utils.LOG_WARNING("l:"+l);
while (j <= l) {
- Utils.LOG_WARNING("j:" + j);
- if (j <= 2) {
- Utils.LOG_WARNING("ArrayList Values: " + validSlots.get(j));
+ Utils.LOG_WARNING("j:"+j);
+ if (j <= 2){
+ Utils.LOG_WARNING("ArrayList Values: "+validSlots.get(j));
Utils.LOG_WARNING("Adding 1.");
j++;
}
- else if (j >= 3) {
- Utils.LOG_WARNING("ArrayList Values: '" + validSlots.get(j) + "' " + validSlots.get(j + 1));
- if (j < l - 2) {
+ else if (j >= 3){
+ Utils.LOG_WARNING("ArrayList Values: '"+validSlots.get(j)+"' "+validSlots.get(j+1));
+ if (j < (l-2)){
Utils.LOG_WARNING("Adding 2.");
- j = j + 2;
+ j=j+2;
}
else {
Utils.LOG_WARNING("Done iteration.");
break;
}
}
- else if (j == l) {
+ else if (j == l){
Utils.LOG_WARNING("Done iteration.");
break;
}
- if (validSlots.get(j) instanceof String || validSlots.get(j) instanceof ItemStack) {
- // Utils.LOG_WARNING("Is Valid: "+validSlots.get(j));
+ if (validSlots.get(j) instanceof String || validSlots.get(j) instanceof ItemStack){
+ //Utils.LOG_WARNING("Is Valid: "+validSlots.get(j));
}
- }
+ }
}
try {
- GameRegistry.addRecipe(new ShapedOreRecipe(resultItem.copy(), validSlots.toArray()));
- Utils.LOG_INFO("Success! Added a recipe for " + resultItem.getDisplayName());
- if (!COMPAT_HANDLER.areInitItemsLoaded) {
+ GameRegistry.addRecipe(new ShapedOreRecipe(resultItem.copy(), (Object[]) validSlots.toArray()));
+ Utils.LOG_INFO("Success! Added a recipe for "+resultItem.getDisplayName());
+ if (!COMPAT_HANDLER.areInitItemsLoaded){
RegistrationHandler.recipesSuccess++;
}
else {
@@ -257,210 +111,55 @@ public class RecipeUtils {
}
return true;
}
- catch (NullPointerException | ClassCastException k) {
+ catch(NullPointerException | ClassCastException k){
k.getMessage();
k.getClass();
k.printStackTrace();
k.getLocalizedMessage();
- Utils.LOG_WARNING("@@@: Invalid Recipe detected for: " + resultItem.getUnlocalizedName());
- if (!COMPAT_HANDLER.areInitItemsLoaded) {
+ Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+resultItem.getUnlocalizedName());
+ if (!COMPAT_HANDLER.areInitItemsLoaded){
RegistrationHandler.recipesFailed++;
}
else {
LateRegistrationHandler.recipesFailed++;
- }
+ }
return false;
}
}
- public static void recipeBuilder(final Object[] array, final ItemStack outPut) {
- Utils.LOG_SPECIFIC_WARNING("object Array - recipeBuilder",
- "Attempting to build a recipe using an object array as an input, splitting it, then running the normal recipeBuilder() method.",
- 396);
- Object a = null;
- Object b = null;
- Object c = null;
- Object d = null;
- Object e = null;
- Object f = null;
- Object g = null;
- Object h = null;
- Object i = null;
- for (int z = 0; z <= array.length; z++) {
- array[z].toString();
- switch (z) {
- case 0:
- a = array[z];
- break;
- case 1:
- b = array[z];
- break;
- case 2:
- c = array[z];
- break;
- case 3:
- d = array[z];
- break;
- case 4:
- e = array[z];
- break;
- case 5:
- f = array[z];
- break;
- case 6:
- g = array[z];
- break;
- case 7:
- h = array[z];
- break;
- case 8:
- i = array[z];
- break;
- default:
- break;
- }
- RecipeUtils.recipeBuilder(a, b, c, d, e, f, g, h, i, outPut);
- }
- }
+ public static void shapelessBuilder(ItemStack Output, Object slot_1, Object slot_2, Object slot_3, Object slot_4, Object slot_5, Object slot_6, Object slot_7, Object slot_8, Object slot_9){
+ //Item output_ITEM = Output.getItem();
- public static boolean removeCraftingRecipe(Object x) {
- if (null == x) {
- return false;
- }
- if (x instanceof String) {
- final Item R = ItemUtils.getItem((String) x);
- if (R != null) {
- x = R;
- }
- else {
- return false;
- }
- }
- if (x instanceof Item || x instanceof ItemStack) {
- if (x instanceof Item) {
- final ItemStack r = new ItemStack((Item) x);
- Utils.LOG_INFO("Removing Recipe for " + r.getUnlocalizedName());
- }
- else {
- Utils.LOG_INFO("Removing Recipe for " + ((ItemStack) x).getUnlocalizedName());
- }
- if (x instanceof ItemStack) {
- final Item r = ((ItemStack) x).getItem();
- if (null != r) {
- x = r;
- }
- else {
- Utils.LOG_INFO("Recipe removal failed - Tell Alkalus.");
- return false;
- }
- }
- if (RecipeUtils.attemptRecipeRemoval((Item) x)) {
- Utils.LOG_INFO("Recipe removal successful");
- return true;
- }
- Utils.LOG_INFO("Recipe removal failed - Tell Alkalus.");
- return false;
- }
- return false;
- }
-
- public static void shapelessBuilder(final ItemStack Output, final Object slot_1, final Object slot_2,
- final Object slot_3, final Object slot_4, final Object slot_5, final Object slot_6, final Object slot_7,
- final Object slot_8, final Object slot_9) {
- // Item output_ITEM = Output.getItem();
-
- final ArrayList<Object> validSlots = new ArrayList<Object>();
+ ArrayList<Object> validSlots = new ArrayList<Object>();
- Utils.LOG_INFO("Trying to add a recipe for " + Output.toString());
- String a, b, c, d, e, f, g, h, i;
- if (slot_1 == null) {
- a = " ";
- }
- else {
- a = "1";
- validSlots.add('1');
- validSlots.add(slot_1);
- }
+ Utils.LOG_INFO("Trying to add a recipe for "+Output.toString());
+ String a,b,c,d,e,f,g,h,i;
+ if (slot_1 == null){ a = " ";} else { a = "1";validSlots.add('1');validSlots.add(slot_1);}
Utils.LOG_WARNING(a);
- if (slot_2 == null) {
- b = " ";
- }
- else {
- b = "2";
- validSlots.add('2');
- validSlots.add(slot_2);
- }
+ if (slot_2 == null){ b = " ";} else { b = "2";validSlots.add('2');validSlots.add(slot_2);}
Utils.LOG_WARNING(b);
- if (slot_3 == null) {
- c = " ";
- }
- else {
- c = "3";
- validSlots.add('3');
- validSlots.add(slot_3);
- }
+ if (slot_3 == null){ c = " ";} else { c = "3";validSlots.add('3');validSlots.add(slot_3);}
Utils.LOG_WARNING(c);
- if (slot_4 == null) {
- d = " ";
- }
- else {
- d = "4";
- validSlots.add('4');
- validSlots.add(slot_4);
- }
+ if (slot_4 == null){ d = " ";} else { d = "4";validSlots.add('4');validSlots.add(slot_4);}
Utils.LOG_WARNING(d);
- if (slot_5 == null) {
- e = " ";
- }
- else {
- e = "5";
- validSlots.add('5');
- validSlots.add(slot_5);
- }
+ if (slot_5 == null){ e = " ";} else { e = "5";validSlots.add('5');validSlots.add(slot_5);}
Utils.LOG_WARNING(e);
- if (slot_6 == null) {
- f = " ";
- }
- else {
- f = "6";
- validSlots.add('6');
- validSlots.add(slot_6);
- }
+ if (slot_6 == null){ f = " ";} else { f = "6";validSlots.add('6');validSlots.add(slot_6);}
Utils.LOG_WARNING(f);
- if (slot_7 == null) {
- g = " ";
- }
- else {
- g = "7";
- validSlots.add('7');
- validSlots.add(slot_7);
- }
+ if (slot_7 == null){ g = " ";} else { g = "7";validSlots.add('7');validSlots.add(slot_7);}
Utils.LOG_WARNING(g);
- if (slot_8 == null) {
- h = " ";
- }
- else {
- h = "8";
- validSlots.add('8');
- validSlots.add(slot_8);
- }
+ if (slot_8 == null){ h = " ";} else { h = "8";validSlots.add('8');validSlots.add(slot_8);}
Utils.LOG_WARNING(h);
- if (slot_9 == null) {
- i = " ";
- }
- else {
- i = "9";
- validSlots.add('9');
- validSlots.add(slot_9);
- }
+ if (slot_9 == null){ i = " ";} else { i = "9";validSlots.add('9');validSlots.add(slot_9);}
Utils.LOG_WARNING(i);
+
Utils.LOG_ERROR("_______");
- Utils.LOG_ERROR("|" + a + "|" + b + "|" + c + "|");
+ Utils.LOG_ERROR("|"+a+"|"+b+"|"+c+"|");
Utils.LOG_ERROR("_______");
- Utils.LOG_ERROR("|" + d + "|" + e + "|" + f + "|");
+ Utils.LOG_ERROR("|"+d+"|"+e+"|"+f+"|");
Utils.LOG_ERROR("_______");
- Utils.LOG_ERROR("|" + g + "|" + h + "|" + i + "|");
+ Utils.LOG_ERROR("|"+g+"|"+h+"|"+i+"|");
Utils.LOG_ERROR("_______");
validSlots.add(0, a);
@@ -474,25 +173,210 @@ public class RecipeUtils {
validSlots.add(8, i);
try {
- // GameRegistry.addRecipe(new ShapelessOreRecipe(Output,
- // outputAmount), (Object[]) validSlots.toArray());
- GameRegistry.addRecipe(new ShapelessOreRecipe(Output, validSlots.toArray()));
- // GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1),
- // new Object[] {slot_1, slot_2});
- Utils.LOG_INFO("Success! Added a recipe for " + Output.getDisplayName());
- RegistrationHandler.recipesSuccess++;
+ //GameRegistry.addRecipe(new ShapelessOreRecipe(Output, outputAmount), (Object[]) validSlots.toArray());
+ GameRegistry.addRecipe(new ShapelessOreRecipe(Output, (Object[]) validSlots.toArray()));
+ //GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2});
+ Utils.LOG_INFO("Success! Added a recipe for "+Output.getDisplayName());
+ RegistrationHandler.recipesSuccess++;
}
- catch (final RuntimeException k) {
+ catch(RuntimeException k){
k.getMessage();
k.getClass();
k.printStackTrace();
k.getLocalizedMessage();
- Utils.LOG_WARNING("@@@: Invalid Recipe detected for: " + Output.getUnlocalizedName());
+ Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+Output.getUnlocalizedName());
RegistrationHandler.recipesFailed++;
}
- // GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new
- // Object[] {slot_1, slot_2});
+
+ //GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2});
+ }
+
+ public static void recipeBuilder(Object[] array, ItemStack outPut) {
+ Utils.LOG_SPECIFIC_WARNING("object Array - recipeBuilder", "Attempting to build a recipe using an object array as an input, splitting it, then running the normal recipeBuilder() method.", 396);
+ Object a=null;
+ Object b=null;
+ Object c=null;
+ Object d=null;
+ Object e=null;
+ Object f=null;
+ Object g=null;
+ Object h=null;
+ Object i=null;
+ for(int z =0; z <= array.length; z++){
+ array[z].toString();
+ switch(z)
+ {
+ case 0:
+ a = array[z];
+ break;
+ case 1:
+ b = array[z];
+ break;
+ case 2:
+ c = array[z];
+ break;
+ case 3:
+ d = array[z];
+ break;
+ case 4:
+ e = array[z];
+ break;
+ case 5:
+ f = array[z];
+ break;
+ case 6:
+ g = array[z];
+ break;
+ case 7:
+ h = array[z];
+ break;
+ case 8:
+ i = array[z];
+ break;
+ default:
+ break;
+ }
+ recipeBuilder(a, b, c, d, e, f, g, h, i, outPut);
+ }
+ }
+
+ public static boolean removeCraftingRecipe(Object x){
+ if (null == x){return false;}
+ if (x instanceof String){
+ Item R = ItemUtils.getItem((String) x);
+ if (R != null){
+ x = R;
+ }
+ else {
+ return false;
+ }
+ }
+ if (x instanceof Item || x instanceof ItemStack){
+ if (x instanceof Item){
+ ItemStack r = new ItemStack((Item) x);
+ Utils.LOG_INFO("Removing Recipe for "+r.getUnlocalizedName());
+ }
+ else {
+ Utils.LOG_INFO("Removing Recipe for "+((ItemStack) x).getUnlocalizedName());
+ }
+ if (x instanceof ItemStack){
+ Item r = ((ItemStack) x).getItem();
+ if (null != r){
+ x = r;
+ }
+ else {
+ Utils.LOG_INFO("Recipe removal failed - Tell Alkalus.");
+ return false;
+ }
+ }
+ if (RecipeUtils.attemptRecipeRemoval((Item) x)){
+ Utils.LOG_INFO("Recipe removal successful");
+ return true;
+ }
+ Utils.LOG_INFO("Recipe removal failed - Tell Alkalus.");
+ return false;
+ }
+ return false;
+ }
+
+ private static boolean attemptRecipeRemoval(Item I){
+ Utils.LOG_WARNING("Create list of recipes.");
+ List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
+ Iterator<IRecipe> items = recipes.iterator();
+ Utils.LOG_WARNING("Begin list iteration.");
+ while (items.hasNext()) {
+ ItemStack is = items.next().getRecipeOutput();
+ if (is != null && is.getItem() == I){
+ items.remove();
+ Utils.LOG_INFO("Remove a recipe with "+I.getUnlocalizedName()+" as output.");
+ continue;
+ }
+ }
+ Utils.LOG_WARNING("All recipes should be gone?");
+ if (!items.hasNext()){
+ Utils.LOG_WARNING("We iterated once, let's try again to double check.");
+ Iterator<IRecipe> items2 = recipes.iterator();
+ while (items2.hasNext()) {
+ ItemStack is = items2.next().getRecipeOutput();
+ if (is != null && is.getItem() == I){
+ items.remove();
+ Utils.LOG_WARNING("REMOVING MISSED RECIPE - RECHECK CONSTRUCTORS");
+ return true;
+ }
+ }
+ Utils.LOG_WARNING("Should be all gone now after double checking, so return true.");
+ return true;
+ }
+ Utils.LOG_INFO("Return false, because something went wrong.");
+ return false;
+ }
+
+
+
+
+
+
+ public static boolean addShapedGregtechRecipe(
+ Object InputItem1, Object InputItem2, Object InputItem3,
+ Object InputItem4, Object InputItem5, Object InputItem6,
+ Object InputItem7, Object InputItem8, Object InputItem9,
+ ItemStack OutputItem){
+
+ if ((!(InputItem1 instanceof ItemStack) && !(InputItem1 instanceof String) && (InputItem1 != null)) ||
+ (!(InputItem2 instanceof ItemStack) && !(InputItem2 instanceof String) && (InputItem2 != null)) ||
+ (!(InputItem3 instanceof ItemStack) && !(InputItem3 instanceof String) && (InputItem3 != null)) ||
+ (!(InputItem4 instanceof ItemStack) && !(InputItem4 instanceof String) && (InputItem4 != null)) ||
+ (!(InputItem5 instanceof ItemStack) && !(InputItem5 instanceof String) && (InputItem5 != null)) ||
+ (!(InputItem6 instanceof ItemStack) && !(InputItem6 instanceof String) && (InputItem6 != null)) ||
+ (!(InputItem7 instanceof ItemStack) && !(InputItem7 instanceof String) && (InputItem7 != null)) ||
+ (!(InputItem8 instanceof ItemStack) && !(InputItem8 instanceof String) && (InputItem8 != null)) ||
+ (!(InputItem9 instanceof ItemStack) && !(InputItem9 instanceof String) && (InputItem9 != null))){
+ Utils.LOG_INFO("One Input item was not an ItemStack of an OreDict String.");
+ return false;
+ }
+
+ if (GT_ModHandler.addCraftingRecipe(OutputItem,
+ GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE |
+ GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED,
+ new Object[]{"ABC", "DEF", "GHI",
+ 'A', InputItem1,
+ 'B', InputItem2,
+ 'C', InputItem3,
+ 'D', InputItem4,
+ 'E', InputItem5,
+ 'F', InputItem6,
+ 'G', InputItem7,
+ 'H', InputItem8,
+ 'I', InputItem9})){
+ Utils.LOG_INFO("Success! Added a recipe for "+OutputItem.getDisplayName());
+ RegistrationHandler.recipesSuccess++;
+ return true;
+ }
+ return false;
+ }
+
+ public static void addShapelessGregtechRecipe(ItemStack OutputItem, Object... inputItems){
+
+ for(Object whatever : inputItems){
+ if (!(whatever instanceof ItemStack) && !(whatever instanceof String)){
+ Utils.LOG_INFO("One Input item was not an ItemStack of an OreDict String.");
+ return;
+ }
+ }
+
+ GT_ModHandler.addShapelessCraftingRecipe(OutputItem,
+ GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE,
+ new Object[]{inputItems});
+ }
+
+ public static ItemStack getItemStackFromOreDict(String oredictName){
+ ArrayList<ItemStack> oreDictList = OreDictionary.getOres(oredictName);
+ return oreDictList.get(0);
+ }
+
+ public static boolean buildShapelessRecipe(ItemStack output, Object[] input){
+ return ShapelessUtils.addShapelessRecipe(output, input);
}
}
diff --git a/src/Java/gtPlusPlus/core/util/recipe/shapeless/ShapelessUtils.java b/src/Java/gtPlusPlus/core/util/recipe/shapeless/ShapelessUtils.java
index 812cfa626d..bf9d4960d8 100644
--- a/src/Java/gtPlusPlus/core/util/recipe/shapeless/ShapelessUtils.java
+++ b/src/Java/gtPlusPlus/core/util/recipe/shapeless/ShapelessUtils.java
@@ -1,8 +1,9 @@
package gtPlusPlus.core.util.recipe.shapeless;
+import gtPlusPlus.core.util.Utils;
+
import java.util.ArrayList;
-import gtPlusPlus.core.util.Utils;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -11,36 +12,45 @@ import net.minecraft.item.crafting.ShapelessRecipes;
public class ShapelessUtils {
- public static boolean addShapelessRecipe(final ItemStack output, final Object... params) {
- final ArrayList<ItemStack> arraylist = new ArrayList<ItemStack>();
- final Object[] aobject = params;
- final int i = params.length;
- for (int j = 0; j < i; ++j) {
- final Object object1 = aobject[j];
+ public static boolean addShapelessRecipe(ItemStack output, Object ... params)
+ {
+ ArrayList<ItemStack> arraylist = new ArrayList<ItemStack>();
+ Object[] aobject = params;
+ int i = params.length;
- if (object1 instanceof ItemStack) {
- arraylist.add(((ItemStack) object1).copy());
+ for (int j = 0; j < i; ++j)
+ {
+ Object object1 = aobject[j];
+
+ if (object1 instanceof ItemStack)
+ {
+ arraylist.add(((ItemStack)object1).copy());
}
- else if (object1 instanceof Item) {
- arraylist.add(new ItemStack((Item) object1));
+ else if (object1 instanceof Item)
+ {
+ arraylist.add(new ItemStack((Item)object1));
}
- else {
- if (object1 == null) {
- Utils.LOG_INFO("Invalid shapeless input, ignoring!");
+ else
+ {
+ if ((object1 == null))
+ {
+ Utils.LOG_INFO(("Invalid shapeless input, ignoring!"));
}
- else if (!(object1 instanceof Block) && object1 != null) {
- Utils.LOG_INFO("Invalid shapeless recipe!");
+ else if (!(object1 instanceof Block) && (object1 != null))
+ {
+ Utils.LOG_INFO(("Invalid shapeless recipe!"));
return false;
}
else {
- arraylist.add(new ItemStack((Block) object1));
+ arraylist.add(new ItemStack((Block)object1));
}
}
}
CraftingManager.getInstance().getRecipeList().add(new ShapelessRecipes(output, arraylist));
- // CraftingManager.getInstance().addShapelessRecipe(output, arraylist);
+ //CraftingManager.getInstance().addShapelessRecipe(output, arraylist);
return true;
}
+
}