From 37e7395682078db2499fbaa25ef38bfb304e0411 Mon Sep 17 00:00:00 2001 From: Tobias Wohlfarth Date: Mon, 26 Jan 2015 21:12:35 +0100 Subject: [PATCH] fix: add liquid to Forestry Carpenters internal tank filter, so new liquids are accepted this time via relfection and hopefully working modified: src/main/java/modtweaker/mods/forestry/ForestryHelper.java modified: src/main/java/modtweaker/mods/forestry/handlers/Carpenter.java --- .../mods/forestry/ForestryHelper.java | 24 +++++++++++++++++++ .../mods/forestry/handlers/Carpenter.java | 8 ++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/modtweaker/mods/forestry/ForestryHelper.java b/src/main/java/modtweaker/mods/forestry/ForestryHelper.java index 7d7ae04..cb25208 100644 --- a/src/main/java/modtweaker/mods/forestry/ForestryHelper.java +++ b/src/main/java/modtweaker/mods/forestry/ForestryHelper.java @@ -1,5 +1,29 @@ package modtweaker.mods.forestry; +import java.lang.reflect.Field; +import java.util.HashSet; + +import net.minecraftforge.fluids.Fluid; + public class ForestryHelper { + @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(); + } + } } diff --git a/src/main/java/modtweaker/mods/forestry/handlers/Carpenter.java b/src/main/java/modtweaker/mods/forestry/handlers/Carpenter.java index 0c4fbbc..5f53f75 100644 --- a/src/main/java/modtweaker/mods/forestry/handlers/Carpenter.java +++ b/src/main/java/modtweaker/mods/forestry/handlers/Carpenter.java @@ -28,6 +28,8 @@ import forestry.factory.gadgets.MachineFermenter; import forestry.factory.gadgets.MachineCarpenter.Recipe; import forestry.factory.gadgets.MachineCarpenter.RecipeManager; +import modtweaker.mods.forestry.ForestryHelper; + @ZenClass("mods.forestry.Carpenter") public class Carpenter { @@ -52,9 +54,13 @@ public class Carpenter { } private static class Add extends BaseListAddition { + public Add(Recipe recipe) { super("Forestry Carpenter", MachineCarpenter.RecipeManager.recipes, recipe); - RecipeManager.recipeFluids.add(recipe.getLiquid().getFluid()); + + //The Carpenter has a list of valid Fluids, access them via Relfection because of private + if (recipe.getLiquid() != null) + ForestryHelper.addCarpenterRecipeFluids(recipe.getLiquid().getFluid()); } }