From 2c34c53bc7c9ca7d9d18e9cc269481398292fcef Mon Sep 17 00:00:00 2001 From: copygirl Date: Sun, 9 Feb 2014 14:45:21 +0100 Subject: [PATCH 1/3] Fix thermal expansion support? --- stanhebben/minetweaker/MineTweaker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stanhebben/minetweaker/MineTweaker.java b/stanhebben/minetweaker/MineTweaker.java index 463a41b..dc3df07 100644 --- a/stanhebben/minetweaker/MineTweaker.java +++ b/stanhebben/minetweaker/MineTweaker.java @@ -91,7 +91,7 @@ * * @author Stan Hebben */ -@Mod(modid = "MineTweaker", name = "MineTweaker", version = MineTweaker.MCVERSION + "-2.1.2") +@Mod(modid = "MineTweaker", name = "MineTweaker", version = MineTweaker.MCVERSION + "-2.1.2", dependencies = "before:ThermalExpansion") @NetworkMod(clientSideRequired = true, serverSideRequired = true, channels = {TweakerPacketHandler.CHANNEL_SERVERSCRIPT}, packetHandler = TweakerPacketHandler.class) public class MineTweaker { //#ifdef MC152 From f2b39ab9fae9dc514a6dedec2429607b938dc67e Mon Sep 17 00:00:00 2001 From: copygirl Date: Tue, 11 Feb 2014 16:16:40 +0100 Subject: [PATCH 2/3] Revert "Fix thermal expansion support?" This reverts commit 2c34c53bc7c9ca7d9d18e9cc269481398292fcef. --- stanhebben/minetweaker/MineTweaker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stanhebben/minetweaker/MineTweaker.java b/stanhebben/minetweaker/MineTweaker.java index dc3df07..463a41b 100644 --- a/stanhebben/minetweaker/MineTweaker.java +++ b/stanhebben/minetweaker/MineTweaker.java @@ -91,7 +91,7 @@ * * @author Stan Hebben */ -@Mod(modid = "MineTweaker", name = "MineTweaker", version = MineTweaker.MCVERSION + "-2.1.2", dependencies = "before:ThermalExpansion") +@Mod(modid = "MineTweaker", name = "MineTweaker", version = MineTweaker.MCVERSION + "-2.1.2") @NetworkMod(clientSideRequired = true, serverSideRequired = true, channels = {TweakerPacketHandler.CHANNEL_SERVERSCRIPT}, packetHandler = TweakerPacketHandler.class) public class MineTweaker { //#ifdef MC152 From 3294b29c2e330579e6b108e873ff6f49348789e0 Mon Sep 17 00:00:00 2001 From: copygirl Date: Tue, 11 Feb 2014 18:22:29 +0100 Subject: [PATCH 3/3] Fix Thermal Expansion support w/ reflection --- .../te/actions/ThermalExpansionAction.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/stanhebben/minetweaker/mods/te/actions/ThermalExpansionAction.java b/stanhebben/minetweaker/mods/te/actions/ThermalExpansionAction.java index b77cad9..016a189 100644 --- a/stanhebben/minetweaker/mods/te/actions/ThermalExpansionAction.java +++ b/stanhebben/minetweaker/mods/te/actions/ThermalExpansionAction.java @@ -1,8 +1,17 @@ package stanhebben.minetweaker.mods.te.actions; +import java.lang.reflect.Method; +import java.util.logging.Level; + import net.minecraft.nbt.NBTTagCompound; import stanhebben.minetweaker.api.IUndoableAction; +import stanhebben.minetweaker.api.Tweaker; + +import com.google.common.collect.ImmutableList; + import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; public class ThermalExpansionAction implements IUndoableAction { private final String key; @@ -18,6 +27,17 @@ public ThermalExpansionAction(String key, NBTTagCompound nbt, String description @Override public void apply() { FMLInterModComms.sendMessage("ThermalExpansion", key, nbt); + // Do some hackery because IMCMessages need to be retrieved manually after they've + // been sent out automatically the first time between init and post-init events. + try { + Class imcHandlerClass = Class.forName("thermalexpansion.util.IMCHandler"); + Method handleIMCMethod = imcHandlerClass.getMethod("handleIMC", IMCEvent.class); + Object imcHandlerInstance = imcHandlerClass.getField("instance").get(null); + handleIMCMethod.invoke(imcHandlerInstance, new CustumIMCEvent()); + } catch (Exception e) { + Tweaker.log(Level.WARNING, "Error adding Thermal Expansion recipe."); + System.out.println(e); + } } @Override @@ -39,4 +59,15 @@ public String describe() { public String describeUndo() { return "Removing a " + key + " for " + description; } + + private class CustumIMCEvent extends IMCEvent { + private ImmutableList messages; + + @Override + public ImmutableList getMessages() { + if (messages == null) + messages = FMLInterModComms.fetchRuntimeMessages("ThermalExpansion"); + return messages; + } + } }