Changes in ReflectionHelper

This commit is contained in:
Zixxl 2015-07-06 17:42:39 +02:00
parent 17d9b78930
commit 6bf0797054
13 changed files with 115 additions and 143 deletions

View file

@ -5,16 +5,47 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
public class ReflectionHelper { public class ReflectionHelper {
public static <T> T getInstance(Constructor<T> 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> T getInstance(Class<T> clazz, Object... arguments) {
Class[] classArray = new Class[arguments.length];
for(int i = 0; i < arguments.length; i++) {
classArray[i] = arguments[i].getClass();
}
Constructor<T> constructor = getConstructor(clazz, classArray);
return getInstance(constructor, arguments);
}
public static Constructor getConstructor(String string, Class... types) { public static Constructor getConstructor(String string, Class... types) {
try { try {
Class clazz = Class.forName(string); Class clazz = Class.forName(string);
Constructor constructor = clazz.getDeclaredConstructor(types); Constructor constructor = clazz.getDeclaredConstructor(types);
constructor.setAccessible(true); constructor.setAccessible(true);
return constructor; return constructor;
} catch (Exception ex) {} } catch (Exception ex) { LogHelper.logError("Exception creating instance of " + string, ex); }
return null; return null;
} }
public static <T> Constructor<T> getConstructor(Class<T> clazz, Class... types) {
try {
Constructor<T> 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> T getObject(Object o, String... fieldName) { public static <T> T getObject(Object o, String... fieldName) {
Class cls = o.getClass(); Class cls = o.getClass();

View file

@ -2,9 +2,9 @@ package modtweaker2.mods.factorization;
import static modtweaker2.helpers.ReflectionHelper.getStaticObject; import static modtweaker2.helpers.ReflectionHelper.getStaticObject;
import java.lang.reflect.Constructor;
import java.util.List; import java.util.List;
import modtweaker2.helpers.ReflectionHelper;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class FactorizationHelper { public class FactorizationHelper {
@ -22,36 +22,30 @@ public class FactorizationHelper {
private FactorizationHelper() {} private FactorizationHelper() {}
@SuppressWarnings("unchecked")
public static Object getLaceratorRecipe(ItemStack input, ItemStack output, float probability) { public static Object getLaceratorRecipe(ItemStack input, ItemStack output, float probability) {
try { return ReflectionHelper.getInstance(ReflectionHelper.getConstructor("factorization.oreprocessing.TileEntityGrinder$GrinderRecipe", Object.class, ItemStack.class, float.class),
Class clazz = Class.forName("factorization.oreprocessing.TileEntityGrinder$GrinderRecipe"); input,
Constructor constructor = clazz.getDeclaredConstructor(Object.class, ItemStack.class, float.class); output,
constructor.setAccessible(true); probability);
return constructor.newInstance(input, output, probability);
} catch (Exception e) {
throw new NullPointerException("Failed to instantiate Lacerator Recipe");
}
} }
@SuppressWarnings("unchecked")
public static Object getSlagFurnaceRecipe(ItemStack input, float chance1, ItemStack output1, float chance2, ItemStack output2) { public static Object getSlagFurnaceRecipe(ItemStack input, float chance1, ItemStack output1, float chance2, ItemStack output2) {
try { return ReflectionHelper.getInstance(ReflectionHelper.getConstructor("factorization.oreprocessing.TileEntitySlagFurnace$SmeltingResult", ItemStack.class, float.class, ItemStack.class, float.class, ItemStack.class),
Class clazz = Class.forName("factorization.oreprocessing.TileEntitySlagFurnace$SmeltingResult"); input,
Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, float.class, ItemStack.class, float.class, ItemStack.class); chance1,
constructor.setAccessible(true); output1,
return constructor.newInstance(input, chance1, output1, chance2, output2); chance2,
} catch (Exception e) { output2);
throw new NullPointerException("Failed to instantiate SmeltingResult");
}
} }
@SuppressWarnings("unchecked")
public static Object getCrystallizerRecipe(ItemStack input, ItemStack output, ItemStack solution, float output_count) { public static Object getCrystallizerRecipe(ItemStack input, ItemStack output, ItemStack solution, float output_count) {
try { return ReflectionHelper.getInstance(ReflectionHelper.getConstructor("factorization.oreprocessing.TileEntityCrystallizer$CrystalRecipe", ItemStack.class, ItemStack.class, float.class, ItemStack.class),
Class clazz = Class.forName("factorization.oreprocessing.TileEntityCrystallizer$CrystalRecipe"); input,
Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, ItemStack.class, float.class, ItemStack.class); output,
constructor.setAccessible(true); output_count,
return constructor.newInstance(input, output, output_count, solution); solution);
} catch (Exception e) {
throw new NullPointerException("Failed to instantiate CrystalRecipe");
}
} }
} }

View file

@ -1,51 +1,30 @@
package modtweaker2.mods.forestry; package modtweaker2.mods.forestry;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import modtweaker2.helpers.ReflectionHelper;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import forestry.factory.gadgets.MachineCarpenter;
public class ForestryHelper { public class ForestryHelper {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static void addCarpenterRecipeBox(ItemStack box) { public static void addCarpenterRecipeBox(ItemStack box) {
Class clazz; ArrayList<ItemStack> recipeBoxes = (ArrayList<ItemStack>) ReflectionHelper.getStaticObject(MachineCarpenter.RecipeManager.class, "boxes");
try {
clazz = Class.forName("forestry.factory.gadgets.MachineCarpenter$RecipeManager"); if(recipeBoxes != null) {
Field field_box = clazz.getDeclaredField("boxes"); recipeBoxes.add(box);
field_box.setAccessible(true); }
ArrayList<ItemStack> recipeBoxes = (ArrayList<ItemStack>) field_box.get(clazz);
recipeBoxes.add(box);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static void addCarpenterRecipeFluids(Fluid newFluid) { public static void addCarpenterRecipeFluids(Fluid newFluid) {
Class clazz; HashSet<Fluid> recipeFluids = (HashSet<Fluid>) ReflectionHelper.getStaticObject(MachineCarpenter.RecipeManager.class, "recipeFluids");
try {
clazz = Class.forName("forestry.factory.gadgets.MachineCarpenter$RecipeManager"); if(recipeFluids != null) {
Field field_recipeFluids = clazz.getDeclaredField("recipeFluids"); recipeFluids.add(newFluid);
field_recipeFluids.setAccessible(true);
HashSet<Fluid> recipeFluids = (HashSet<Fluid>) field_recipeFluids.get(clazz);
recipeFluids.add(newFluid);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} }
} }
} }

View file

@ -1,12 +1,15 @@
package modtweaker2.mods.railcraft; package modtweaker2.mods.railcraft;
import java.lang.reflect.Constructor;
import java.util.List; import java.util.List;
import mods.railcraft.api.crafting.IBlastFurnaceRecipe; import mods.railcraft.api.crafting.IBlastFurnaceRecipe;
import mods.railcraft.api.crafting.ICokeOvenRecipe; import mods.railcraft.api.crafting.ICokeOvenRecipe;
import mods.railcraft.api.crafting.IRockCrusherRecipe; import mods.railcraft.api.crafting.IRockCrusherRecipe;
import mods.railcraft.api.crafting.RailcraftCraftingManager; 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.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -28,35 +31,28 @@ public class RailcraftHelper {
private RailcraftHelper() {} private RailcraftHelper() {}
public static IBlastFurnaceRecipe getBlastFurnaceRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, int cookTime, ItemStack output) { public static IBlastFurnaceRecipe getBlastFurnaceRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, int cookTime, ItemStack output) {
try { return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(BlastFurnaceRecipe.class,ItemStack.class, boolean.class, boolean.class, int.class, ItemStack.class),
Class clazz = Class.forName("mods.railcraft.common.util.crafting.BlastFurnaceCraftingManager$BlastFurnaceRecipe"); input,
Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, boolean.class, boolean.class, int.class, ItemStack.class); matchDamage,
constructor.setAccessible(true); matchNBT,
return (IBlastFurnaceRecipe) constructor.newInstance(input, matchDamage, matchNBT, cookTime, output); cookTime,
} catch (Exception e) { output);
throw new NullPointerException("Failed to instantiate BlastFurnaceRecipe");
}
} }
public static ICokeOvenRecipe getCokeOvenRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, ItemStack output, FluidStack fluidOutput, int cookTime) { public static ICokeOvenRecipe getCokeOvenRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, ItemStack output, FluidStack fluidOutput, int cookTime) {
try { return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(CokeOvenRecipe.class, ItemStack.class, boolean.class, boolean.class, ItemStack.class, FluidStack.class, int.class),
Class clazz = Class.forName("mods.railcraft.common.util.crafting.CokeOvenCraftingManager$CokeOvenRecipe"); input,
Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, boolean.class, boolean.class, ItemStack.class, FluidStack.class, int.class); matchDamage,
constructor.setAccessible(true); matchNBT,
return (ICokeOvenRecipe) constructor.newInstance(input, matchDamage, matchNBT, output, fluidOutput, cookTime); output,
} catch (Exception e) { fluidOutput,
throw new NullPointerException("Failed to instantiate CokeOvenRecipe"); cookTime);
}
} }
public static IRockCrusherRecipe getRockCrusherRecipe(ItemStack stack, boolean matchDamage, boolean matchNBT) { public static IRockCrusherRecipe getRockCrusherRecipe(ItemStack stack, boolean matchDamage, boolean matchNBT) {
try { return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(CrusherRecipe.class, ItemStack.class, boolean.class, boolean.class),
Class clazz = Class.forName("mods.railcraft.common.util.crafting.RockCrusherCraftingManager$CrusherRecipe"); stack,
Constructor constructor = clazz.getDeclaredConstructor(ItemStack.class, boolean.class, boolean.class); matchDamage,
constructor.setAccessible(true); matchNBT);
return (IRockCrusherRecipe) constructor.newInstance(stack, matchDamage, matchNBT);
} catch (Exception e) {
throw new NullPointerException("Failed to instantiate CrusherRecipe");
}
} }
} }

