diff options
Diffstat (limited to 'src/Java/gtPlusPlus')
-rw-r--r-- | src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java | 69 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java | 39 |
2 files changed, 90 insertions, 18 deletions
diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java b/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java index de10c11845..64f486b23e 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ShapedRecipe.java @@ -3,6 +3,7 @@ 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; @@ -24,6 +25,8 @@ public class ShapedRecipe { public ShapedRecipe(Object[] aInputs, ItemStack aOutput) { String aGridWhole = ""; String aGrid[] = new String[3]; + char[] aChar = new char[9]; + String[] aLoggingInfo = new String[9]; //Just to be safe try { @@ -33,24 +36,51 @@ public class ShapedRecipe { 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("Reciped exists at location: "+ReflectionUtils.getMethodName(1)); + } + + //Build a Pair for each slot AutoMap<Pair<Character, Object>> aRecipePairs = new AutoMap<Pair<Character, Object>>(); int aCharSlot = 0; + int aMemSlot = 0; + int aInfoSlot = 0; for (Object stack : aInputs) { if (stack != null) { - aRecipePairs.put(new Pair<Character, Object>(CHARS.charAt(aCharSlot++), stack)); + + String mInfo = ""; + if (stack instanceof String) { + mInfo = (String) stack; + } + 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); + aCharSlot++; + aLoggingInfo[aInfoSlot++] = mInfo; } else { - aRecipePairs.put(new Pair<Character, Object>(' ', (ItemStack) null)); + aRecipePairs.put(new Pair<Character, Object>(' ', (ItemStack) null)); + Logger.RECIPE("Storing ' ' with an object of type null"); + aChar[aMemSlot++] = ' '; + aLoggingInfo[aInfoSlot++] = "Empty"; } } + Logger.RECIPE(aRecipePairs.size()+" Char|Object pairs registered for recipe."); //If we have enough valid slots, iterate them and build a String which represents the entire grid. //If this String is the correct length, we will split it into thirds and build the grid String array. if (aRecipePairs.size() == 9) { - Logger.RECIPE("9 Char|Object pairs registered for recipe."); - for (Pair<Character, Object> h : aRecipePairs) { if (h.getKey() != null) { aGridWhole += String.valueOf(h.getKey()); @@ -74,17 +104,25 @@ public class ShapedRecipe { int counter = 3; for (Object stack : aInputs) { if (stack != null) { + String mInfo = ""; + if (stack instanceof String) { + mInfo = (String) stack; + } + else if (stack instanceof ItemStack) { + mInfo = ((ItemStack) stack).getDisplayName(); + } aRecipePairs.put(new Pair<Character, Object>(CHARS.charAt(aCharSlot), stack)); - Logger.RECIPE("Registering Pair of '"+CHARS.charAt(aCharSlot)+" and a "+stack.getClass().getSimpleName()+" object."); + Logger.RECIPE("Registering Pair of '"+CHARS.charAt(aCharSlot)+"' and a "+stack.getClass().getSimpleName()+" object. Object has a value of "+mInfo); aCharSlot++; counter++; } } - Logger.RECIPE("Counter started at 3, counter is now at "+counter+". Trying to create Varag array with a size of "+((counter-3)*2)); + Logger.RECIPE("Counter started at 3, counter is now at "+counter+". Trying to create Varag array with a size of "+(3+(counter-3)*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[((counter-3)*2)]; + mVarags2 = new Object[(3+(counter-3)*2)]; mVarags2[0] = aGrid[0]; mVarags2[1] = aGrid[1]; mVarags2[2] = aGrid[2]; @@ -97,7 +135,22 @@ public class ShapedRecipe { mVarags2[counter2] = (char) c; mVarags2[counter2+1] = o; counter2 += 2; - } + } + + 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("+=+=+=+"); + for (int r=0;r<9;r++) { + if (aChar[r] != ' ') { + Logger.RECIPE(""+aChar[r]+" : "+aLoggingInfo[r]); + } + } + } //Try set the recipe for this object. diff --git a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java index 8b2ab43cf2..ce3b778beb 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -33,7 +33,7 @@ public class RecipeUtils { final ArrayList<Object> validSlots = new ArrayList<>(); if (resultItem == null){ - Logger.WARNING("[Recipe] Found a recipe with an invalid output, yet had a valid inputs. Using Dummy output so recipe can be found.."); + Logger.INFO("[1234abcd] Found a recipe with an invalid output, yet had a valid inputs. Using Dummy output so recipe can be found.."); resultItem = ItemUtils.getItemStackOfAmountFromOreDict("givemeabrokenitem", 1); RegistrationHandler.recipesFailed++; //return false; @@ -42,12 +42,13 @@ public class RecipeUtils { if ((slot_1 == null) && (slot_2 == null) && (slot_3 == null) && (slot_4 == null) && (slot_5 == null) && (slot_6 == null) && (slot_7 == null) && (slot_8 == null) && (slot_9 == null)){ - Logger.INFO("[Recipe] Found a recipe with 0 inputs, yet had a valid output."); - Logger.INFO("[Recipe] Error found while adding a recipe for: "+resultItem.getDisplayName()+" | Please report this issue on Github."); + Logger.INFO("[1234abcd] Found a recipe with 0 inputs, yet had a valid output."); + Logger.INFO("[1234abcd] Error found while adding a recipe for: "+resultItem.getDisplayName()+" | Please report this issue on Github."); RegistrationHandler.recipesFailed++; return false; } - + + /* //Utils.LOG_WARNING("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);} @@ -81,9 +82,9 @@ public class RecipeUtils { Logger.ERROR("|"+g+"|"+h+"|"+i+"|"); Logger.ERROR("_______"); - validSlots.add(0, lineOne); - validSlots.add(1, lineTwo); - validSlots.add(2, lineThree); + //validSlots.add(0, lineOne); + //validSlots.add(1, lineTwo); + //validSlots.add(2, lineThree); boolean advancedLog = false; if (CORE.DEBUG){ advancedLog = true; @@ -118,7 +119,7 @@ public class RecipeUtils { //Utils.LOG_WARNING("Is Valid: "+validSlots.get(j)); } } - } + }*/ try { int size = COMPAT_HANDLER.mRecipesToGenerate.size(); @@ -546,8 +547,26 @@ public class RecipeUtils { public final boolean isValid; public InternalRecipeObject(Object[] aInputs, ItemStack aOutput, boolean gtRecipe) { - mOutput = aOutput != null ? aOutput.copy() : null; - ShapedRecipe r = new ShapedRecipe(aInputs, aOutput); + Logger.RECIPE("==================================="); + 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) { + aFiltered[aValid++] = o; + } + else if (o instanceof String) { + aFiltered[aValid++] = o; + } + else { + Logger.RECIPE("Cleaned a "+o.getClass().getSimpleName()+" from recipe input."); + } + } + + ShapedRecipe r = new ShapedRecipe(aFiltered, aOutput); if (r != null && r.mRecipe != null) { isValid = true; } |