Fix timer reflection not working out of dev, also fix up Log class

This commit is contained in:
tterrag1098 committed 2015-01-31 19:00:22 -05:00
1 parent 6f1163f774
commit 11c51a7ef6
2 files changed
+22 -12

No files matched your search

+7 -6
View File
@@ -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() {
@@ -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<IGuiOverlay> overlays = new ArrayList<IGuiOverlay>();
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;