View file

@ -1,13 +1,12 @@
package modtweaker2.mods.tconstruct; package modtweaker2.mods.tconstruct;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import mantle.utils.ItemMetaWrapper; import mantle.utils.ItemMetaWrapper;
import modtweaker2.helpers.ReflectionHelper;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
@ -18,12 +17,11 @@ import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe; import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe;
import tconstruct.library.crafting.ModifyBuilder; import tconstruct.library.crafting.ModifyBuilder;
import tconstruct.library.crafting.PatternBuilder.ItemKey; import tconstruct.library.crafting.PatternBuilder.ItemKey;
import tconstruct.library.crafting.Smeltery;
import tconstruct.library.modifier.ItemModifier; import tconstruct.library.modifier.ItemModifier;
import tconstruct.library.tools.ToolMaterial; import tconstruct.library.tools.ToolMaterial;
public class TConstructHelper { public class TConstructHelper {
public static HashMap<String, Integer> mappings = new HashMap(); public static HashMap<String, Integer> mappings = new HashMap<String, Integer>();
public static List<AlloyMix> alloys = null; public static List<AlloyMix> alloys = null;
public static ArrayList<CastingRecipe> basinCasting = null; public static ArrayList<CastingRecipe> basinCasting = null;
public static ArrayList<CastingRecipe> tableCasting = null; public static ArrayList<CastingRecipe> tableCasting = null;
@ -43,13 +41,13 @@ public class TConstructHelper {
basinCasting = TConstructRegistry.getBasinCasting().getCastingRecipes(); basinCasting = TConstructRegistry.getBasinCasting().getCastingRecipes();
tableCasting = TConstructRegistry.getTableCasting().getCastingRecipes(); tableCasting = TConstructRegistry.getTableCasting().getCastingRecipes();
modifiers = ModifyBuilder.instance.itemModifiers; modifiers = ModifyBuilder.instance.itemModifiers;
modifiers_clone = new ArrayList(modifiers); modifiers_clone = new ArrayList<ItemModifier>(modifiers);
for (Map.Entry<Integer, ToolMaterial> entry : TConstructRegistry.toolMaterials.entrySet()) { for (Map.Entry<Integer, ToolMaterial> entry : TConstructRegistry.toolMaterials.entrySet()) {
mappings.put(entry.getValue().materialName, entry.getKey()); mappings.put(entry.getValue().materialName, entry.getKey());
} }
fuelList = getFuelList(); fuelList = ReflectionHelper.getObject(tconstruct.library.crafting.Smeltery.instance, "smelteryFuels");
} catch (Exception e) {} } catch (Exception e) {}
} }
@ -60,31 +58,13 @@ public class TConstructHelper {
return -1; return -1;
} else return mappings.get(material); } else return mappings.get(material);
} }
public static Map<Fluid, Integer[]> getFuelList() {
Smeltery smelteryInstance = tconstruct.library.crafting.Smeltery.instance;
try {
Field smelteryFuels = Smeltery.class.getDeclaredField("smelteryFuels");
smelteryFuels.setAccessible(true);
return (Map<Fluid, Integer[]>)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 //Returns a Drying Recipe, using reflection as the constructor is not visible
public static DryingRecipe getDryingRecipe(ItemStack input, int time, ItemStack output) { public static DryingRecipe getDryingRecipe(ItemStack input, int time, ItemStack output) {
try { return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(DryingRecipe.class, ItemStack.class, int.class, ItemStack.class),
Constructor constructor = DryingRecipe.class.getDeclaredConstructor(ItemStack.class, int.class, ItemStack.class); input,
constructor.setAccessible(true); time,
return (DryingRecipe) constructor.newInstance(input, time, output); output);
} catch (Exception e) {
e.printStackTrace();
throw new NullPointerException("Failed to instantiate DryingRecipe");
}
} }
public static String getMaterialFromID(int id) { 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) { public static ItemKey getItemKey(Item item, int damage, int value, String material) {
try { return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(ItemKey.class, ItemStack.class, int.class, int.class, String.class),
Constructor constructor = ItemKey.class.getDeclaredConstructor(ItemStack.class, int.class, int.class, String.class); item,
constructor.setAccessible(true); damage,
return (ItemKey) constructor.newInstance(item, damage, value, material); value,
} catch (Exception e) { material);
e.printStackTrace();
throw new NullPointerException("Failed to instantiate ItemKey");
}
} }
} }

