aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java31
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/gregtech/recipehandlers/GregtechRecipe.java75
2 files changed, 24 insertions, 82 deletions
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
index 3f08715914..486cda42f9 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
@@ -608,25 +608,40 @@ public class ItemUtils {
public static String getArrayStackNames(final ItemStack[] aStack) {
String itemNames = "Item Array: ";
- for (final ItemStack alph : aStack) {
-
+ int aPos = 0;
+ for (final ItemStack alph : aStack) {
+ if (alph == null) {
+ continue;
+ }
if (alph != null) {
final String temp = itemNames;
- itemNames = temp + ", " + alph.getDisplayName() + " x" + alph.stackSize;
- } else {
- final String temp = itemNames;
- itemNames = temp + ", " + "null" + " x" + "0";
+ itemNames = temp + (aPos > 0 ? ", " : "") + alph.getDisplayName() + " x" + alph.stackSize;
+ aPos++;
}
}
return itemNames;
}
public static String[] getArrayStackNamesAsArray(final ItemStack[] aStack) {
- final String[] itemNames = {};
+ final String[] itemNames = aStack == null ? new String[] {} : new String[aStack.length];
+ Logger.INFO(""+aStack.length);
+
+ if (aStack == null || aStack.length < 1) {
+ return itemNames;
+ }
+
int arpos = 0;
- for (final ItemStack alph : aStack) {
+ for (final ItemStack alph : aStack) {
+ if (alph == null) {
+ continue;
+ }
+ try {
itemNames[arpos] = alph.getDisplayName();
arpos++;
+ }
+ catch (Throwable t) {
+ t.printStackTrace();
+ }
}
return itemNames;
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/recipehandlers/GregtechRecipe.java b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/recipehandlers/GregtechRecipe.java
index afba320fe7..635239bbfc 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/recipehandlers/GregtechRecipe.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/recipehandlers/GregtechRecipe.java
@@ -1,76 +1,3 @@
package gtPlusPlus.core.util.minecraft.gregtech.recipehandlers;
-import java.lang.reflect.Method;
-
-import net.minecraft.item.ItemStack;
-
-import gregtech.api.util.GT_ModHandler;
-
-import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.core.lib.CORE;
-
-public final class GregtechRecipe {
-
- public LibraryProxy ourProxy;
- public GregtechRecipe(){
- Logger.INFO("Initializing a recipe handler for different versions of Gregtech 5.");
- try {
- if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){
- this.ourProxy = new LibProxy1();
- Logger.INFO("Selecting GT 5.7/5.8 Recipe Set");
- }
- if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){
- this.ourProxy = new LibProxy2();
- Logger.INFO("Selecting GT 5.9 Recipe Set");
- }
- } catch (final NoSuchMethodException e) {
- this.ourProxy = null;
- }
- }
-
- public boolean addSmeltingAndAlloySmeltingRecipe(final ItemStack aInput, final ItemStack aOutput) {
- Logger.WARNING("Adding a GT Furnace/Alloy Smelter Recipe"+"| Input:"+aInput.getDisplayName()+" | Output:"+aOutput.getDisplayName()+" |");
- return this.ourProxy.addSmeltingAndAlloySmeltingRecipe(aInput, aOutput);
- }
-
-}
-
-abstract class LibraryProxy { // can also be interface unless you want to have common code here
- abstract public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aInput, ItemStack aOutput);
-}
-
-class LibProxy1 extends LibraryProxy {
- final Method m1;
-
- public LibProxy1() throws NoSuchMethodException {
- this.m1 = GT_ModHandler.class.getDeclaredMethod("addSmeltingAndAlloySmeltingRecipe", ItemStack.class, ItemStack.class);
- }
-
- @Override
- public boolean addSmeltingAndAlloySmeltingRecipe(final ItemStack aInput, final ItemStack aOutput) {
- try {
- //Logger.INFO("Trying with Gt 5.7/5.8 Method.");
- return (boolean) this.m1.invoke(null, aInput, aOutput);
- } catch (final Exception e) {
- throw new RuntimeException(e);
- }
- }
-}
-
-class LibProxy2 extends LibraryProxy {
- final Method m2;
-
- public LibProxy2() throws NoSuchMethodException {
- this.m2 = GT_ModHandler.class.getDeclaredMethod("addSmeltingAndAlloySmeltingRecipe", ItemStack.class, ItemStack.class, boolean.class);
- }
-
- @Override
- public boolean addSmeltingAndAlloySmeltingRecipe(final ItemStack aInput, final ItemStack aOutput) {
- try {
- //Logger.INFO("Trying with Gt 5.9 Method.");
- return (boolean) this.m2.invoke(null, aInput, aOutput, true);
- } catch (final Exception e) {
- throw new RuntimeException(e);
- }
- }
-} \ No newline at end of file
+public final class GregtechRecipe {} \ No newline at end of file