aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus')
-rw-r--r--src/Java/gtPlusPlus/api/objects/Logger.java1
-rw-r--r--src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java85
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java95
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java13
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java2
5 files changed, 87 insertions, 109 deletions
diff --git a/src/Java/gtPlusPlus/api/objects/Logger.java b/src/Java/gtPlusPlus/api/objects/Logger.java
index 672cb52304..6f6224332c 100644
--- a/src/Java/gtPlusPlus/api/objects/Logger.java
+++ b/src/Java/gtPlusPlus/api/objects/Logger.java
@@ -141,6 +141,7 @@ public class Logger {
}
public static void RECIPE(String string) {
+ if (CORE.DEVENV || CORE.DEBUG)
modLogger.info("[Recipe] "+string);
}
diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java b/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java
index 64f486b23e..f113a67996 100644
--- a/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java
+++ b/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java
@@ -3,7 +3,6 @@ package gtPlusPlus.api.objects.minecraft;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.data.AutoMap;
import gtPlusPlus.api.objects.data.Pair;
-import gtPlusPlus.core.util.reflect.ReflectionUtils;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.ShapedOreRecipe;
@@ -28,20 +27,39 @@ public class ShapedRecipe {
char[] aChar = new char[9];
String[] aLoggingInfo = new String[9];
+
+
//Just to be safe
try {
-
+ Logger.RECIPE("======== B R E A K P O I N T =========");
+ int xSlot = 0;
+ int xNull = 0;
+ for (Object u : aInputs) {
+ String mInfo = "";
+ if (u instanceof String) {
+ mInfo = (String) u;
+ Logger.RECIPE("Input slot "+xSlot+++" contains "+mInfo);
+ }
+ else if (u instanceof ItemStack) {
+ mInfo = ((ItemStack) u).getDisplayName();
+ Logger.RECIPE("Input slot "+xSlot+++" contains "+mInfo);
+ }
+ else if (u == null) {
+ xNull++;
+ }
+ }
+ Logger.RECIPE("Found "+xNull+" null inputs.");
//Check if the output is invalid
- if (aOutput != null) {
+ if (aOutput != null && xNull < 9) {
Object[] mVarags2 = null;
Logger.RECIPE("Generating Shaped Crafting Recipe for "+aOutput.getDisplayName());
if (aInputs.length < 9 || aInputs.length > 9) {
- Logger.RECIPE("[1234abcd] Recipe for "+aOutput.getDisplayName()+" has incorrect number of inputs. Size: "+aInputs.length+".");
- Logger.RECIPE("[1234abcd] Reciped exists at location: "+ReflectionUtils.getMethodName(1));
- Logger.RECIPE("[1234abcd] Reciped exists at location: "+ReflectionUtils.getMethodName(2));
- Logger.RECIPE("[1234abcd] Reciped exists at location: "+ReflectionUtils.getMethodName(3));
- Logger.RECIPE("[1234abcd] Reciped exists at location: "+ReflectionUtils.getMethodName(4));
+ Logger.RECIPE("[Fix] Recipe for "+aOutput.getDisplayName()+" has incorrect number of inputs. Size: "+aInputs.length+".");
+ //Logger.RECIPE("[1234abcd] Reciped exists at location: "+ReflectionUtils.getMethodName(1));
+ //Logger.RECIPE("[1234abcd] Reciped exists at location: "+ReflectionUtils.getMethodName(2));
+ //Logger.RECIPE("[1234abcd] Reciped exists at location: "+ReflectionUtils.getMethodName(3));
+ //Logger.RECIPE("[1234abcd] Reciped exists at location: "+ReflectionUtils.getMethodName(4));
//Logger.RECIPE("Reciped exists at location: "+ReflectionUtils.getMethodName(1));
}
@@ -53,7 +71,6 @@ public class ShapedRecipe {
int aInfoSlot = 0;
for (Object stack : aInputs) {
if (stack != null) {
-
String mInfo = "";
if (stack instanceof String) {
mInfo = (String) stack;
@@ -61,7 +78,6 @@ public class ShapedRecipe {
else if (stack instanceof ItemStack) {
mInfo = ((ItemStack) stack).getDisplayName();
}
-
aRecipePairs.put(new Pair<Character, Object>(CHARS.charAt(aCharSlot), stack));
Logger.RECIPE("Storing '"+CHARS.charAt(aCharSlot)+"' with an object of type "+stack.getClass().getSimpleName()+" and a value of "+mInfo);
aChar[aMemSlot++] = CHARS.charAt(aCharSlot);
@@ -97,11 +113,19 @@ public class ShapedRecipe {
aGrid[1] = ""+aGridWhole.charAt(3)+aGridWhole.charAt(4)+aGridWhole.charAt(5);
aGrid[2] = ""+aGridWhole.charAt(6)+aGridWhole.charAt(7)+aGridWhole.charAt(8);
}
+ else {
+ Logger.RECIPE("[Fix] Grid length for recipe outputting "+aOutput.getDisplayName()+" is not 9.");
+ }
//Rebuild the Map without spaces
aRecipePairs.clear();
aCharSlot = 0;
- int counter = 3;
+
+ //The amount of spaces in the Varags that the Shape strings takes.
+ //Currently they are inserted as a single array into index 0.
+ final int KEY_COUNTER = 1;
+
+ int counter = KEY_COUNTER;
for (Object stack : aInputs) {
if (stack != null) {
String mInfo = "";
@@ -118,17 +142,18 @@ public class ShapedRecipe {
}
}
- Logger.RECIPE("Counter started at 3, counter is now at "+counter+". Trying to create Varag array with a size of "+(3+(counter-3)*2));
+ Logger.RECIPE("Counter started at "+KEY_COUNTER+", counter is now at "+counter+". Trying to create Varag array with a size of "+(KEY_COUNTER+(counter-KEY_COUNTER)*2));
//Counter started at 3, counter is now at 4. Trying to create Varag array with a size of 2
//Register the shaped grid straight to the varags
- mVarags2 = new Object[(3+(counter-3)*2)];
- mVarags2[0] = aGrid[0];
+ mVarags2 = new Object[(KEY_COUNTER+(counter-KEY_COUNTER)*2)];
+ /*mVarags2[0] = aGrid[0];
mVarags2[1] = aGrid[1];
- mVarags2[2] = aGrid[2];
+ mVarags2[2] = aGrid[2];*/
+ mVarags2[0] = aGrid;
//Add Each Char, then Item to the varags, sequentially.
- int counter2 = 3;
+ int counter2 = KEY_COUNTER;
for (Pair<Character, Object> r : aRecipePairs) {
char c = r.getKey();
Object o = r.getValue();
@@ -138,13 +163,13 @@ public class ShapedRecipe {
}
Logger.RECIPE("Recipe Summary");
- Logger.RECIPE("+=+=+=+");
- Logger.RECIPE("="+aChar[0]+"="+aChar[1]+"="+aChar[2]+"=");
- Logger.RECIPE("+=+=+=+");
- Logger.RECIPE("="+aChar[3]+"="+aChar[4]+"="+aChar[5]+"=");
- Logger.RECIPE("+=+=+=+");
- Logger.RECIPE("="+aChar[6]+"="+aChar[7]+"="+aChar[8]+"=");
- Logger.RECIPE("+=+=+=+");
+ Logger.RECIPE("+ = + = + = +");
+ Logger.RECIPE("= "+aChar[0]+" = "+aChar[1]+" = "+aChar[2]+" =");
+ Logger.RECIPE("+ = + = + = +");
+ Logger.RECIPE("= "+aChar[3]+" = "+aChar[4]+" = "+aChar[5]+" =");
+ Logger.RECIPE("+ = + = + = +");
+ Logger.RECIPE("=" +aChar[6]+" = "+aChar[7]+" = "+aChar[8]+" =");
+ Logger.RECIPE("+ = + = + = +");
for (int r=0;r<9;r++) {
if (aChar[r] != ' ') {
Logger.RECIPE(""+aChar[r]+" : "+aLoggingInfo[r]);
@@ -152,6 +177,9 @@ public class ShapedRecipe {
}
}
+ else {
+ Logger.RECIPE("[Fix] Recipe for "+aOutput.getDisplayName()+" contains a strange number of inputs.");
+ }
//Try set the recipe for this object.
ShapedOreRecipe testRecipe = null;
@@ -159,12 +187,12 @@ public class ShapedRecipe {
testRecipe = new ShapedOreRecipe(aOutput, mVarags2);
}
catch (Throwable t) {
- Logger.RECIPE("Error thrown when making a ShapedOreRecipe object.");
+ Logger.RECIPE("[Fix][0] Error thrown when making a ShapedOreRecipe object.");
t.printStackTrace();
}
if (testRecipe == null) {
this.mRecipe = null;
- Logger.RECIPE("Failed to generate a shaped recipe.");
+ Logger.RECIPE("[Fix] Failed to generate a shaped recipe.");
}
else {
this.mRecipe = testRecipe;
@@ -175,14 +203,17 @@ public class ShapedRecipe {
//Output was not valid
else {
this.mRecipe = null;
- Logger.RECIPE("Failed to generate a shaped recipe. Output was not valid.");
+ Logger.RECIPE("[Fix] Failed to generate a shaped recipe. Output was not valid.");
}
}
catch(Throwable t) {
- this.mRecipe = null;
+ this.mRecipe = null;
+ Logger.RECIPE("[Fix][1] Error thrown when making a ShapedOreRecipe object.");
+ t.printStackTrace();
}
+
}
}
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java
index ce3b778beb..b64c0995e7 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java
@@ -121,9 +121,11 @@ public class RecipeUtils {
}
}*/
+ Object[] o = new Object[] {slot_1, slot_2, slot_3, slot_4, slot_5, slot_6, slot_7, slot_8, slot_9};
+
try {
int size = COMPAT_HANDLER.mRecipesToGenerate.size();
- COMPAT_HANDLER.mRecipesToGenerate.put(new InternalRecipeObject(validSlots.toArray(), resultItem, false));
+ COMPAT_HANDLER.mRecipesToGenerate.put(new InternalRecipeObject(o, resultItem, false));
//Utils.LOG_WARNING("Success! Added a recipe for "+resultItem.getDisplayName());
if (COMPAT_HANDLER.mRecipesToGenerate.size() > size) {
@@ -551,22 +553,39 @@ public class RecipeUtils {
mOutput = aOutput != null ? aOutput.copy() : null;
Object[] aFiltered = new Object[9];
int aValid = 0;
- for (Object o : aInputs) {
- if (o == null) {
- aFiltered[aValid++] = null;
- }
- else if (o instanceof ItemStack) {
+ for (Object o : aInputs) {
+ if (o instanceof ItemStack) {
aFiltered[aValid++] = o;
}
else if (o instanceof String) {
aFiltered[aValid++] = o;
}
+ else if (o == null) {
+ aFiltered[aValid++] = null;
+ }
else {
Logger.RECIPE("Cleaned a "+o.getClass().getSimpleName()+" from recipe input.");
}
}
-
- ShapedRecipe r = new ShapedRecipe(aFiltered, aOutput);
+
+ int validCounter = 0, invalidCounter = 0;
+ for (Object p : aFiltered) {
+ if (p instanceof ItemStack) {
+ validCounter++;
+ }
+ else if (p instanceof String) {
+ validCounter++;
+ }
+ else if (p == null) {
+ validCounter++;
+ }
+ else {
+ invalidCounter++;
+ }
+ }
+
+ Logger.RECIPE("Using "+validCounter+" valid inputs and "+invalidCounter+" invalid inputs.");
+ ShapedRecipe r = new ShapedRecipe(aFiltered, mOutput);
if (r != null && r.mRecipe != null) {
isValid = true;
}
@@ -584,66 +603,6 @@ public class RecipeUtils {
else {
Logger.INFO("[Recipe] Invalid shapped recipe outputting "+mOutput != null ? mOutput.getDisplayName() : "Bad Output Item");
}
-
- /*ItemStack[] vInputs = new ItemStack[9];
- if (mOutput != null) {
- for (int y=0;y<9;y++){
- if (mInputs.length > y) {
- if (mInputs[y] instanceof String) {
- vInputs[y] = ItemUtils.getItemStackOfAmountFromOreDict((String) mInputs[y], 1);
- }
- else if (mInputs[y] instanceof ItemStack) {
- vInputs[y] = (ItemStack) mInputs[y];
- }
- else {
- Logger.INFO("[Recipe] Invalid Item in shapped recipe outputting "+mOutput.getDisplayName() + " | Type: "+mInputs[y].getClass().getName());
- }
- }
- else {
- vInputs[y] = null;
- }
- }
-
- GameRegistry.addRecipe(new ShapedOreRecipe(mOutput.copy(), vInputs));
- }*/
-
-
-
- /*if (!gtType) {
-
- }
- else {
- if (GT_ModHandler.addCraftingRecipe(mOutput,
- GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE |
- GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED,
- new Object[]{"ABC", "DEF", "GHI",
- 'A', mInputs[0],
- 'B', mInputs[1],
- 'C', mInputs[2],
- 'D', mInputs[3],
- 'E', mInputs[4],
- 'F', mInputs[5],
- 'G', mInputs[6],
- 'H', mInputs[7],
- 'I', mInputs[8]})){
- Logger.WARNING("Success! Added a recipe for "+mOutput.getDisplayName());
- RegistrationHandler.recipesSuccess++;
- }
- else if (recipeBuilder(
- mInputs[0], mInputs[0], mInputs[0],
- mInputs[0], mInputs[0], mInputs[0],
- mInputs[0], mInputs[0], mInputs[0],
- mOutput)){
- Logger.WARNING("Success! Added a recipe for "+mOutput.getDisplayName());
- RegistrationHandler.recipesSuccess++;
- }
- else {
- if (mOutput != null){
- Logger.WARNING("Adding recipe for "+mOutput.getDisplayName()+" failed. Error 62.");
- }
- RegistrationHandler.recipesFailed++;
- }
- }*/
}
@Override
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java
index 52a3c914b6..1875e874ea 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java
@@ -45,19 +45,6 @@ public class RecipeGen_DustGeneration extends RecipeGen_Base {
final int tVoltageMultiplier = material.getMeltingPointK() >= 2800 ? 60 : 15;
Logger.WARNING("Generating Shaped Crafting recipes for "+material.getLocalizedName()); //TODO
- //Ring Recipe
-
- if (RecipeUtils.addShapedGregtechRecipe(
- "craftingToolWrench", null, null,
- null, material.getRod(1), null,
- null, null, null,
- material.getRing(1))){
- Logger.WARNING("Ring Recipe: "+material.getLocalizedName()+" - Success");
- }
- else {
- Logger.WARNING("Ring Recipe: "+material.getLocalizedName()+" - Failed");
- }
-
final ItemStack normalDust = material.getDust(1);
final ItemStack smallDust = material.getSmallDust(1);
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java
index fce4bad318..df50f6c7d7 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java
@@ -93,7 +93,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base {
//Ring Recipe
if (!material.isRadioactive && material.getRing(1) != null){
- if (LoadedMods.DreamCraft){
+ if (CORE.GTNH){
if (RecipeUtils.recipeBuilder(
"craftingToolHardHammer", null, null,
"craftingToolFile", material.getRod(1), null,