Commit 4dc2ac38db687687f7747a9f3421ea5d41516175

Authored by Mumfrey
1 parent 0e1a1e12

LiteLoader 1.4.5_02

+ Added callback pre GUI render to RenderListener
 + Added forge compatibility to class loading from Macros
.classpath
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 <classpath> 2 <classpath>
3 <classpathentry kind="src" path="java"/> 3 <classpathentry kind="src" path="java"/>
4 <classpathentry kind="src" path="res"/> 4 <classpathentry kind="src" path="res"/>
5 - <classpathentry combineaccessrules="false" kind="src" path="/ClientMods"/>  
6 <classpathentry combineaccessrules="false" kind="src" path="/Client"/> 5 <classpathentry combineaccessrules="false" kind="src" path="/Client"/>
7 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6"/> 6 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6"/>
8 <classpathentry kind="lib" path="/Client/jars/bin/jinput.jar"/> 7 <classpathentry kind="lib" path="/Client/jars/bin/jinput.jar"/>
java/com/mumfrey/liteloader/RenderListener.java
1 package com.mumfrey.liteloader; 1 package com.mumfrey.liteloader;
2 2
  3 +import net.minecraft.src.GuiScreen;
  4 +
3 /** 5 /**
4 * Interface for objects which want a pre-render callback 6 * Interface for objects which want a pre-render callback
5 * 7 *
@@ -12,5 +14,7 @@ public interface RenderListener extends LiteMod @@ -12,5 +14,7 @@ public interface RenderListener extends LiteMod
12 */ 14 */
13 public abstract void onRender(); 15 public abstract void onRender();
14 16
  17 + public abstract void onRenderGui(GuiScreen currentScreen);
  18 +
15 public abstract void onRenderWorld(); 19 public abstract void onRenderWorld();
16 } 20 }
java/com/mumfrey/liteloader/core/HookProfiler.java
@@ -5,7 +5,10 @@ import java.lang.reflect.Method; @@ -5,7 +5,10 @@ import java.lang.reflect.Method;
5 import java.util.LinkedList; 5 import java.util.LinkedList;
6 import java.util.logging.Logger; 6 import java.util.logging.Logger;
7 7
  8 +import com.mumfrey.liteloader.util.ModUtilities;
  9 +
8 import net.minecraft.client.Minecraft; 10 import net.minecraft.client.Minecraft;
  11 +import net.minecraft.src.EntityPlayerSP;
