diff --git a/src/main/java/crazypants/enderio/Log.java b/src/main/java/crazypants/enderio/Log.java index 347be541..7fa9bd1d 100644 --- a/src/main/java/crazypants/enderio/Log.java +++ b/src/main/java/crazypants/enderio/Log.java @@ -1,26 +1,27 @@ package crazypants.enderio; -import cpw.mods.fml.common.FMLLog; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; public final class Log { - public static final String CHANNEL = EnderIO.MODID; + public static final Logger LOGGER = LogManager.getLogger(EnderIO.MODID); public static void warn(String msg) { - FMLLog.log(CHANNEL, org.apache.logging.log4j.Level.WARN, msg, (Object[])null); + LOGGER.warn(msg); } public static void error(String msg) { - FMLLog.log(CHANNEL, org.apache.logging.log4j.Level.ERROR, msg); + LOGGER.error(msg); } public static void info(String msg) { - FMLLog.log(CHANNEL, org.apache.logging.log4j.Level.INFO, msg); + LOGGER.info(msg); } public static void debug(String msg) { - FMLLog.log(CHANNEL, org.apache.logging.log4j.Level.DEBUG, msg); + LOGGER.debug(msg); } private Log() { diff --git a/src/main/java/crazypants/gui/GuiContainerBase.java b/src/main/java/crazypants/gui/GuiContainerBase.java index fb1cc43f..982d8b8c 100644 --- a/src/main/java/crazypants/gui/GuiContainerBase.java +++ b/src/main/java/crazypants/gui/GuiContainerBase.java @@ -18,6 +18,8 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; +import cpw.mods.fml.relauncher.ReflectionHelper; +import crazypants.enderio.Log; import crazypants.enderio.gui.IGuiOverlay; import crazypants.gui.ToolTipManager.ToolTipRenderer; @@ -26,7 +28,7 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe protected ToolTipManager ttMan = new ToolTipManager(); protected List overlays = new ArrayList(); - private Field timer = null; + private static Field timerField = null; protected GuiContainerBase(Container par1Container) { super(par1Container); @@ -38,6 +40,17 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe for (IGuiOverlay overlay : overlays) { overlay.init(this); } + if(timerField == null) { + try { + if(timerField == null) { + timerField = ReflectionHelper.findField(Minecraft.class, "field_71428_T", "timer", "Q"); + timerField.setAccessible(true); + } + } catch (Exception e) { + Log.error("Failed to initialize timer reflection for IO config."); + e.printStackTrace(); + } + } } @Override @@ -107,11 +120,7 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe Timer t = null; try { - if(timer == null) { - timer = Minecraft.class.getDeclaredField("timer"); - timer.setAccessible(true); - } - t = (Timer) timer.get(this.mc); + t = (Timer) timerField.get(this.mc); } catch (Exception e) { e.printStackTrace(); return;