View file

@ -35,7 +35,6 @@ public class Modifiers {
} }
} }
//Searches through the modifiers and removes the first valid entry
private static class Remove extends BaseListRemoval<ItemModifier>{ private static class Remove extends BaseListRemoval<ItemModifier>{
public Remove(List<ItemModifier> recipes) { public Remove(List<ItemModifier> recipes) {
super(Modifiers.name, TConstructHelper.modifiers, recipes); super(Modifiers.name, TConstructHelper.modifiers, recipes);

View file

@ -14,8 +14,6 @@ import cofh.thermalexpansion.util.crafting.SawmillManager.RecipeSawmill;
import cofh.thermalexpansion.util.crafting.SmelterManager.RecipeSmelter; import cofh.thermalexpansion.util.crafting.SmelterManager.RecipeSmelter;
import cofh.thermalexpansion.util.crafting.TransposerManager.RecipeTransposer; import cofh.thermalexpansion.util.crafting.TransposerManager.RecipeTransposer;
@SuppressWarnings("unchecked")
public class ThermalHelper { public class ThermalHelper {
public static Constructor<RecipeCrucible> crucibleRecipe; public static Constructor<RecipeCrucible> crucibleRecipe;
public static Constructor<RecipeFurnace> furanceRecipe; public static Constructor<RecipeFurnace> furanceRecipe;
@ -26,20 +24,12 @@ public class ThermalHelper {
static { static {
try { try {
crucibleRecipe = getConstructor("cofh.thermalexpansion.util.crafting.CrucibleManager$RecipeCrucible", ItemStack.class, FluidStack.class, int.class); crucibleRecipe = getConstructor(RecipeCrucible.class, ItemStack.class, FluidStack.class, int.class);
furanceRecipe = getConstructor("cofh.thermalexpansion.util.crafting.FurnaceManager$RecipeFurnace", ItemStack.class, ItemStack.class, int.class); furanceRecipe = getConstructor(RecipeFurnace.class, ItemStack.class, ItemStack.class, int.class);
pulverizerRecipe = getConstructor("cofh.thermalexpansion.util.crafting.PulverizerManager$RecipePulverizer", ItemStack.class, ItemStack.class, ItemStack.class, int.class, int.class); pulverizerRecipe = getConstructor(RecipePulverizer.class, 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); sawmillRecipe = getConstructor(RecipeSawmill.class, 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); smelterRecipe = getConstructor(RecipeSmelter.class, 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); 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); } } catch (Exception e) { LogHelper.logError("Exception getting constructor for Thermal Expansion recipes!", e); }
} }
public static <T> T getTERecipe(Constructor<T> constructor, Object... items) {
try {
return constructor.newInstance(items);
} catch (Exception e) { LogHelper.logError("Exception creating instance of Thermal Expansion recipe!", e); }
return null;
}
} }

View file

@ -14,6 +14,7 @@ import minetweaker.api.item.IItemStack;
import minetweaker.api.liquid.ILiquidStack; import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper;
import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval; import modtweaker2.utils.BaseListRemoval;
@ -39,7 +40,7 @@ public class Crucible {
return; 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<RecipeCrucible> { private static class Add extends BaseListAddition<RecipeCrucible> {

View file

@ -13,6 +13,7 @@ import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack; import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper;
import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval; import modtweaker2.utils.BaseListRemoval;
@ -40,7 +41,7 @@ public class Furnace {
return; 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<RecipeFurnace> { private static class Add extends BaseListAddition<RecipeFurnace> {

View file

@ -12,6 +12,7 @@ import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack; import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper;
import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval; import modtweaker2.utils.BaseListRemoval;
@ -44,7 +45,7 @@ public class Pulverizer {
return; 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<RecipePulverizer> { private static class Add extends BaseListAddition<RecipePulverizer> {

View file

@ -12,6 +12,7 @@ import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack; import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper;
import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval; import modtweaker2.utils.BaseListRemoval;
@ -44,7 +45,7 @@ public class Sawmill {
return; 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<RecipeSawmill> { private static class Add extends BaseListAddition<RecipeSawmill> {

View file

@ -12,6 +12,7 @@ import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack; import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper;
import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval; import modtweaker2.utils.BaseListRemoval;
@ -44,7 +45,7 @@ public class Smelter {
return; 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<RecipeSmelter> { private static class Add extends BaseListAddition<RecipeSmelter> {

View file

@ -16,6 +16,7 @@ import minetweaker.api.item.IngredientAny;
import minetweaker.api.liquid.ILiquidStack; import minetweaker.api.liquid.ILiquidStack;
import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.InputHelper;
import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.LogHelper;
import modtweaker2.helpers.ReflectionHelper;
import modtweaker2.mods.thermalexpansion.ThermalHelper; import modtweaker2.mods.thermalexpansion.ThermalHelper;
import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval; import modtweaker2.utils.BaseListRemoval;
@ -44,7 +45,7 @@ public class Transposer {
return; 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 @ZenMethod
@ -59,7 +60,7 @@ public class Transposer {
return; 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<RecipeTransposer> { private static class Add extends BaseListAddition<RecipeTransposer> {