9 import net.minecraft.src.GameSettings; 12 import net.minecraft.src.GameSettings;
10 import net.minecraft.src.Profiler; 13 import net.minecraft.src.Profiler;
11 14
@@ -59,6 +62,8 @@ public class HookProfiler extends Profiler @@ -59,6 +62,8 @@ public class HookProfiler extends Profiler
59 */ 62 */
60 public HookProfiler(LiteLoader core, Logger logger) 63 public HookProfiler(LiteLoader core, Logger logger)
61 { 64 {
  65 + this.mc = Minecraft.getMinecraft();
  66 +
62 this.loader = core; 67 this.loader = core;
63 this.logger = logger; 68 this.logger = logger;
64 69
@@ -87,7 +92,6 @@ public class HookProfiler extends Profiler @@ -87,7 +92,6 @@ public class HookProfiler extends Profiler
87 if (ofProfiler != null) 92 if (ofProfiler != null)
88 { 93 {
89 logger.info(String.format("Optifine version %s detected, enabling compatibility check", GetOptifineVersion())); 94 logger.info(String.format("Optifine version %s detected, enabling compatibility check", GetOptifineVersion()));
90 - mc = Minecraft.getMinecraft();  
91 } 95 }
92 } 96 }
93 } 97 }
@@ -156,7 +160,7 @@ public class HookProfiler extends Profiler @@ -156,7 +160,7 @@ public class HookProfiler extends Profiler
156 } 160 }
157 } 161 }
158 } 162 }
159 - 163 +
160 /* (non-Javadoc) 164 /* (non-Javadoc)
161 * @see net.minecraft.src.Profiler#endSection() 165 * @see net.minecraft.src.Profiler#endSection()
162 */ 166 */
@@ -165,9 +169,10 @@ public class HookProfiler extends Profiler @@ -165,9 +169,10 @@ public class HookProfiler extends Profiler
165 { 169 {
166 super.endSection(); 170 super.endSection();
167 171
168 - String endingSection = sectionStack.removeLast();  
169 -  
170 - if ("gameRenderer".equalsIgnoreCase(endingSection) && "root".equalsIgnoreCase(sectionStack.getLast())) 172 + String endingSection = sectionStack.size() > 0 ? sectionStack.removeLast() : null;
  173 + String nextSection = sectionStack.size() > 0 ? sectionStack.getLast() : null;
  174 +
  175 + if ("gameRenderer".equals(endingSection) && "root".equals(sectionStack.getLast()))
171 { 176 {
172 super.startSection("litetick"); 177 super.startSection("litetick");
173 178
@@ -176,5 +181,9 @@ public class HookProfiler extends Profiler @@ -176,5 +181,9 @@ public class HookProfiler extends Profiler
176 181
177 super.endSection(); 182 super.endSection();
178 } 183 }
  184 + else if (("mouse".equals(endingSection) && "gameRenderer".equals(nextSection) && (mc.skipRenderWorld || mc.theWorld == null)) || ("gui".equals(endingSection) && "gameRenderer".equals(nextSection) && mc.theWorld != null))
  185 + {
  186 + loader.onBeforeGuiRender();
  187 + }
179 } 188 }
180 } 189 }
java/com/mumfrey/liteloader/core/LiteLoader.java
@@ -5,6 +5,7 @@ import java.lang.reflect.Constructor; @@ -5,6 +5,7 @@ import java.lang.reflect.Constructor;
5 import java.lang.reflect.Method; 5 import java.lang.reflect.Method;
6 import java.net.URL; 6 import java.net.URL;
7 import java.net.URLClassLoader; 7 import java.net.URLClassLoader;
  8 +import java.net.URLDecoder;
