From 6bf0797054c4fd015bb964aeb712d2a415ab750a Mon Sep 17 00:00:00 2001 From: Zixxl Date: Mon, 6 Jul 2015 17:42:39 +0200 Subject: [PATCH] Changes in ReflectionHelper --- .../modtweaker2/helpers/ReflectionHelper.java | 33 ++++++++++++- .../factorization/FactorizationHelper.java | 44 +++++++---------- .../mods/forestry/ForestryHelper.java | 43 +++++----------- .../mods/railcraft/RailcraftHelper.java | 46 ++++++++--------- .../mods/tconstruct/TConstructHelper.java | 49 +++++-------------- .../mods/tconstruct/handlers/Modifiers.java | 1 - .../mods/thermalexpansion/ThermalHelper.java | 22 +++------ .../thermalexpansion/handlers/Crucible.java | 3 +- .../thermalexpansion/handlers/Furnace.java | 3 +- .../thermalexpansion/handlers/Pulverizer.java | 3 +- .../thermalexpansion/handlers/Sawmill.java | 3 +- .../thermalexpansion/handlers/Smelter.java | 3 +- .../thermalexpansion/handlers/Transposer.java | 5 +- 13 files changed, 115 insertions(+), 143 deletions(-) diff --git a/src/main/java/modtweaker2/helpers/ReflectionHelper.java b/src/main/java/modtweaker2/helpers/ReflectionHelper.java index 281dd86..0bfe727 100644 --- a/src/main/java/modtweaker2/helpers/ReflectionHelper.java +++ b/src/main/java/modtweaker2/helpers/ReflectionHelper.java @@ -5,16 +5,47 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; public class ReflectionHelper { + + public static T getInstance(Constructor constructor, Object... arguments) { + try { + return constructor.newInstance(arguments); + } catch (Exception e) { LogHelper.logError("Exception creating instance of " + constructor.getClass().getName(), e); } + + return null; + } + + public static T getInstance(Class clazz, Object... arguments) { + Class[] classArray = new Class[arguments.length]; + + for(int i = 0; i < arguments.length; i++) { + classArray[i] = arguments[i].getClass(); + } + + Constructor constructor = getConstructor(clazz, classArray); + + return getInstance(constructor, arguments); + } + public static Constructor getConstructor(String string, Class... types) { try { Class clazz = Class.forName(string); Constructor constructor = clazz.getDeclaredConstructor(types); constructor.setAccessible(true); return constructor; - } catch (Exception ex) {} + } catch (Exception ex) { LogHelper.logError("Exception creating instance of " + string, ex); } return null; } + + public static Constructor getConstructor(Class clazz, Class... types) { + try { + Constructor constructor = clazz.getDeclaredConstructor(types); + constructor.setAccessible(true); + return constructor; + } catch (Exception ex) { LogHelper.logError("Exception getting constructore of " + clazz.getName(), ex); } + + return null; + } public static T getObject(Object o, String... fieldName) { Class cls = o.getClass(); diff --git a/src/main/java/modtweaker2/mods/factorization/FactorizationHelper.java b/src/main/java/modtweaker2/mods/factorization/FactorizationHelper.java index 7e48644..37d5372 100644 --- a/src/main/java/modtweaker2/mods/factorization/FactorizationHelper.java +++ b/src/main/java/modtweaker2/mods/factorization/FactorizationHelper.java @@ -2,9 +2,9 @@ package modtweaker2.mods.factorization; import static modtweaker2.helpers.ReflectionHelper.getStaticObject; -import java.lang.reflect.Constructor; import java.util.List; +import modtweaker2.helpers.ReflectionHelper; import net.minecraft.item.ItemStack; public class FactorizationHelper { @@ -22,36 +22,30 @@ public class FactorizationHelper { private FactorizationHelper() {} + @SuppressWarnings("unchecked") public static Object getLaceratorRecipe(ItemStack input, ItemStack output, float probability) { - try { - Class clazz = Class.forName("factorization.oreprocessing.TileEntityGrinder$GrinderRecipe"); - Constructor constructor = clazz.getDeclaredConstructor(Object.class, ItemStack.class, float.class); - constructor.setAccessible(true); - return constructor.newInstance(input, output, probability); - } catch (Exception e) { - throw new NullPointerException("Failed to instantiate Lacerator Recipe"); - } + return ReflectionHelper.getInstance(ReflectionHelper.getConstructor("factorization.oreprocessing.TileEntityGrinder$GrinderRecipe", Object.class, ItemStack.class, float.class), + input, + output, + probability); } + @SuppressWarnings("unchecked") public static Object getSlagFurnaceRecipe(ItemStack input, float chance1, ItemStack output1, float chance2, ItemStack output2) { - try { - Class clazz = Class.forName("factorization.oreprocessing.TileEntitySlagFurnace$SmeltingResult"); - Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, float.class, ItemStack.class, float.class, ItemStack.class); - constructor.setAccessible(true); - return constructor.newInstance(input, chance1, output1, chance2, output2); - } catch (Exception e) { - throw new NullPointerException("Failed to instantiate SmeltingResult"); - } + return ReflectionHelper.getInstance(ReflectionHelper.getConstructor("factorization.oreprocessing.TileEntitySlagFurnace$SmeltingResult", ItemStack.class, float.class, ItemStack.class, float.class, ItemStack.class), + input, + chance1, + output1, + chance2, + output2); } + @SuppressWarnings("unchecked") public static Object getCrystallizerRecipe(ItemStack input, ItemStack output, ItemStack solution, float output_count) { - try { - Class clazz = Class.forName("factorization.oreprocessing.TileEntityCrystallizer$CrystalRecipe"); - Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, ItemStack.class, float.class, ItemStack.class); - constructor.setAccessible(true); - return constructor.newInstance(input, output, output_count, solution); - } catch (Exception e) { - throw new NullPointerException("Failed to instantiate CrystalRecipe"); - } + return ReflectionHelper.getInstance(ReflectionHelper.getConstructor("factorization.oreprocessing.TileEntityCrystallizer$CrystalRecipe", ItemStack.class, ItemStack.class, float.class, ItemStack.class), + input, + output, + output_count, + solution); } } \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/forestry/ForestryHelper.java b/src/main/java/modtweaker2/mods/forestry/ForestryHelper.java index 5733957..53a6779 100644 --- a/src/main/java/modtweaker2/mods/forestry/ForestryHelper.java +++ b/src/main/java/modtweaker2/mods/forestry/ForestryHelper.java @@ -1,51 +1,30 @@ package modtweaker2.mods.forestry; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashSet; +import modtweaker2.helpers.ReflectionHelper; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; +import forestry.factory.gadgets.MachineCarpenter; public class ForestryHelper { @SuppressWarnings("unchecked") public static void addCarpenterRecipeBox(ItemStack box) { - Class clazz; - try { - clazz = Class.forName("forestry.factory.gadgets.MachineCarpenter$RecipeManager"); - Field field_box = clazz.getDeclaredField("boxes"); - field_box.setAccessible(true); - - ArrayList recipeBoxes = (ArrayList) field_box.get(clazz); - recipeBoxes.add(box); - - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } + ArrayList recipeBoxes = (ArrayList) ReflectionHelper.getStaticObject(MachineCarpenter.RecipeManager.class, "boxes"); + + if(recipeBoxes != null) { + recipeBoxes.add(box); + } } @SuppressWarnings("unchecked") public static void addCarpenterRecipeFluids(Fluid newFluid) { - Class clazz; - try { - clazz = Class.forName("forestry.factory.gadgets.MachineCarpenter$RecipeManager"); - Field field_recipeFluids = clazz.getDeclaredField("recipeFluids"); - field_recipeFluids.setAccessible(true); - - HashSet recipeFluids = (HashSet) field_recipeFluids.get(clazz); - recipeFluids.add(newFluid); - - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); + HashSet recipeFluids = (HashSet) ReflectionHelper.getStaticObject(MachineCarpenter.RecipeManager.class, "recipeFluids"); + + if(recipeFluids != null) { + recipeFluids.add(newFluid); } } } diff --git a/src/main/java/modtweaker2/mods/railcraft/RailcraftHelper.java b/src/main/java/modtweaker2/mods/railcraft/RailcraftHelper.java index 9d048b1..a4a3c31 100644 --- a/src/main/java/modtweaker2/mods/railcraft/RailcraftHelper.java +++ b/src/main/java/modtweaker2/mods/railcraft/RailcraftHelper.java @@ -1,12 +1,15 @@ package modtweaker2.mods.railcraft; -import java.lang.reflect.Constructor; import java.util.List; import mods.railcraft.api.crafting.IBlastFurnaceRecipe; import mods.railcraft.api.crafting.ICokeOvenRecipe; import mods.railcraft.api.crafting.IRockCrusherRecipe; import mods.railcraft.api.crafting.RailcraftCraftingManager; +import mods.railcraft.common.util.crafting.BlastFurnaceCraftingManager.BlastFurnaceRecipe; +import mods.railcraft.common.util.crafting.CokeOvenCraftingManager.CokeOvenRecipe; +import mods.railcraft.common.util.crafting.RockCrusherCraftingManager.CrusherRecipe; +import modtweaker2.helpers.ReflectionHelper; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.fluids.FluidStack; @@ -28,35 +31,28 @@ public class RailcraftHelper { private RailcraftHelper() {} public static IBlastFurnaceRecipe getBlastFurnaceRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, int cookTime, ItemStack output) { - try { - Class clazz = Class.forName("mods.railcraft.common.util.crafting.BlastFurnaceCraftingManager$BlastFurnaceRecipe"); - Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, boolean.class, boolean.class, int.class, ItemStack.class); - constructor.setAccessible(true); - return (IBlastFurnaceRecipe) constructor.newInstance(input, matchDamage, matchNBT, cookTime, output); - } catch (Exception e) { - throw new NullPointerException("Failed to instantiate BlastFurnaceRecipe"); - } + return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(BlastFurnaceRecipe.class,ItemStack.class, boolean.class, boolean.class, int.class, ItemStack.class), + input, + matchDamage, + matchNBT, + cookTime, + output); } public static ICokeOvenRecipe getCokeOvenRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, ItemStack output, FluidStack fluidOutput, int cookTime) { - try { - Class clazz = Class.forName("mods.railcraft.common.util.crafting.CokeOvenCraftingManager$CokeOvenRecipe"); - Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, boolean.class, boolean.class, ItemStack.class, FluidStack.class, int.class); - constructor.setAccessible(true); - return (ICokeOvenRecipe) constructor.newInstance(input, matchDamage, matchNBT, output, fluidOutput, cookTime); - } catch (Exception e) { - throw new NullPointerException("Failed to instantiate CokeOvenRecipe"); - } + return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(CokeOvenRecipe.class, ItemStack.class, boolean.class, boolean.class, ItemStack.class, FluidStack.class, int.class), + input, + matchDamage, + matchNBT, + output, + fluidOutput, + cookTime); } public static IRockCrusherRecipe getRockCrusherRecipe(ItemStack stack, boolean matchDamage, boolean matchNBT) { - try { - Class clazz = Class.forName("mods.railcraft.common.util.crafting.RockCrusherCraftingManager$CrusherRecipe"); - Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, boolean.class, boolean.class); - constructor.setAccessible(true); - return (IRockCrusherRecipe) constructor.newInstance(stack, matchDamage, matchNBT); - } catch (Exception e) { - throw new NullPointerException("Failed to instantiate CrusherRecipe"); - } + return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(CrusherRecipe.class, ItemStack.class, boolean.class, boolean.class), + stack, + matchDamage, + matchNBT); } } diff --git a/src/main/java/modtweaker2/mods/tconstruct/TConstructHelper.java b/src/main/java/modtweaker2/mods/tconstruct/TConstructHelper.java index 6e911c2..3362ed4 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/TConstructHelper.java +++ b/src/main/java/modtweaker2/mods/tconstruct/TConstructHelper.java @@ -1,13 +1,12 @@ package modtweaker2.mods.tconstruct; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import mantle.utils.ItemMetaWrapper; +import modtweaker2.helpers.ReflectionHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; @@ -18,12 +17,11 @@ import tconstruct.library.crafting.CastingRecipe; import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe; import tconstruct.library.crafting.ModifyBuilder; import tconstruct.library.crafting.PatternBuilder.ItemKey; -import tconstruct.library.crafting.Smeltery; import tconstruct.library.modifier.ItemModifier; import tconstruct.library.tools.ToolMaterial; public class TConstructHelper { - public static HashMap mappings = new HashMap(); + public static HashMap mappings = new HashMap(); public static List alloys = null; public static ArrayList basinCasting = null; public static ArrayList tableCasting = null; @@ -43,13 +41,13 @@ public class TConstructHelper { basinCasting = TConstructRegistry.getBasinCasting().getCastingRecipes(); tableCasting = TConstructRegistry.getTableCasting().getCastingRecipes(); modifiers = ModifyBuilder.instance.itemModifiers; - modifiers_clone = new ArrayList(modifiers); + modifiers_clone = new ArrayList(modifiers); for (Map.Entry entry : TConstructRegistry.toolMaterials.entrySet()) { mappings.put(entry.getValue().materialName, entry.getKey()); } - fuelList = getFuelList(); + fuelList = ReflectionHelper.getObject(tconstruct.library.crafting.Smeltery.instance, "smelteryFuels"); } catch (Exception e) {} } @@ -60,31 +58,13 @@ public class TConstructHelper { return -1; } else return mappings.get(material); } - - public static Map getFuelList() { - Smeltery smelteryInstance = tconstruct.library.crafting.Smeltery.instance; - - try { - Field smelteryFuels = Smeltery.class.getDeclaredField("smelteryFuels"); - smelteryFuels.setAccessible(true); - - return (Map)smelteryFuels.get(smelteryInstance); - } catch (Exception e) { - e.printStackTrace(); - throw new NullPointerException("Failed to instantiate smeltery fuel map"); - } - } //Returns a Drying Recipe, using reflection as the constructor is not visible public static DryingRecipe getDryingRecipe(ItemStack input, int time, ItemStack output) { - try { - Constructor constructor = DryingRecipe.class.getDeclaredConstructor(ItemStack.class, int.class, ItemStack.class); - constructor.setAccessible(true); - return (DryingRecipe) constructor.newInstance(input, time, output); - } catch (Exception e) { - e.printStackTrace(); - throw new NullPointerException("Failed to instantiate DryingRecipe"); - } + return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(DryingRecipe.class, ItemStack.class, int.class, ItemStack.class), + input, + time, + output); } public static String getMaterialFromID(int id) { @@ -92,13 +72,10 @@ public class TConstructHelper { } public static ItemKey getItemKey(Item item, int damage, int value, String material) { - try { - Constructor constructor = ItemKey.class.getDeclaredConstructor(ItemStack.class, int.class, int.class, String.class); - constructor.setAccessible(true); - return (ItemKey) constructor.newInstance(item, damage, value, material); - } catch (Exception e) { - e.printStackTrace(); - throw new NullPointerException("Failed to instantiate ItemKey"); - } + return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(ItemKey.class, ItemStack.class, int.class, int.class, String.class), + item, + damage, + value, + material); } } diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/Modifiers.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/Modifiers.java index e7453c4..3778718 100644 --- a/src/main/java/modtweaker2/mods/tconstruct/handlers/Modifiers.java +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/Modifiers.java @@ -35,7 +35,6 @@ public class Modifiers { } } - //Searches through the modifiers and removes the first valid entry private static class Remove extends BaseListRemoval{ public Remove(List recipes) { super(Modifiers.name, TConstructHelper.modifiers, recipes); diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/ThermalHelper.java b/src/main/java/modtweaker2/mods/thermalexpansion/ThermalHelper.java index a4082a6..70a9e02 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/ThermalHelper.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/ThermalHelper.java @@ -14,8 +14,6 @@ import cofh.thermalexpansion.util.crafting.SawmillManager.RecipeSawmill; import cofh.thermalexpansion.util.crafting.SmelterManager.RecipeSmelter; import cofh.thermalexpansion.util.crafting.TransposerManager.RecipeTransposer; - -@SuppressWarnings("unchecked") public class ThermalHelper { public static Constructor crucibleRecipe; public static Constructor furanceRecipe; @@ -26,20 +24,12 @@ public class ThermalHelper { static { try { - crucibleRecipe = getConstructor("cofh.thermalexpansion.util.crafting.CrucibleManager$RecipeCrucible", ItemStack.class, FluidStack.class, int.class); - furanceRecipe = getConstructor("cofh.thermalexpansion.util.crafting.FurnaceManager$RecipeFurnace", ItemStack.class, ItemStack.class, int.class); - pulverizerRecipe = getConstructor("cofh.thermalexpansion.util.crafting.PulverizerManager$RecipePulverizer", ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); - sawmillRecipe = getConstructor("cofh.thermalexpansion.util.crafting.SawmillManager$RecipeSawmill", ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); - smelterRecipe = getConstructor("cofh.thermalexpansion.util.crafting.SmelterManager$RecipeSmelter", ItemStack.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); - transposerRecipe = getConstructor("cofh.thermalexpansion.util.crafting.TransposerManager$RecipeTransposer", ItemStack.class, ItemStack.class, FluidStack.class, int.class, int.class); + crucibleRecipe = getConstructor(RecipeCrucible.class, ItemStack.class, FluidStack.class, int.class); + furanceRecipe = getConstructor(RecipeFurnace.class, ItemStack.class, ItemStack.class, int.class); + pulverizerRecipe = getConstructor(RecipePulverizer.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); + sawmillRecipe = getConstructor(RecipeSawmill.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); + smelterRecipe = getConstructor(RecipeSmelter.class, ItemStack.class, ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); + transposerRecipe = getConstructor(RecipeTransposer.class, ItemStack.class, ItemStack.class, FluidStack.class, int.class, int.class); } catch (Exception e) { LogHelper.logError("Exception getting constructor for Thermal Expansion recipes!", e); } } - - public static T getTERecipe(Constructor constructor, Object... items) { - try { - return constructor.newInstance(items); - } catch (Exception e) { LogHelper.logError("Exception creating instance of Thermal Expansion recipe!", e); } - - return null; - } } diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Crucible.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Crucible.java index f341201..941bfeb 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Crucible.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Crucible.java @@ -14,6 +14,7 @@ import minetweaker.api.item.IItemStack; import minetweaker.api.liquid.ILiquidStack; import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.LogHelper; +import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; @@ -39,7 +40,7 @@ public class Crucible { return; } - MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.crucibleRecipe, toStack(input), toFluid(output), energy))); + MineTweakerAPI.apply(new Add(ReflectionHelper.getInstance(ThermalHelper.crucibleRecipe, toStack(input), toFluid(output), energy))); } private static class Add extends BaseListAddition { diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Furnace.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Furnace.java index 79cd9ab..f25e7f6 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Furnace.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Furnace.java @@ -13,6 +13,7 @@ import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.LogHelper; +import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; @@ -40,7 +41,7 @@ public class Furnace { return; } - MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.furanceRecipe, toStack(input), toStack(output), energy))); + MineTweakerAPI.apply(new Add(ReflectionHelper.getInstance(ThermalHelper.furanceRecipe, toStack(input), toStack(output), energy))); } private static class Add extends BaseListAddition { diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Pulverizer.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Pulverizer.java index 098ca8b..82da909 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Pulverizer.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Pulverizer.java @@ -12,6 +12,7 @@ import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.LogHelper; +import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; @@ -44,7 +45,7 @@ public class Pulverizer { return; } - MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.pulverizerRecipe, toStack(input), toStack(output), toStack(secondary), secondaryChance, energy))); + MineTweakerAPI.apply(new Add(ReflectionHelper.getInstance(ThermalHelper.pulverizerRecipe, toStack(input), toStack(output), toStack(secondary), secondaryChance, energy))); } private static class Add extends BaseListAddition { diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Sawmill.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Sawmill.java index da9d411..56ac348 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Sawmill.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Sawmill.java @@ -12,6 +12,7 @@ import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.LogHelper; +import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; @@ -44,7 +45,7 @@ public class Sawmill { return; } - MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.sawmillRecipe, toStack(input), toStack(output), toStack(secondary), secondaryChance, energy))); + MineTweakerAPI.apply(new Add(ReflectionHelper.getInstance(ThermalHelper.sawmillRecipe, toStack(input), toStack(output), toStack(secondary), secondaryChance, energy))); } private static class Add extends BaseListAddition { diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Smelter.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Smelter.java index 8c1eed4..4fc110c 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Smelter.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Smelter.java @@ -12,6 +12,7 @@ import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.LogHelper; +import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; @@ -44,7 +45,7 @@ public class Smelter { return; } - MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.smelterRecipe, toStack(input), toStack(input2), toStack(output), toStack(output2), chance, energy))); + MineTweakerAPI.apply(new Add(ReflectionHelper.getInstance(ThermalHelper.smelterRecipe, toStack(input), toStack(input2), toStack(output), toStack(output2), chance, energy))); } private static class Add extends BaseListAddition { diff --git a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Transposer.java b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Transposer.java index cf2ef34..0be3206 100644 --- a/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Transposer.java +++ b/src/main/java/modtweaker2/mods/thermalexpansion/handlers/Transposer.java @@ -16,6 +16,7 @@ import minetweaker.api.item.IngredientAny; import minetweaker.api.liquid.ILiquidStack; import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.LogHelper; +import modtweaker2.helpers.ReflectionHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; @@ -44,7 +45,7 @@ public class Transposer { return; } - MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.transposerRecipe, toStack(input), toStack(output), toFluid(liquid), energy, 100), RecipeType.Fill)); + MineTweakerAPI.apply(new Add(ReflectionHelper.getInstance(ThermalHelper.transposerRecipe, toStack(input), toStack(output), toFluid(liquid), energy, 100), RecipeType.Fill)); } @ZenMethod @@ -59,7 +60,7 @@ public class Transposer { return; } - MineTweakerAPI.apply(new Add(ThermalHelper.getTERecipe(ThermalHelper.transposerRecipe, toStack(input), toStack(output), toFluid(liquid), energy, 100), RecipeType.Extract)); + MineTweakerAPI.apply(new Add(ReflectionHelper.getInstance(ThermalHelper.transposerRecipe, toStack(input), toStack(output), toFluid(liquid), energy, 100), RecipeType.Extract)); } private static class Add extends BaseListAddition {