Commit 4dc2ac38db687687f7747a9f3421ea5d41516175
1 parent
0e1a1e12
LiteLoader 1.4.5_02
+ Added callback pre GUI render to RenderListener + Added forge compatibility to class loading from Macros
Showing
4 changed files
with
57 additions
and
16 deletions
.classpath
... | ... | @@ -2,7 +2,6 @@ |
2 | 2 | <classpath> |
3 | 3 | <classpathentry kind="src" path="java"/> |
4 | 4 | <classpathentry kind="src" path="res"/> |
5 | - <classpathentry combineaccessrules="false" kind="src" path="/ClientMods"/> | |
6 | 5 | <classpathentry combineaccessrules="false" kind="src" path="/Client"/> |
7 | 6 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6"/> |
8 | 7 | <classpathentry kind="lib" path="/Client/jars/bin/jinput.jar"/> | ... | ... |
java/com/mumfrey/liteloader/RenderListener.java
1 | 1 | package com.mumfrey.liteloader; |
2 | 2 | |
3 | +import net.minecraft.src.GuiScreen; | |
4 | + | |
3 | 5 | /** |
4 | 6 | * Interface for objects which want a pre-render callback |
5 | 7 | * |
... | ... | @@ -12,5 +14,7 @@ public interface RenderListener extends LiteMod |
12 | 14 | */ |
13 | 15 | public abstract void onRender(); |
14 | 16 | |
17 | + public abstract void onRenderGui(GuiScreen currentScreen); | |
18 | + | |
15 | 19 | public abstract void onRenderWorld(); |
16 | 20 | } | ... | ... |
java/com/mumfrey/liteloader/core/HookProfiler.java
... | ... | @@ -5,7 +5,10 @@ import java.lang.reflect.Method; |
5 | 5 | import java.util.LinkedList; |
6 | 6 | import java.util.logging.Logger; |
7 | 7 | |
8 | +import com.mumfrey.liteloader.util.ModUtilities; | |
9 | + | |
8 | 10 | import net.minecraft.client.Minecraft; |
11 | +import net.minecraft.src.EntityPlayerSP; | |
9 | 12 | import net.minecraft.src.GameSettings; |
10 | 13 | import net.minecraft.src.Profiler; |
11 | 14 | |
... | ... | @@ -59,6 +62,8 @@ public class HookProfiler extends Profiler |
59 | 62 | */ |
60 | 63 | public HookProfiler(LiteLoader core, Logger logger) |
61 | 64 | { |
65 | + this.mc = Minecraft.getMinecraft(); | |
66 | + | |
62 | 67 | this.loader = core; |
63 | 68 | this.logger = logger; |
64 | 69 | |
... | ... | @@ -87,7 +92,6 @@ public class HookProfiler extends Profiler |
87 | 92 | if (ofProfiler != null) |
88 | 93 | { |
89 | 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 | 160 | } |
157 | 161 | } |
158 | 162 | } |
159 | - | |
163 | + | |
160 | 164 | /* (non-Javadoc) |
161 | 165 | * @see net.minecraft.src.Profiler#endSection() |
162 | 166 | */ |
... | ... | @@ -165,9 +169,10 @@ public class HookProfiler extends Profiler |
165 | 169 | { |
166 | 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 | 177 | super.startSection("litetick"); |
173 | 178 | |
... | ... | @@ -176,5 +181,9 @@ public class HookProfiler extends Profiler |
176 | 181 | |
177 | 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 | 5 | import java.lang.reflect.Method; |
6 | 6 | import java.net.URL; |
7 | 7 | import java.net.URLClassLoader; |
8 | +import java.net.URLDecoder; | |
8 | 9 | import java.nio.CharBuffer; |
9 | 10 | import java.nio.charset.Charset; |
10 | 11 | import java.util.*; |
... | ... | @@ -18,7 +19,6 @@ import java.util.zip.ZipInputStream; |
18 | 19 | import com.mumfrey.liteloader.*; |
19 | 20 | import com.mumfrey.liteloader.util.ModUtilities; |
20 | 21 | import com.mumfrey.liteloader.util.PrivateFields; |
21 | -import com.sun.corba.se.impl.ior.ByteBuffer; | |
22 | 22 | |
23 | 23 | import net.minecraft.client.Minecraft; |
24 | 24 | import net.minecraft.src.*; |
... | ... | @@ -28,7 +28,7 @@ import net.minecraft.src.Timer; |
28 | 28 | * LiteLoader is a simple loader which provides tick events to loaded mods |
29 | 29 | * |
30 | 30 | * @author Adam Mummery-Smith |
31 | - * @version 1.4.4 | |
31 | + * @version 1.4.5_02 | |
32 | 32 | */ |
33 | 33 | @SuppressWarnings("rawtypes") |
34 | 34 | public final class LiteLoader implements FilenameFilter |
... | ... | @@ -36,7 +36,7 @@ public final class LiteLoader implements FilenameFilter |
36 | 36 | /** |
37 | 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 | 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 | 128 | * List of mods which implement PluginChannelListener interface |
129 | 129 | */ |
130 | 130 | private LinkedList<PluginChannelListener> pluginChannelListeners = new LinkedList<PluginChannelListener>(); |
131 | - | |
131 | + | |
132 | 132 | /** |
133 | 133 | * Mapping of plugin channel names to listeners |
134 | 134 | */ |
... | ... | @@ -470,15 +470,35 @@ public final class LiteLoader implements FilenameFilter |
470 | 470 | { |
471 | 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 | 503 | catch (Throwable th) |
484 | 504 | { |
... | ... | @@ -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 | 998 | * Callback from the tick hook, ticks all tickable mods |
970 | 999 | * |
971 | 1000 | * @param tick True if this is a new tick (otherwise it's just a new frame) | ... | ... |