From 2615992e7d0d4ed3ac205800be71c831029b2dc5 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Sat, 18 Jun 2016 16:55:58 +1000 Subject: ~More Refactoring Does it ever end? --- src/Java/miscutil/core/util/PlayerCache.java | 126 ------ src/Java/miscutil/core/util/UtilsItems.java | 455 -------------------- src/Java/miscutil/core/util/UtilsMining.java | 179 -------- .../core/util/VanillaChatCommandSender.java | 35 -- src/Java/miscutil/core/util/item/UtilsItems.java | 179 ++++++++ .../miscutil/core/util/player/PlayerCache.java | 127 ++++++ .../miscutil/core/util/player/UtilsMining.java | 180 ++++++++ .../core/util/recipe/RECIPES_GREGTECH.java | 85 ---- .../core/util/recipe/RECIPES_MTWRAPPER.java | 113 ----- .../core/util/recipe/RECIPES_Machines.java | 458 --------------------- .../core/util/recipe/RECIPES_Shapeless.java | 41 -- .../miscutil/core/util/recipe/RECIPES_Tools.java | 176 -------- .../core/util/recipe/ShapedRecipeObject.java | 43 -- .../miscutil/core/util/recipe/UtilsRecipe.java | 309 ++++++++++++++ src/Java/miscutil/core/util/wrapper/var.java | 2 +- 15 files changed, 796 insertions(+), 1712 deletions(-) delete mode 100644 src/Java/miscutil/core/util/PlayerCache.java delete mode 100644 src/Java/miscutil/core/util/UtilsItems.java delete mode 100644 src/Java/miscutil/core/util/UtilsMining.java delete mode 100644 src/Java/miscutil/core/util/VanillaChatCommandSender.java create mode 100644 src/Java/miscutil/core/util/item/UtilsItems.java create mode 100644 src/Java/miscutil/core/util/player/PlayerCache.java create mode 100644 src/Java/miscutil/core/util/player/UtilsMining.java delete mode 100644 src/Java/miscutil/core/util/recipe/RECIPES_GREGTECH.java delete mode 100644 src/Java/miscutil/core/util/recipe/RECIPES_MTWRAPPER.java delete mode 100644 src/Java/miscutil/core/util/recipe/RECIPES_Machines.java delete mode 100644 src/Java/miscutil/core/util/recipe/RECIPES_Shapeless.java delete mode 100644 src/Java/miscutil/core/util/recipe/RECIPES_Tools.java delete mode 100644 src/Java/miscutil/core/util/recipe/ShapedRecipeObject.java create mode 100644 src/Java/miscutil/core/util/recipe/UtilsRecipe.java (limited to 'src/Java/miscutil/core/util') diff --git a/src/Java/miscutil/core/util/PlayerCache.java b/src/Java/miscutil/core/util/PlayerCache.java deleted file mode 100644 index a1474bf07a..0000000000 --- a/src/Java/miscutil/core/util/PlayerCache.java +++ /dev/null @@ -1,126 +0,0 @@ -package miscutil.core.util; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Properties; - -import miscutil.core.lib.CORE; - -public class PlayerCache { - - private static final File cache = new File("PlayerCache.dat"); - - public static final void initCache() { - if (CORE.PlayerCache == null || CORE.PlayerCache.equals(null)){ - try { - CORE.PlayerCache = PlayerCache.readPropertiesFileAsMap(); - Utils.LOG_INFO("Loaded PlayerCache.dat"); - } catch (Exception e) { - Utils.LOG_INFO("Failed to initialise PlayerCache.dat"); - PlayerCache.createPropertiesFile("CACHE_FILE_=", "THIS_CONTAINS_PLAYERDATA"); - //e.printStackTrace(); - } - } - } - - public static void createPropertiesFile(String playerName, String playerUUIDasString) { - try { - Properties props = new Properties(); - props.setProperty(playerName+" ", playerUUIDasString); - OutputStream out = new FileOutputStream(cache); - props.store(out, "Player Cache."); - Utils.LOG_INFO("Created an empty PlayerCache.dat for future use."); - } - catch (Exception e ) { - e.printStackTrace(); - } - } - - public static void appendParamChanges(String playerName, String playerUUIDasString) { - Properties properties = new Properties(); - try { - Utils.LOG_WARNING("Attempting to load "+cache.getName()); - properties.load(new FileInputStream(cache)); - if (properties == null || properties.equals(null)){ - Utils.LOG_WARNING("Null properties"); - } - else { - Utils.LOG_WARNING("Loaded PlayerCache.dat"); - properties.setProperty(playerName+"_", playerUUIDasString); - FileOutputStream fr=new FileOutputStream(cache); - properties.store(fr, "Player Cache."); - fr.close(); - } - - } catch (IOException e) { - Utils.LOG_WARNING("No PlayerCache file found, creating one."); - createPropertiesFile(playerName, playerUUIDasString); - } - } - - /** - * Reads a "properties" file, and returns it as a Map - * (a collection of key/value pairs). - * - * Credit due to Alvin Alexander - http://alvinalexander.com/java/java-properties-file-map-example?nocache=1#comment-8215 - * Changed slightly as the filename and delimiter are constant in my case. - * - * @param filename The properties filename to read. - * @param delimiter The string (or character) that separates the key - * from the value in the properties file. - * @return The Map that contains the key/value pairs. - * @throws Exception - */ - public static Map readPropertiesFileAsMap() throws Exception { - String delimiter = "="; - @SuppressWarnings({ "rawtypes", "unchecked" }) - Map map = new HashMap(); - BufferedReader reader = new BufferedReader(new FileReader(cache)); - String line; - while ((line = reader.readLine()) != null) - { - if (line.trim().length()==0) continue; - if (line.charAt(0)=='#') continue; - // assumption here is that proper lines are like "String : http://xxx.yyy.zzz/foo/bar", - // and the ":" is the delimiter - int delimPosition = line.indexOf(delimiter); - String key = line.substring(0, delimPosition-1).trim(); - String value = line.substring(delimPosition+1).trim(); - map.put(key, value); - } - reader.close(); - CORE.PlayerCache = map; - return map; - } - - public static String lookupPlayerByUUID(String UUID){ - try { - Map map = null; - try { - map = readPropertiesFileAsMap(); - } catch (Exception e) { - Utils.LOG_ERROR("With "+e.getCause()+" as cause, Caught Exception: "+e.toString()); - //e.printStackTrace(); - } - for (Entry entry : map.entrySet()) { - if (Objects.equals(UUID, entry.getValue())) { - return entry.getKey(); - } - } - return null; - } catch (NullPointerException e) { - Utils.LOG_ERROR("With "+e.getCause()+" as cause, Caught Exception: "+e.toString()); - //e.printStackTrace(); - } - return null; -} -} diff --git a/src/Java/miscutil/core/util/UtilsItems.java b/src/Java/miscutil/core/util/UtilsItems.java deleted file mode 100644 index 7f80534804..0000000000 --- a/src/Java/miscutil/core/util/UtilsItems.java +++ /dev/null @@ -1,455 +0,0 @@ -package miscutil.core.util; - -import gregtech.api.util.GT_OreDictUnificator; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import miscutil.core.handler.COMPAT_HANDLER; -import miscutil.core.handler.registration.LateRegistrationHandler; -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 { - - public static ItemStack getItemStackOfItem(Boolean modToCheck, String mod_itemname_meta){ - if (modToCheck){ - try{ - Item em = null; - - Item em1 = getItem(mod_itemname_meta); - Utils.LOG_WARNING("Found: "+em1.toString()); - if (em1 != null){ - em = em1; - } - if (em != null ){ - ItemStack returnStack = new ItemStack(em,1); - return returnStack; - } - Utils.LOG_WARNING(mod_itemname_meta+" not found."); - return null; - } catch (NullPointerException e) { - Utils.LOG_ERROR(mod_itemname_meta+" not found. [NULL]"); - return null; - } - } - return null; - } - - public static ItemStack getSimpleStack(Item x){ - try { - 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 { - Item em = null; - Item em1 = getItem(FQRN); - Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); - if (em1 != null){ - em = em1; - } - if (em != null){ - - ItemStack metaStack = new ItemStack(em,1,meta); - GT_OreDictUnificator.registerOre(oreDictName, metaStack); - - /*ItemStack itemStackWithMeta = new ItemStack(em,1,meta); - GT_OreDictUnificator.registerOre(oreDictName, new ItemStack(itemStackWithMeta.getItem()));*/ - } - } catch (NullPointerException e) { - Utils.LOG_ERROR(itemName+" not found. [NULL]"); - } - } - - @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 validSlots = new ArrayList(); - - 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);} - 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); - boolean advancedLog = false; - if (CORE.DEBUG){ - advancedLog = true; - } - if (advancedLog){ - int j = 0; - 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("Adding 1."); - j++; - } - 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; - } - else { - Utils.LOG_WARNING("Done iteration."); - break; - } - } - 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)); - } - } - } - - try { - GameRegistry.addRecipe(new ShapedOreRecipe(resultItem.copy(), (Object[]) validSlots.toArray())); - Utils.LOG_INFO("Success! Added a recipe for "+resultItem.toString()); - if (!COMPAT_HANDLER.areInitItemsLoaded){ - RegistrationHandler.recipesSuccess++; - } - else { - LateRegistrationHandler.recipesSuccess++; - } - } - 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){ - RegistrationHandler.recipesFailed++; - } - else { - LateRegistrationHandler.recipesFailed++; - } - } - } - - 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 validSlots = new ArrayList(); - - 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("_______"); - Utils.LOG_ERROR("|"+a+"|"+b+"|"+c+"|"); - Utils.LOG_ERROR("_______"); - Utils.LOG_ERROR("|"+d+"|"+e+"|"+f+"|"); - Utils.LOG_ERROR("_______"); - Utils.LOG_ERROR("|"+g+"|"+h+"|"+i+"|"); - Utils.LOG_ERROR("_______"); - - validSlots.add(0, a); - validSlots.add(1, b); - validSlots.add(2, c); - validSlots.add(3, d); - validSlots.add(4, e); - validSlots.add(5, f); - validSlots.add(6, g); - validSlots.add(7, h); - validSlots.add(8, i); - - 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(":"); - return GameRegistry.findItem(fqrnSplit[0], fqrnSplit[1]); - } - - public static ItemStack getItemStack(String fqrn, int Size) // fqrn = fully qualified resource name - { - 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); - }*/ - - public static Item getItemInPlayersHand(){ - Minecraft mc = Minecraft.getMinecraft(); - Item heldItem = null; - - try{heldItem = mc.thePlayer.getHeldItem().getItem(); - }catch(NullPointerException e){return null;} - - if (heldItem != null){ - return heldItem; - } - - return null; - } - - public static boolean removeCraftingRecipe(Object x){ - if (null == x){return false;} - if (x instanceof String){ - Item R = 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 (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 recipes = CraftingManager.getInstance().getRecipeList(); - Iterator 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 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 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); - } - } - -} diff --git a/src/Java/miscutil/core/util/UtilsMining.java b/src/Java/miscutil/core/util/UtilsMining.java deleted file mode 100644 index 4c6ef7cda9..0000000000 --- a/src/Java/miscutil/core/util/UtilsMining.java +++ /dev/null @@ -1,179 +0,0 @@ -package miscutil.core.util; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -public class UtilsMining { - - private static boolean durabilityDamage = false; - private static ItemStack stack; - - public static Boolean canPickaxeBlock(Block currentBlock, World currentWorld){ - String correctTool = ""; - if (!currentWorld.isRemote){ - try { - correctTool = currentBlock.getHarvestTool(0); - //Utils.LOG_WARNING(correctTool); - if (correctTool.equals("pickaxe")){ - return true;} - } catch (NullPointerException e){ - return false;} - } - return false; - } - - private static void removeBlockAndDropAsItem(World world, int X, int Y, int Z){ - try { - Block block = world.getBlock(X, Y, Z); - if (canPickaxeBlock(block, world)){ - if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ - block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); - world.setBlockToAir(X, Y, Z); - - } - else { - Utils.LOG_WARNING("Incorrect Tool for mining this block."); - } - } - } catch (NullPointerException e){ - - } - } - - public static void customMine(World world, String FACING, EntityPlayer aPlayer){ - - float DURABILITY_LOSS = 0; - if (!world.isRemote){ - int X = 0; - int Y = 0; - int Z = 0; - - if (FACING.equals("below") || FACING.equals("above")){ - - //Set Player Facing - X = (int) aPlayer.posX; - Utils.LOG_WARNING("Setting Variable X: "+X); - if (FACING.equals("above")){ - Z = (int) aPlayer.posY + 1; - Utils.LOG_WARNING("Setting Variable Y: "+Y); - } - else { - Z = (int) aPlayer.posY - 1; - Utils.LOG_WARNING("Setting Variable Y: "+Y);} - Z = (int) aPlayer.posZ; - Utils.LOG_WARNING("Setting Variable Z: "+Z); - - DURABILITY_LOSS = 0; - for(int i = -2; i < 3; i++) { - for(int j = -2; j < 3; j++) { - for(int k = -2; k < 3; k++) { -/*// float dur = calculateDurabilityLoss(world, X + i, Y + k, Z + j); -// DURABILITY_LOSS = (DURABILITY_LOSS + dur); -// Utils.LOG_WARNING("Added Loss: "+dur); -*/ removeBlockAndDropAsItem(world, X + i, Y + k, Z + j); - } - } - } - } - - else if (FACING.equals("facingEast") || FACING.equals("facingWest")){ - - //Set Player Facing - Z = (int) aPlayer.posZ; - Y = (int) aPlayer.posY; - if (FACING.equals("facingEast")){ - X = (int) aPlayer.posX + 1;} - else { - X = (int) aPlayer.posX - 1;} - - - DURABILITY_LOSS = 0; - for(int i = -1; i < 2; i++) { - for(int j = -1; j < 2; j++) { - for(int k = -1; k < 2; k++) { - /*float dur = calculateDurabilityLoss(world, X+k, Y + i, Z + j); - DURABILITY_LOSS = (DURABILITY_LOSS + dur); - Utils.LOG_WARNING("Added Loss: "+dur);*/ - removeBlockAndDropAsItem(world, X+k, Y + i, Z + j); - } - } - } - } - - else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")){ - - //Set Player Facing - X = (int) aPlayer.posX; - Y = (int) aPlayer.posY; - - if (FACING.equals("facingNorth")){ - Z = (int) aPlayer.posZ + 1;} - else { - Z = (int) aPlayer.posZ - 1;} - - DURABILITY_LOSS = 0; - for(int i = -1; i < 2; i++) { - for(int j = -1; j < 2; j++) { - for(int k = -1; k < 2; k++) { - /*float dur = calculateDurabilityLoss(world, X + j, Y + i, Z+k); - DURABILITY_LOSS = (DURABILITY_LOSS + dur); - Utils.LOG_WARNING("Added Loss: "+dur);*/ - removeBlockAndDropAsItem(world, X + j, Y + i, Z+k); - } - } - } - } - - //Set Durability damage to the item - if (durabilityDamage == true){ - Utils.LOG_WARNING("Total Loss: "+(int)DURABILITY_LOSS); - if (stack.getItemDamage() < (stack.getMaxDamage()-DURABILITY_LOSS)){ - stack.damageItem((int) DURABILITY_LOSS, aPlayer); - } - } - DURABILITY_LOSS = 0; - } - } - - - public static boolean getBlockType(Block block){ - final String LIQUID = "liquid"; - final String BLOCK = "block"; - final String ORE = "ore"; - final String AIR = "air"; - String blockClass = ""; - - try { - blockClass = block.getClass().toString().toLowerCase(); - Utils.LOG_WARNING(blockClass); - if (blockClass.toLowerCase().contains(LIQUID)){ - Utils.LOG_WARNING(block.toString()+" is a Liquid."); - return false; - } - else if (blockClass.toLowerCase().contains(ORE)){ - Utils.LOG_WARNING(block.toString()+" is an Ore."); - return true; - } - else if (blockClass.toLowerCase().contains(AIR)){ - Utils.LOG_WARNING(block.toString()+" is Air."); - return false; - } - else if (blockClass.toLowerCase().contains(BLOCK)){ - Utils.LOG_WARNING(block.toString()+" is a block of some kind."); - return false; - } - else { - Utils.LOG_WARNING(block.toString()+" is mystery."); - return false; - } - } - catch(NullPointerException e){ - return false; - } - } - - -} diff --git a/src/Java/miscutil/core/util/VanillaChatCommandSender.java b/src/Java/miscutil/core/util/VanillaChatCommandSender.java deleted file mode 100644 index 76e80204de..0000000000 --- a/src/Java/miscutil/core/util/VanillaChatCommandSender.java +++ /dev/null @@ -1,35 +0,0 @@ -package miscutil.core.util; - -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.util.IChatComponent; -import net.minecraft.world.World; - -public interface VanillaChatCommandSender { - - /** - * Gets the name of this command sender (usually username, but possibly "Rcon") - */ - String getCommandSenderName(); - - IChatComponent func_145748_c_(); - - /** - * Notifies this sender of some sort of information. This is for messages intended to display to the user. Used - * for typical output (like "you asked for whether or not this game rule is set, so here's your answer"), warnings - * (like "I fetched this block for you by ID, but I'd like you to know that every time you do this, I die a little - * inside"), and errors (like "it's not called iron_pixacke, silly"). - */ - void addChatMessage(IChatComponent p_145747_1_); - - /** - * Returns true if the command sender is allowed to use the given command. - */ - boolean canCommandSenderUseCommand(int p_70003_1_, String p_70003_2_); - - /** - * Return the position for this command sender. - */ - ChunkCoordinates getPlayerCoordinates(); - - World getEntityWorld(); - } diff --git a/src/Java/miscutil/core/util/item/UtilsItems.java b/src/Java/miscutil/core/util/item/UtilsItems.java new file mode 100644 index 0000000000..590b0167be --- /dev/null +++ b/src/Java/miscutil/core/util/item/UtilsItems.java @@ -0,0 +1,179 @@ +package miscutil.core.util.item; + +import gregtech.api.util.GT_OreDictUnificator; +import miscutil.core.lib.LoadedMods; +import miscutil.core.util.Utils; +import miscutil.core.util.wrapper.var; +import net.minecraft.client.Minecraft; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; + +public class UtilsItems { + + public static ItemStack getItemStackOfItem(Boolean modToCheck, String mod_itemname_meta){ + if (modToCheck){ + try{ + Item em = null; + + Item em1 = getItem(mod_itemname_meta); + Utils.LOG_WARNING("Found: "+em1.toString()); + if (em1 != null){ + em = em1; + } + if (em != null ){ + ItemStack returnStack = new ItemStack(em,1); + return returnStack; + } + Utils.LOG_WARNING(mod_itemname_meta+" not found."); + return null; + } catch (NullPointerException e) { + Utils.LOG_ERROR(mod_itemname_meta+" not found. [NULL]"); + return null; + } + } + return null; + } + + public static ItemStack getSimpleStack(Item x){ + try { + 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 { + Item em = null; + Item em1 = getItem(FQRN); + Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); + if (em1 != null){ + em = em1; + } + if (em != null){ + + ItemStack metaStack = new ItemStack(em,1,meta); + GT_OreDictUnificator.registerOre(oreDictName, metaStack); + + /*ItemStack itemStackWithMeta = new ItemStack(em,1,meta); + GT_OreDictUnificator.registerOre(oreDictName, new ItemStack(itemStackWithMeta.getItem()));*/ + } + } catch (NullPointerException e) { + Utils.LOG_ERROR(itemName+" not found. [NULL]"); + } + } + + @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; + } + + @SuppressWarnings("unused") + public static ItemStack simpleMetaStack(String FQRN, int meta, int itemstackSize){ + 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(FQRN+" not found. [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 Item getItem(String fqrn) // fqrn = fully qualified resource name + { + String[] fqrnSplit = fqrn.split(":"); + return GameRegistry.findItem(fqrnSplit[0], fqrnSplit[1]); + } + + public static ItemStack getItemStack(String fqrn, int Size) // fqrn = fully qualified resource name + { + 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); + }*/ + + public static Item getItemInPlayersHand(){ + Minecraft mc = Minecraft.getMinecraft(); + Item heldItem = null; + + try{heldItem = mc.thePlayer.getHeldItem().getItem(); + }catch(NullPointerException e){return null;} + + if (heldItem != null){ + return heldItem; + } + + return null; + } + +} diff --git a/src/Java/miscutil/core/util/player/PlayerCache.java b/src/Java/miscutil/core/util/player/PlayerCache.java new file mode 100644 index 0000000000..5969766556 --- /dev/null +++ b/src/Java/miscutil/core/util/player/PlayerCache.java @@ -0,0 +1,127 @@ +package miscutil.core.util.player; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.OutputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Properties; + +import miscutil.core.lib.CORE; +import miscutil.core.util.Utils; + +public class PlayerCache { + + private static final File cache = new File("PlayerCache.dat"); + + public static final void initCache() { + if (CORE.PlayerCache == null || CORE.PlayerCache.equals(null)){ + try { + CORE.PlayerCache = PlayerCache.readPropertiesFileAsMap(); + Utils.LOG_INFO("Loaded PlayerCache.dat"); + } catch (Exception e) { + Utils.LOG_INFO("Failed to initialise PlayerCache.dat"); + PlayerCache.createPropertiesFile("CACHE_FILE_=", "THIS_CONTAINS_PLAYERDATA"); + //e.printStackTrace(); + } + } + } + + public static void createPropertiesFile(String playerName, String playerUUIDasString) { + try { + Properties props = new Properties(); + props.setProperty(playerName+" ", playerUUIDasString); + OutputStream out = new FileOutputStream(cache); + props.store(out, "Player Cache."); + Utils.LOG_INFO("Created an empty PlayerCache.dat for future use."); + } + catch (Exception e ) { + e.printStackTrace(); + } + } + + public static void appendParamChanges(String playerName, String playerUUIDasString) { + Properties properties = new Properties(); + try { + Utils.LOG_WARNING("Attempting to load "+cache.getName()); + properties.load(new FileInputStream(cache)); + if (properties == null || properties.equals(null)){ + Utils.LOG_WARNING("Null properties"); + } + else { + Utils.LOG_WARNING("Loaded PlayerCache.dat"); + properties.setProperty(playerName+"_", playerUUIDasString); + FileOutputStream fr=new FileOutputStream(cache); + properties.store(fr, "Player Cache."); + fr.close(); + } + + } catch (IOException e) { + Utils.LOG_WARNING("No PlayerCache file found, creating one."); + createPropertiesFile(playerName, playerUUIDasString); + } + } + + /** + * Reads a "properties" file, and returns it as a Map + * (a collection of key/value pairs). + * + * Credit due to Alvin Alexander - http://alvinalexander.com/java/java-properties-file-map-example?nocache=1#comment-8215 + * Changed slightly as the filename and delimiter are constant in my case. + * + * @param filename The properties filename to read. + * @param delimiter The string (or character) that separates the key + * from the value in the properties file. + * @return The Map that contains the key/value pairs. + * @throws Exception + */ + public static Map readPropertiesFileAsMap() throws Exception { + String delimiter = "="; + @SuppressWarnings({ "rawtypes", "unchecked" }) + Map map = new HashMap(); + BufferedReader reader = new BufferedReader(new FileReader(cache)); + String line; + while ((line = reader.readLine()) != null) + { + if (line.trim().length()==0) continue; + if (line.charAt(0)=='#') continue; + // assumption here is that proper lines are like "String : http://xxx.yyy.zzz/foo/bar", + // and the ":" is the delimiter + int delimPosition = line.indexOf(delimiter); + String key = line.substring(0, delimPosition-1).trim(); + String value = line.substring(delimPosition+1).trim(); + map.put(key, value); + } + reader.close(); + CORE.PlayerCache = map; + return map; + } + + public static String lookupPlayerByUUID(String UUID){ + try { + Map map = null; + try { + map = readPropertiesFileAsMap(); + } catch (Exception e) { + Utils.LOG_ERROR("With "+e.getCause()+" as cause, Caught Exception: "+e.toString()); + //e.printStackTrace(); + } + for (Entry entry : map.entrySet()) { + if (Objects.equals(UUID, entry.getValue())) { + return entry.getKey(); + } + } + return null; + } catch (NullPointerException e) { + Utils.LOG_ERROR("With "+e.getCause()+" as cause, Caught Exception: "+e.toString()); + //e.printStackTrace(); + } + return null; +} +} diff --git a/src/Java/miscutil/core/util/player/UtilsMining.java b/src/Java/miscutil/core/util/player/UtilsMining.java new file mode 100644 index 0000000000..81e69c1aff --- /dev/null +++ b/src/Java/miscutil/core/util/player/UtilsMining.java @@ -0,0 +1,180 @@ +package miscutil.core.util.player; + +import miscutil.core.util.Utils; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class UtilsMining { + + private static boolean durabilityDamage = false; + private static ItemStack stack; + + public static Boolean canPickaxeBlock(Block currentBlock, World currentWorld){ + String correctTool = ""; + if (!currentWorld.isRemote){ + try { + correctTool = currentBlock.getHarvestTool(0); + //Utils.LOG_WARNING(correctTool); + if (correctTool.equals("pickaxe")){ + return true;} + } catch (NullPointerException e){ + return false;} + } + return false; + } + + private static void removeBlockAndDropAsItem(World world, int X, int Y, int Z){ + try { + Block block = world.getBlock(X, Y, Z); + if (canPickaxeBlock(block, world)){ + if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + + } + else { + Utils.LOG_WARNING("Incorrect Tool for mining this block."); + } + } + } catch (NullPointerException e){ + + } + } + + public static void customMine(World world, String FACING, EntityPlayer aPlayer){ + + float DURABILITY_LOSS = 0; + if (!world.isRemote){ + int X = 0; + int Y = 0; + int Z = 0; + + if (FACING.equals("below") || FACING.equals("above")){ + + //Set Player Facing + X = (int) aPlayer.posX; + Utils.LOG_WARNING("Setting Variable X: "+X); + if (FACING.equals("above")){ + Z = (int) aPlayer.posY + 1; + Utils.LOG_WARNING("Setting Variable Y: "+Y); + } + else { + Z = (int) aPlayer.posY - 1; + Utils.LOG_WARNING("Setting Variable Y: "+Y);} + Z = (int) aPlayer.posZ; + Utils.LOG_WARNING("Setting Variable Z: "+Z); + + DURABILITY_LOSS = 0; + for(int i = -2; i < 3; i++) { + for(int j = -2; j < 3; j++) { + for(int k = -2; k < 3; k++) { +/*// float dur = calculateDurabilityLoss(world, X + i, Y + k, Z + j); +// DURABILITY_LOSS = (DURABILITY_LOSS + dur); +// Utils.LOG_WARNING("Added Loss: "+dur); +*/ removeBlockAndDropAsItem(world, X + i, Y + k, Z + j); + } + } + } + } + + else if (FACING.equals("facingEast") || FACING.equals("facingWest")){ + + //Set Player Facing + Z = (int) aPlayer.posZ; + Y = (int) aPlayer.posY; + if (FACING.equals("facingEast")){ + X = (int) aPlayer.posX + 1;} + else { + X = (int) aPlayer.posX - 1;} + + + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + for(int k = -1; k < 2; k++) { + /*float dur = calculateDurabilityLoss(world, X+k, Y + i, Z + j); + DURABILITY_LOSS = (DURABILITY_LOSS + dur); + Utils.LOG_WARNING("Added Loss: "+dur);*/ + removeBlockAndDropAsItem(world, X+k, Y + i, Z + j); + } + } + } + } + + else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")){ + + //Set Player Facing + X = (int) aPlayer.posX; + Y = (int) aPlayer.posY; + + if (FACING.equals("facingNorth")){ + Z = (int) aPlayer.posZ + 1;} + else { + Z = (int) aPlayer.posZ - 1;} + + DURABILITY_LOSS = 0; + for(int i = -1; i < 2; i++) { + for(int j = -1; j < 2; j++) { + for(int k = -1; k < 2; k++) { + /*float dur = calculateDurabilityLoss(world, X + j, Y + i, Z+k); + DURABILITY_LOSS = (DURABILITY_LOSS + dur); + Utils.LOG_WARNING("Added Loss: "+dur);*/ + removeBlockAndDropAsItem(world, X + j, Y + i, Z+k); + } + } + } + } + + //Set Durability damage to the item + if (durabilityDamage == true){ + Utils.LOG_WARNING("Total Loss: "+(int)DURABILITY_LOSS); + if (stack.getItemDamage() < (stack.getMaxDamage()-DURABILITY_LOSS)){ + stack.damageItem((int) DURABILITY_LOSS, aPlayer); + } + } + DURABILITY_LOSS = 0; + } + } + + + public static boolean getBlockType(Block block){ + final String LIQUID = "liquid"; + final String BLOCK = "block"; + final String ORE = "ore"; + final String AIR = "air"; + String blockClass = ""; + + try { + blockClass = block.getClass().toString().toLowerCase(); + Utils.LOG_WARNING(blockClass); + if (blockClass.toLowerCase().contains(LIQUID)){ + Utils.LOG_WARNING(block.toString()+" is a Liquid."); + return false; + } + else if (blockClass.toLowerCase().contains(ORE)){ + Utils.LOG_WARNING(block.toString()+" is an Ore."); + return true; + } + else if (blockClass.toLowerCase().contains(AIR)){ + Utils.LOG_WARNING(block.toString()+" is Air."); + return false; + } + else if (blockClass.toLowerCase().contains(BLOCK)){ + Utils.LOG_WARNING(block.toString()+" is a block of some kind."); + return false; + } + else { + Utils.LOG_WARNING(block.toString()+" is mystery."); + return false; + } + } + catch(NullPointerException e){ + return false; + } + } + + +} diff --git a/src/Java/miscutil/core/util/recipe/RECIPES_GREGTECH.java b/src/Java/miscutil/core/util/recipe/RECIPES_GREGTECH.java deleted file mode 100644 index b6f6e778de..0000000000 --- a/src/Java/miscutil/core/util/recipe/RECIPES_GREGTECH.java +++ /dev/null @@ -1,85 +0,0 @@ -package miscutil.core.util.recipe; - -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_OreDictUnificator; -import miscutil.core.lib.CORE; -import miscutil.core.util.Utils; -import miscutil.core.util.UtilsItems; - -public class RECIPES_GREGTECH { - - public static void run(){ - Utils.LOG_INFO("Loading Recipes through GregAPI for Industrial Multiblocks."); - execute(); - } - - private static void execute(){ - cokeOvenRecipes(); - assemblerRecipes(); - - } - - private static void cokeOvenRecipes(){ - Utils.LOG_INFO("Loading Recipes for Industrial Coking Oven."); - - try { - - //GT Logs to Charcoal Recipe - //With Sulfuric Acid - CORE.RA.addCokeOvenRecipe( - GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 2L), //Input 1 - GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 1L), //Input 2 - Materials.SulfuricAcid.getFluid(20L), //Fluid Input - Materials.Creosote.getFluid(175L), //Fluid Output - GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 2L), //Item Output - 800, //Time in ticks - 30); //EU - }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} - try { - - //Coal -> Coke Recipe - //With Sulfuric Acid - CORE.RA.addCokeOvenRecipe( - GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 2L), //Input 1 - GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 1L), //Input 2 - Materials.SulfuricAcid.getFluid(60L), //Fluid Input - Materials.Creosote.getFluid(250L), //Fluid Output - UtilsItems.getItemStack("Railcraft:fuel.coke", 2), //Item Output - 600, //Time in ticks - 120); //EU - }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} - - try { - //GT Logs to Charcoal Recipe - //Without Sulfuric Acid - CORE.RA.addCokeOvenRecipe( - GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 2L), //Input 1 - GT_OreDictUnificator.get(OrePrefixes.log, Materials.Wood, 1L), //Input 2 - Materials.SaltWater.getFluid(85L), //Fluid Input - Materials.Creosote.getFluid(145L), //Fluid Output - GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 2L), //Item Output - 1200, //Time in ticks - 30); //EU - }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} - - try { - //Coal -> Coke Recipe - //Without Sulfuric Acid - CORE.RA.addCokeOvenRecipe( - GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 2L), //Input 1 - GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Coal, 1L), //Input 2 - Materials.SaltWater.getFluid(185L), //Fluid Input - Materials.Creosote.getFluid(200L), //Fluid Output - UtilsItems.getItemStack("Railcraft:fuel.coke", 2), //Item Output - 900, //Time in ticks - 120); //EU - }catch (NullPointerException e){Utils.LOG_INFO("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE");} - } - - private static void assemblerRecipes(){ - //GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 6L), ItemList.Casing_Turbine.get(1L, new Object[0]), ItemList.Casing_Turbine2.get(1L, new Object[0]), 50, 16); - //GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 6L), ItemList.Casing_Turbine.get(1L, new Object[0]), ItemList.Casing_Turbine3.get(1L, new Object[0]), 50, 16); - - } -} \ No newline at end of file diff --git a/src/Java/miscutil/core/util/recipe/RECIPES_MTWRAPPER.java b/src/Java/miscutil/core/util/recipe/RECIPES_MTWRAPPER.java deleted file mode 100644 index e30b3f1c04..0000000000 --- a/src/Java/miscutil/core/util/recipe/RECIPES_MTWRAPPER.java +++ /dev/null @@ -1,113 +0,0 @@ -package miscutil.core.util.recipe; - -import java.util.ArrayList; - -import miscutil.core.util.Utils; -import miscutil.core.util.UtilsItems; -import miscutil.core.util.wrapper.var; -import net.minecraft.item.ItemStack; - -public class RECIPES_MTWRAPPER { - - public static int MT_RECIPES_LOADED = 0; - public static int MT_RECIPES_FAILED = 0; - - static var chestWood = new var("minecraft:chest>"); - static var slabWood = new var("ore:slabWood>"); - static var gemNetherQuartz = new var("ore:gemNetherQuartz>"); - static var glass = new var("ore:blockGlass>"); - static var sensorDaylight = new var("minecraft:daylight_detector>"); - static var blazeRod = new var("minecraft:blaze_rod>"); - static var saw = new var("ore:craftingToolSaw>"); - static var logWood = new var("ore:logWood>"); - static var button = new var("minecraft:stone_button>"); - static var stoneBlock = new var("minecraft:stone>"); - - public static void run(){ - /*addShaped(button.getStack(2), - null, stoneBlock, null, - null, stoneBlock, null, - null, null, null);*/ - /*addShaped(stoneStick.getStack(1), - stoneBlock, null, null, - stoneBlock, null, null, - null, null, null);*/ - addShaped(chestWood.getStack(2), - logWood, logWood, logWood, - logWood, null, logWood, - logWood, logWood, logWood); - addShaped(chestWood.getStack(4), - logWood, logWood, logWood, - logWood, saw, logWood, - logWood, logWood, logWood); - //Recipe Fixes - //remove(sensorDaylight); - addShaped(sensorDaylight.getStack(1), - glass, glass, glass, - gemNetherQuartz, gemNetherQuartz, gemNetherQuartz, - slabWood, slabWood, slabWood); - /*addShaped(ironBars .getStack( 8), - null, "", null, - "", "", "", - "", "", "");*/ - } - - - public static void addShaped(Object item_Output, - Object item_1, Object item_2, Object item_3, - Object item_4, Object item_5, Object item_6, - Object item_7, Object item_8, Object item_9){ - - - /* - * - * var item_1, var item_2, var item_3, - var item_4, var item_5, var item_6, - var item_7, var item_8, var item_9 - * - * - */ - - ItemStack outputItem = UtilsItems.getCorrectStacktype(item_Output, 1); - - ArrayList validSlots = new ArrayList(); - String a,b,c,d,e,f,g,h,i; - if (item_1 == null){ a = " ";} else { a = "1";validSlots.add('1');validSlots.add(item_1);} - if (item_2 == null){ b = " ";} else { b = "2";validSlots.add('2');validSlots.add(item_2);} - if (item_3 == null){ c = " ";} else { c = "3";validSlots.add('3');validSlots.add(item_3);} - if (item_4 == null){ d = " ";} else { d = "4";validSlots.add('4');validSlots.add(item_4);} - if (item_5 == null){ e = " ";} else { e = "5";validSlots.add('5');validSlots.add(item_5);} - if (item_6 == null){ f = " ";} else { f = "6";validSlots.add('6');validSlots.add(item_6);} - if (item_7 == null){ g = " ";} else { g = "7";validSlots.add('7');validSlots.add(item_7);} - if (item_8 == null){ h = " ";} else { h = "8";validSlots.add('8');validSlots.add(item_8);} - if (item_9 == null){ i = " ";} else { i = "9";validSlots.add('9');validSlots.add(item_9);} - - String lineOne = a+b+c; - String lineTwo = d+e+f; - String lineThree = g+h+i; - validSlots.add(0, lineOne); - validSlots.add(1, lineTwo); - validSlots.add(2, lineThree); - - try { - UtilsItems.recipeBuilder((Object[]) validSlots.toArray(), outputItem.copy()); - MT_RECIPES_LOADED++; - } - catch(NullPointerException | ClassCastException k){ - k.getMessage(); - k.getClass(); - k.printStackTrace(); - k.getLocalizedMessage(); - Utils.LOG_WARNING("@@@: Invalid Recipe detected for: "+((var) item_Output).getsanitizedName()); - MT_RECIPES_FAILED++; - } - } - - public static void addShapeless(){ - - } - - - -} - diff --git a/src/Java/miscutil/core/util/recipe/RECIPES_Machines.java b/src/Java/miscutil/core/util/recipe/RECIPES_Machines.java deleted file mode 100644 index 9d324e69f0..0000000000 --- a/src/Java/miscutil/core/util/recipe/RECIPES_Machines.java +++ /dev/null @@ -1,458 +0,0 @@ -package miscutil.core.util.recipe; - -import gregtech.api.enums.ItemList; -import miscutil.core.lib.LoadedMods; -import miscutil.core.util.Utils; -import miscutil.core.util.UtilsItems; -import miscutil.gregtech.api.enums.GregtechItemList; -import net.minecraft.item.ItemStack; - -public class RECIPES_Machines { - - //Outputs - //static ItemStack RECIPE_BufferCore_ULV = new ItemStack(GregtechEnergyBuffer.itemBufferCore); - static ItemStack RECIPE_SteamCondenser = GregtechItemList.Condensor_MAX.get(1); - static ItemStack RECIPE_IronBlastFurnace = GregtechItemList.Machine_Iron_BlastFurnace.get(1); - static ItemStack RECIPE_IronPlatedBricks = GregtechItemList.Casing_IronPlatedBricks.get(1); - static ItemStack RECIPE_Buffer_ULV = GregtechItemList.Energy_Buffer_1by1_ULV.get(1); - static ItemStack RECIPE_Buffer_LV = GregtechItemList.Energy_Buffer_1by1_LV.get(1); - static ItemStack RECIPE_Buffer_MV = GregtechItemList.Energy_Buffer_1by1_MV.get(1); - static ItemStack RECIPE_Buffer_HV = GregtechItemList.Energy_Buffer_1by1_HV.get(1); - static ItemStack RECIPE_Buffer_EV = GregtechItemList.Energy_Buffer_1by1_EV.get(1); - static ItemStack RECIPE_Buffer_IV = GregtechItemList.Energy_Buffer_1by1_IV.get(1); - static ItemStack RECIPE_Buffer_LuV = GregtechItemList.Energy_Buffer_1by1_LuV.get(1); - static ItemStack RECIPE_Buffer_ZPM = GregtechItemList.Energy_Buffer_1by1_ZPM.get(1); - static ItemStack RECIPE_Buffer_UV = GregtechItemList.Energy_Buffer_1by1_UV.get(1); - static ItemStack RECIPE_Buffer_MAX = GregtechItemList.Energy_Buffer_1by1_MAX.get(1); - //Industrial Centrifuge - static ItemStack RECIPE_IndustrialCentrifugeController = GregtechItemList.Industrial_Centrifuge.get(1); - static ItemStack RECIPE_IndustrialCentrifugeCasing = GregtechItemList.Casing_Centrifuge1.get(1); - //Industrial Coke Oven - static ItemStack RECIPE_IndustrialCokeOvenController = GregtechItemList.Industrial_CokeOven.get(1); - static ItemStack RECIPE_IndustrialCokeOvenFrame = GregtechItemList.Casing_CokeOven.get(1); - static ItemStack RECIPE_IndustrialCokeOvenCasingA = GregtechItemList.Casing_CokeOven_Coil1.get(1); - static ItemStack RECIPE_IndustrialCokeOvenCasingB = GregtechItemList.Casing_CokeOven_Coil2.get(1); - - - //Buffer Cores - static ItemStack RECIPE_BufferCore_ULV = UtilsItems.getItemStack("miscutils:item.itemBufferCore1", 1); - static ItemStack RECIPE_BufferCore_LV = UtilsItems.getItemStack("miscutils:item.itemBufferCore2", 1); - static ItemStack RECIPE_BufferCore_MV = UtilsItems.getItemStack("miscutils:item.itemBufferCore3", 1); - static ItemStack RECIPE_BufferCore_HV = UtilsItems.getItemStack("miscutils:item.itemBufferCore4", 1); - static ItemStack RECIPE_BufferCore_EV = UtilsItems.getItemStack("miscutils:item.itemBufferCore5", 1); - static ItemStack RECIPE_BufferCore_IV = UtilsItems.getItemStack("miscutils:item.itemBufferCore6", 1); - static ItemStack RECIPE_BufferCore_LuV = UtilsItems.getItemStack("miscutils:item.itemBufferCore7", 1); - static ItemStack RECIPE_BufferCore_ZPM = UtilsItems.getItemStack("miscutils:item.itemBufferCore8", 1); - static ItemStack RECIPE_BufferCore_UV = UtilsItems.getItemStack("miscutils:item.itemBufferCore9", 1); - static ItemStack RECIPE_BufferCore_MAX = UtilsItems.getItemStack("miscutils:item.itemBufferCore10", 1); - - - //Wire - static String wireTier1 = "wireGt08Lead"; - static String wireTier2 = "wireGt08Tin"; - static String wireTier3 = "wireGt08Copper"; - static String wireTier4 = "wireGt08Gold"; - static String wireTier5 = "wireGt08Aluminium"; - static String wireTier6 = "wireGt08Tungsten"; - static String wireTier7 = "wireGt08Osmium"; - static String wireTier8 = "wireGt08Naquadah"; - static String wireTier9 = "wireGt08Superconductor"; - static String wireTier10 = "wireGt16Superconductor"; - - //Wire - static String cableTier1 = "cableGt04Lead"; - static String cableTier2 = "cableGt04Tin"; - static String cableTier3 = "cableGt04Copper"; - static String cableTier4 = "cableGt04Gold"; - static String cableTier5 = "cableGt04Aluminium"; - static String cableTier6 = "cableGt04Tungsten"; - static String cableTier7 = "cableGt04Osmium"; - static String cableTier8 = "cableGt04Naquadah"; - static String cableTier9 = "cableGt04NiobiumTitanium"; - static String cableTier10 = "cableGt08NiobiumTitanium"; - - - //Plates - static String plateTier1 = "plateLead"; - static String plateTier2 = "plateTin"; - static String plateTier3 = "plateCopper"; - static String plateTier4 = "plateGold"; - static String plateTier5 = "plateAluminium"; - static String plateTier6 = "plateThorium"; - static String plateTier7 = "plateTungsten"; - static String plateTier8 = "plateTungstenSteel"; - static String plateTier9 = "plateOsmium"; - static String plateTier10 = "plateNaquadah"; - static String plateTier11 = "plateNeutronium"; - - //rods - static String rodTier1 = "stickLead"; - static String rodTier2 = "stickTin"; - static String rodTier3 = "stickCopper"; - static String rodTier4 = "stickGold"; - static String rodTier5 = "stickAluminium"; - static String rodTier6 = "stickThorium"; - static String rodTier7 = "stickTungsten"; - static String rodTier8 = "stickTungstenSteel"; - static String rodTier9 = "stickOsmium"; - static String rodTier10 = "stickNaquadah"; - static String rodTier11 = "stickNeutronium"; - - - //Machine Casings - static ItemStack machineCasing_ULV = ItemList.Casing_ULV.get(1); - static ItemStack machineCasing_LV = ItemList.Casing_LV.get(1); - static ItemStack machineCasing_MV = ItemList.Casing_MV.get(1); - static ItemStack machineCasing_HV = ItemList.Casing_HV.get(1); - static ItemStack machineCasing_EV = ItemList.Casing_EV.get(1); - static ItemStack machineCasing_IV = ItemList.Casing_IV.get(1); - static ItemStack machineCasing_LuV = ItemList.Casing_LuV.get(1); - static ItemStack machineCasing_ZPM = ItemList.Casing_ZPM.get(1); - static ItemStack machineCasing_UV = ItemList.Casing_UV.get(1); - static ItemStack machineCasing_MAX = ItemList.Casing_MAX.get(1); - - //Gearbox Casings - static ItemStack gearboxCasing_Tier_1 = ItemList.Casing_Gearbox_Bronze.get(1); - static ItemStack gearboxCasing_Tier_2 = ItemList.Casing_Gearbox_Steel.get(1); - static ItemStack gearboxCasing_Tier_3 = ItemList.Casing_Gearbox_Titanium.get(1); - static ItemStack gearboxCasing_Tier_4 = ItemList.Casing_Gearbox_TungstenSteel.get(1); - - //Cables - static String cableGt02Electrum = "cableGt02Electrum"; - - - //Plates - static String plateElectricalSteel= "plateElectricalSteel"; - static String plateEnergeticAlloy= "plateEnergeticAlloy"; - static String plateCobalt = "plateCobalt"; - static String plateBronze = "plateBronze"; - static String plateSteel = "plateSteel"; - - //Pipes - static String pipeLargeCopper="pipeLargeCopper"; - static String pipeHugeSteel="pipeHugeSteel"; - static String pipeHugeStainlessSteel="pipeHugeStainlessSteel"; - static String pipeHugeTitanium="pipeHugeTitanium"; - - //Lava Boiler - static ItemStack boiler_Coal = ItemList.Machine_Bronze_Boiler.get(1); - static ItemStack blockBricks = UtilsItems.getItemStack("minecraft:brick_block", 1); - - //Batteries - static String batteryBasic = "batteryBasic"; - static String batteryAdvanced = "batteryAdvanced"; - static String batteryElite = "batteryElite"; - static String batteryMaster = "batteryMaster"; - static String batteryUltimate = "batteryUltimate"; - - //Circuits - static String circuitPrimitive = "circuitPrimitive"; - static String circuitBasic = "circuitBasic"; - static String circuitGood = "circuitGood"; - static String circuitAdvanced = "circuitAdvanced"; - static String circuitData = "circuitData"; - static String circuitElite = "circuitElite"; - static String circuitMaster = "circuitMaster"; - static String circuitUltimate = "circuitUltimate"; - - //Machine Components - static ItemStack electricMotor_LV = ItemList.Electric_Motor_LV.get(1); - static ItemStack electricMotor_MV = ItemList.Electric_Motor_MV.get(1); - static ItemStack electricMotor_HV = ItemList.Electric_Motor_HV.get(1); - static ItemStack electricMotor_EV = ItemList.Electric_Motor_EV.get(1); - static ItemStack electricMotor_IV = ItemList.Electric_Motor_IV.get(1); - static ItemStack electricPump_LV = ItemList.Electric_Pump_LV.get(1); - static ItemStack electricPump_MV = ItemList.Electric_Pump_MV.get(1); - static ItemStack electricPump_HV = ItemList.Electric_Pump_HV.get(1); - static ItemStack electricPump_EV = ItemList.Electric_Pump_EV.get(1); - static ItemStack electricPump_IV = ItemList.Electric_Pump_IV.get(1); - static ItemStack electricPiston_LV = ItemList.Electric_Piston_LV.get(1); - static ItemStack electricPiston_MV = ItemList.Electric_Piston_MV.get(1); - static ItemStack electricPiston_HV = ItemList.Electric_Piston_HV.get(1); - static ItemStack electricPiston_EV = ItemList.Electric_Piston_EV.get(1); - static ItemStack electricPiston_IV = ItemList.Electric_Piston_IV.get(1); - static ItemStack robotArm_LV = ItemList.Robot_Arm_LV.get(1); - static ItemStack robotArm_MV = ItemList.Robot_Arm_MV.get(1); - static ItemStack robotArm_HV = ItemList.Robot_Arm_HV.get(1); - static ItemStack robotArm_EV = ItemList.Robot_Arm_EV.get(1); - static ItemStack robotArm_IV = ItemList.Robot_Arm_IV.get(1); - static ItemStack conveyorModule_LV = ItemList.Conveyor_Module_LV.get(1); - static ItemStack conveyorModule_MV = ItemList.Conveyor_Module_MV.get(1); - static ItemStack conveyorModule_HV = ItemList.Conveyor_Module_HV.get(1); - static ItemStack conveyorModule_EV = ItemList.Conveyor_Module_EV.get(1); - static ItemStack conveyorModule_IV = ItemList.Conveyor_Module_IV.get(1); - static ItemStack emitter_LV = ItemList.Emitter_LV.get(1); - static ItemStack emitter_MV = ItemList.Emitter_MV.get(1); - static ItemStack emitter_HV = ItemList.Emitter_HV.get(1); - static ItemStack emitter_EV = ItemList.Emitter_EV.get(1); - static ItemStack emitter_IV = ItemList.Emitter_IV.get(1); - static ItemStack fieldGenerator_LV = ItemList.Field_Generator_LV.get(1); - static ItemStack fieldGenerator_MV = ItemList.Field_Generator_MV.get(1); - static ItemStack fieldGenerator_HV = ItemList.Field_Generator_HV.get(1); - static ItemStack fieldGenerator_EV = ItemList.Field_Generator_EV.get(1); - static ItemStack fieldGenerator_IV = ItemList.Field_Generator_IV.get(1); - static ItemStack sensor_LV = ItemList.Sensor_LV.get(1); - static ItemStack sensor_MV = ItemList.Sensor_MV.get(1); - static ItemStack sensor_HV = ItemList.Sensor_HV.get(1); - static ItemStack sensor_EV = ItemList.Sensor_EV.get(1); - static ItemStack sensor_IV = ItemList.Sensor_IV.get(1); - - //Misc - static ItemStack INPUT_RCCokeOvenBlock = UtilsItems.getItemStackWithMeta(LoadedMods.Railcraft, "Railcraft:machine.alpha", "Coke_Oven_RC", 7, 1); - - - - //RobotArm, Conveyor, Emitter, Sensor, Field Generator - - - public static final void RECIPES_LOAD(){ - run(); - Utils.LOG_INFO("Loading Recipes for the Various machine blocks."); - } - - private static void run(){ - //Staballoy Dust - TEMP - UtilsItems.recipeBuilder("dustTitanium", "dustUranium", "dustUranium", - "dustUranium", "dustUranium", "dustUranium", - "dustUranium", "dustUranium", "dustUranium", - RECIPES_Shapeless.dustStaballoy); - - //Buffer Core - UtilsItems.recipeBuilder( - plateTier1, cableTier1, plateTier1, - circuitPrimitive, batteryBasic, circuitPrimitive, - plateTier1, cableTier1, plateTier1, - RECIPE_BufferCore_ULV); - UtilsItems.recipeBuilder( - plateTier2, cableTier2, plateTier2, - circuitBasic, batteryBasic, circuitBasic, - plateTier2, cableTier2, plateTier2, - RECIPE_BufferCore_LV); - UtilsItems.recipeBuilder( - plateTier3, cableTier3, plateTier3, - circuitGood, batteryAdvanced, circuitGood, - plateTier3, cableTier3, plateTier3, - RECIPE_BufferCore_MV); - UtilsItems.recipeBuilder( - plateTier4, cableTier4, plateTier4, - circuitAdvanced, batteryAdvanced, circuitAdvanced, - plateTier4, cableTier4, plateTier4, - RECIPE_BufferCore_HV); - UtilsItems.recipeBuilder( - plateTier5, cableTier5, plateTier5, - circuitData, batteryElite, circuitData, - plateTier5, cableTier5, plateTier5, - RECIPE_BufferCore_EV); - - UtilsItems.recipeBuilder( - plateTier6, cableTier6, plateTier6, - circuitData, batteryElite, circuitElite, - plateTier6, cableTier6, plateTier6, - RECIPE_BufferCore_IV); - UtilsItems.recipeBuilder( - plateTier7, cableTier7, plateTier7, - circuitElite, batteryMaster, circuitElite, - plateTier7, cableTier7, plateTier7, - RECIPE_BufferCore_LuV); - UtilsItems.recipeBuilder( - plateTier8, cableTier8, plateTier8, - circuitMaster, batteryMaster, circuitMaster, - plateTier8, cableTier8, plateTier8, - RECIPE_BufferCore_ZPM); - UtilsItems.recipeBuilder( - plateTier9, cableTier9, plateTier9, - circuitMaster, batteryUltimate, circuitUltimate, - plateTier9, cableTier9, plateTier9, - RECIPE_BufferCore_UV); - UtilsItems.recipeBuilder( - plateTier10, cableTier10, plateTier10, - circuitUltimate, batteryUltimate, circuitUltimate, - plateTier10, cableTier10, plateTier10, - RECIPE_BufferCore