aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil/core/util/UtilsItems.java
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-06-02 00:13:32 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-06-02 00:13:32 +1000
commitecff67654aac93b33907a0784d9c0b88648cfd1a (patch)
tree728ab9131bacd866313c65c37e3f37a53e73520a /src/Java/miscutil/core/util/UtilsItems.java
parente6d4747d4cb4e648f2b6f8f88ad0aceca59d3d8b (diff)
downloadGT5-Unofficial-ecff67654aac93b33907a0784d9c0b88648cfd1a.tar.gz
GT5-Unofficial-ecff67654aac93b33907a0784d9c0b88648cfd1a.tar.bz2
GT5-Unofficial-ecff67654aac93b33907a0784d9c0b88648cfd1a.zip
~Changed Coke Oven Recipes
~Cleaned up a handful of classes (ModItems.java, RECIPES_Machines.java, Utils.java & UtilsItems.java) +Added a handful of DEBUG classes (To resolve multiblock shaping issues) +Added GregtechMetaTileEntityIndustrialPlatePress.java +Added textures for itemStickyRubber, itemIngotBatteryAlloy & itemPlateBatteryAlloy. +Added a basic wrapper for direct MineTweaker script usage (Ultra W.I.P.) >This will probably be changed to preload .zs scripts, regex and handle appropriately, but undecided.
Diffstat (limited to 'src/Java/miscutil/core/util/UtilsItems.java')
-rw-r--r--src/Java/miscutil/core/util/UtilsItems.java226
1 files changed, 181 insertions, 45 deletions
diff --git a/src/Java/miscutil/core/util/UtilsItems.java b/src/Java/miscutil/core/util/UtilsItems.java
index c2bf2823fc..d939f2a9bc 100644
--- a/src/Java/miscutil/core/util/UtilsItems.java
+++ b/src/Java/miscutil/core/util/UtilsItems.java
@@ -7,12 +7,16 @@ import java.util.Iterator;
import java.util.List;
import miscutil.core.handler.registration.RegistrationHandler;
+import miscutil.core.lib.CORE;
+import miscutil.core.lib.LoadedMods;
+import miscutil.core.util.wrapper.var;
import net.minecraft.client.Minecraft;
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.ShapedOreRecipe;
+import net.minecraftforge.oredict.ShapelessOreRecipe;
import cpw.mods.fml.common.registry.GameRegistry;
public class UtilsItems {
@@ -44,16 +48,16 @@ public class UtilsItems {
}
return null;
}
-
+
public static ItemStack getSimpleStack(Item x){
try {
- ItemStack r = new ItemStack(x, 1);
- return r;
+ ItemStack r = new ItemStack(x, 1);
+ return r;
} catch(Throwable e){
return null;
}
}
-
+
public static void getItemForOreDict(String FQRN, String oreDictName, String itemName, int meta){
try {
@@ -76,14 +80,64 @@ public class UtilsItems {
}
}
+ @SuppressWarnings("unused")
+ public static ItemStack getItemStackWithMeta(boolean MOD, String FQRN, String itemName, int meta, int itemstackSize){
+ if (MOD){
+ try {
+ Item em = null;
+ Item em1 = getItem(FQRN);
+ Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta);
+ if (em1 != null){
+ if (null == em){
+ em = em1;
+ }
+ if (em != null){
+ ItemStack metaStack = new ItemStack(em,itemstackSize,meta);
+ return metaStack;
+ }
+ }
+ return null;
+ } catch (NullPointerException e) {
+ Utils.LOG_ERROR(itemName+" not found. [NULL]");
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static ItemStack getCorrectStacktype(String fqrn, int stackSize){
+ String oreDict = "ore:";
+ ItemStack temp;
+ if (fqrn.toLowerCase().contains(oreDict.toLowerCase())){
+ String sanitizedName = fqrn.replace(oreDict, "");
+ temp = UtilsItems.getItemStack(sanitizedName, stackSize);
+ return temp;
+ }
+ String[] fqrnSplit = fqrn.split(":");
+ if(fqrnSplit[2] == null){fqrnSplit[2] = "0";}
+ temp = UtilsItems.getItemStackWithMeta(LoadedMods.MiscUtils, fqrn, fqrnSplit[1], Integer.parseInt(fqrnSplit[2]), stackSize);
+ return temp;
+ }
+
+ public static ItemStack getCorrectStacktype(Object item_Input, int stackSize) {
+ if (item_Input instanceof String){
+ return getCorrectStacktype(item_Input, stackSize);
+ }
+ else if (item_Input instanceof ItemStack){
+ return (ItemStack) item_Input;
+ }
+ if (item_Input instanceof var){
+ return ((var) item_Input).getStack(stackSize);
+ }
+ return null;
+ }
+
public static void 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){
ArrayList<Object> validSlots = new ArrayList<Object>();
- //, String lineFirst, String lineSecond, String lineThird
Utils.LOG_INFO("Trying to add a recipe for "+resultItem.toString());
- String a,b,c,d,e,f,g,h,i;
- //ItemStack empty = new ItemStack(Blocks.air);
+ 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);}
@@ -118,8 +172,11 @@ public class UtilsItems {
validSlots.add(0, lineOne);
validSlots.add(1, lineTwo);
validSlots.add(2, lineThree);
- Boolean AadvancedLog = true;
- if (AadvancedLog){
+ boolean advancedLog = false;
+ if (CORE.DEBUG){
+ advancedLog = true;
+ }
+ if (advancedLog){
int j = 0;
int l = validSlots.size();
Utils.LOG_WARNING("l:"+l);
@@ -152,40 +209,9 @@ public class UtilsItems {
}
try {
- /*Utils.LOG_WARNING("validSlots to array: "+validSlots.toArray());
- Object[] validSlotsArray = (Object[]) validSlots.toArray();
-
- for(int j = 0; j < validSlotsArray.length; j++)
- {
- Utils.LOG_ERROR(""+validSlotsArray[j]);
- }*/
-
GameRegistry.addRecipe(new ShapedOreRecipe(resultItem.copy(), (Object[]) validSlots.toArray()));
Utils.LOG_INFO("Success! Added a recipe for "+resultItem.toString());
- RegistrationHandler.recipesSuccess++;
- /*try {
- try {
- try {
- //Code
- }
- catch (NullPointerException | ClassCastException r){
- Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+resultItem.getUnlocalizedName());
- RegistrationHandler.recipesFailed++;
- r.printStackTrace();
- //System.exit(1);
- }
- }
- catch (NullPointerException o){
-
- Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+resultItem.getUnlocalizedName());
- o.printStackTrace();
- RegistrationHandler.recipesFailed++;
- //System.exit(1);
- }
- }
- catch (ClassCastException r){
- Utils.LOG_WARNING("@@@: Casting to ObjectArray Failed :(");
- }*/
+ RegistrationHandler.recipesSuccess++;
}
catch(NullPointerException | ClassCastException k){
k.getMessage();
@@ -194,10 +220,71 @@ public class UtilsItems {
k.getLocalizedMessage();
Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+resultItem.getUnlocalizedName());
RegistrationHandler.recipesFailed++;
- //System.exit(1);
}
}
+ 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();
+
+ 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_WARNING(a);
+ 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);}
+ Utils.LOG_WARNING(c);
+ 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);}
+ Utils.LOG_WARNING(e);
+ 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);}
+ Utils.LOG_WARNING(g);
+ 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);}
+ Utils.LOG_WARNING(i);
+
+
+ Utils.LOG_ERROR("_______");
+ String lineOne = a+b+c;
+ Utils.LOG_ERROR("|"+a+"|"+b+"|"+c+"|");
+ Utils.LOG_ERROR("_______");
+ String lineTwo = d+e+f;
+ Utils.LOG_ERROR("|"+d+"|"+e+"|"+f+"|");
+ Utils.LOG_ERROR("_______");
+ 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);
+
+ try {
+ //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.toString());
+ RegistrationHandler.recipesSuccess++;
+ }
+ catch(RuntimeException k){
+ k.getMessage();
+ k.getClass();
+ k.printStackTrace();
+ k.getLocalizedMessage();
+ Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+Output.getUnlocalizedName());
+ RegistrationHandler.recipesFailed++;
+ }
+
+
+ //GameRegistry.addShapelessRecipe(new ItemStack(output_ITEM, 1), new Object[] {slot_1, slot_2});
+ }
+
public static Item getItem(String fqrn) // fqrn = fully qualified resource name
{
String[] fqrnSplit = fqrn.split(":");
@@ -209,14 +296,14 @@ public class UtilsItems {
String[] fqrnSplit = fqrn.split(":");
return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size);
}
-
+
// TODO
/*public static FluidStack getFluidStack(Materials m, int Size) // fqrn = fully qualified resource name
{
String[] fqrnSplit = fqrn.split(":");
-
+
FluidStack x = (FluidStack) "Materials."+m+".getFluid"(Size);
-
+
return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size);
}*/
@@ -304,4 +391,53 @@ public class UtilsItems {
Utils.LOG_INFO("Return false, because something went wrong.");
return false;
}
+
+ public static void recipeBuilder(Object[] array, ItemStack outPut) {
+ 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);
+ }
+ }
+
}