8 import java.nio.CharBuffer; 9 import java.nio.CharBuffer;
9 import java.nio.charset.Charset; 10 import java.nio.charset.Charset;
10 import java.util.*; 11 import java.util.*;
@@ -18,7 +19,6 @@ import java.util.zip.ZipInputStream; @@ -18,7 +19,6 @@ import java.util.zip.ZipInputStream;
18 import com.mumfrey.liteloader.*; 19 import com.mumfrey.liteloader.*;
19 import com.mumfrey.liteloader.util.ModUtilities; 20 import com.mumfrey.liteloader.util.ModUtilities;
20 import com.mumfrey.liteloader.util.PrivateFields; 21 import com.mumfrey.liteloader.util.PrivateFields;
21 -import com.sun.corba.se.impl.ior.ByteBuffer;  
22 22
23 import net.minecraft.client.Minecraft; 23 import net.minecraft.client.Minecraft;
24 import net.minecraft.src.*; 24 import net.minecraft.src.*;
@@ -28,7 +28,7 @@ import net.minecraft.src.Timer; @@ -28,7 +28,7 @@ import net.minecraft.src.Timer;
28 * LiteLoader is a simple loader which provides tick events to loaded mods 28 * LiteLoader is a simple loader which provides tick events to loaded mods
29 * 29 *
30 * @author Adam Mummery-Smith 30 * @author Adam Mummery-Smith
31 - * @version 1.4.4 31 + * @version 1.4.5_02
32 */ 32 */
33 @SuppressWarnings("rawtypes") 33 @SuppressWarnings("rawtypes")
34 public final class LiteLoader implements FilenameFilter 34 public final class LiteLoader implements FilenameFilter
@@ -36,7 +36,7 @@ public final class LiteLoader implements FilenameFilter @@ -36,7 +36,7 @@ public final class LiteLoader implements FilenameFilter
36 /** 36 /**
37 * Liteloader version 37 * Liteloader version
38 */ 38 */
39 - private static final String LOADER_VERSION = "1.4.5"; 39 + private static final String LOADER_VERSION = "1.4.5_02";
40 40
41 /** 41 /**
42 * Loader revision, can be used by mods to determine whether the loader is sufficiently up-to-date 42 * Loader revision, can be used by mods to determine whether the loader is sufficiently up-to-date
@@ -128,7 +128,7 @@ public final class LiteLoader implements FilenameFilter @@ -128,7 +128,7 @@ public final class LiteLoader implements FilenameFilter
128 * List of mods which implement PluginChannelListener interface 128 * List of mods which implement PluginChannelListener interface
129 */ 129 */
130 private LinkedList<PluginChannelListener> pluginChannelListeners = new LinkedList<PluginChannelListener>(); 130 private LinkedList<PluginChannelListener> pluginChannelListeners = new LinkedList<PluginChannelListener>();
131 - 131 +
132 /** 132 /**
133 * Mapping of plugin channel names to listeners 133 * Mapping of plugin channel names to listeners
134 */ 134 */
@@ -470,15 +470,35 @@ public final class LiteLoader implements FilenameFilter @@ -470,15 +470,35 @@ public final class LiteLoader implements FilenameFilter
470 { 470 {
471 logger.info("Searching protection domain code source..."); 471 logger.info("Searching protection domain code source...");
472 472
473 - File packagePath = new File(LiteLoader.class.getProtectionDomain().getCodeSource().getLocation().toURI());  
474 - LinkedList<Class> modClasses = getSubclassesFor(packagePath, Minecraft.class.getClassLoader(), LiteMod.class, "LiteMod"); 473 + File packagePath = null;
475 474
476 - for (Class mod : modClasses) 475 + if (LiteLoader.class.getProtectionDomain().getCodeSource().getLocation() != null)
477 { 476 {
478 - modsToLoad.put(mod.getSimpleName(), mod); 477 + packagePath = new File(LiteLoader.class.getProtectionDomain().getCodeSource().getLocation().toURI());
  478 + }
  479 + else
  480 + {
  481 + // Fix (?) for forge and other mods which screw up the protection domain
  482 + String reflectionClassPath = LiteLoader.class.getResource("/com/mumfrey/liteloader/core/LiteLoader.class").getPath();
  483 +
  484 + if (reflectionClassPath.indexOf('!') > -1)
  485 + {
  486 + reflectionClassPath = URLDecoder.decode(reflectionClassPath, "UTF-8");
  487 + packagePath = new File(reflectionClassPath.substring(5, reflectionClassPath.indexOf('!')));
  488 + }
  489 + }
  490 +
  491 + if (packagePath != null)
  492 + {
  493 + LinkedList<Class> modClasses = getSubclassesFor(packagePath, Minecraft.class.getClassLoader(), LiteMod.class, "LiteMod");
  494 +
  495 + for (Class mod : modClasses)
  496 + {
  497 + modsToLoad.put(mod.getSimpleName(), mod);
  498 + }
  499 +
  500 + if (modClasses.size() > 0) logger.info(String.format("Found %s potential matches", modClasses.size()));
479 } 501 }
480 -  
481 - if (modClasses.size() > 0) logger.info(String.format("Found %s potential matches", modClasses.size()));  
482 } 502 }
483 catch (Throwable th) 503 catch (Throwable th)
484 { 504 {
@@ -966,6 +986,15 @@ public final class LiteLoader implements FilenameFilter @@ -966,6 +986,15 @@ public final class LiteLoader implements FilenameFilter
966 } 986 }
967 987
968 /** 988 /**
  989 + * Called immediately before the current GUI is rendered
  990 + */
  991 + public void onBeforeGuiRender()
  992 + {
  993 + for (RenderListener renderListener : renderListeners)
  994 + renderListener.onRenderGui(minecraft.currentScreen);
  995 + }
  996 +
  997 + /**
969 * Callback from the tick hook, ticks all tickable mods 998 * Callback from the tick hook, ticks all tickable mods
970 * 999 *
971 * @param tick True if this is a new tick (otherwise it's just a new frame) 1000 * @param tick True if this is a new tick (otherwise it's just a new frame)