Commit c92c91ea81534b1f1545d7d4ccbfba6a8e28f8ef

Authored by Mumfrey
1 parent 14886082

Liteloader 1.4.0

.classpath
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <classpath> 2 <classpath>
3 <classpathentry kind="src" path="java"/> 3 <classpathentry kind="src" path="java"/>
  4 + <classpathentry kind="src" path="res"/>
4 <classpathentry combineaccessrules="false" kind="src" path="/Client"/> 5 <classpathentry combineaccessrules="false" kind="src" path="/Client"/>
5 <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"/>
6 <classpathentry kind="lib" path="jars/bin/jinput.jar"> 7 <classpathentry kind="lib" path="jars/bin/jinput.jar">
java/com/mumfrey/liteloader/core/CallableLiteLoaderMods.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.core;
  2 +
  3 +import java.util.concurrent.Callable;
  4 +
  5 +import net.minecraft.src.CrashReport;
  6 +
  7 +public class CallableLiteLoaderMods implements Callable<String>
  8 +{
  9 + final CrashReport crashReport;
  10 +
  11 + public CallableLiteLoaderMods(CrashReport report)
  12 + {
  13 + this.crashReport = report;
  14 + }
  15 +
  16 + /* (non-Javadoc)
  17 + * @see java.util.concurrent.Callable#call()
  18 + */
  19 + @Override
  20 + public String call() throws Exception
  21 + {
  22 + return LiteLoader.getInstance().getLoadedModsList();
  23 + }
  24 +}
java/com/mumfrey/liteloader/core/FilteringClassLoader.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.core;
  2 +
  3 +import java.io.IOException;
  4 +import java.io.InputStream;
  5 +import java.net.URL;
  6 +import java.net.URLClassLoader;
  7 +import java.util.Enumeration;
  8 +
  9 +import net.minecraft.client.Minecraft;
  10 +
  11 +public class FilteringClassLoader extends URLClassLoader
  12 +{
  13 + public FilteringClassLoader()
  14 + {
  15 + super(new URL[0], Minecraft.class.getClassLoader());
  16 + }
  17 +
  18 + /* (non-Javadoc)
  19 + * @see java.lang.ClassLoader#loadClass(java.lang.String)
  20 + */
  21 + @Override
  22 + public Class<?> loadClass(String name) throws ClassNotFoundException
  23 + {
  24 + System.out.println("Parent is trying to load class " + name);
  25 + return super.loadClass(name);
  26 + }
  27 +
  28 + /* (non-Javadoc)
  29 + * @see java.lang.ClassLoader#findClass(java.lang.String)
  30 + */
  31 + @Override
  32 + protected Class<?> findClass(String name) throws ClassNotFoundException
  33 + {
  34 + System.out.println("findClass " + name);
  35 + // TODO Auto-generated method stub
  36 + return super.findClass(name);
  37 + }
  38 +
  39 + /* (non-Javadoc)
  40 + * @see java.lang.ClassLoader#getResource(java.lang.String)
  41 + */
  42 + @Override
  43 + public URL getResource(String name)
  44 + {
  45 + System.out.println("getResource " + name);
  46 + // TODO Auto-generated method stub
  47 + return super.getResource(name);
  48 + }
  49 +
  50 + /* (non-Javadoc)
  51 + * @see java.lang.ClassLoader#getResources(java.lang.String)
  52 + */
  53 + @Override
  54 + public Enumeration<URL> getResources(String name) throws IOException
  55 + {
  56 + System.out.println("getResources " + name);
  57 + // TODO Auto-generated method stub
  58 + return super.getResources(name);
  59 + }
  60 +
  61 + /* (non-Javadoc)
  62 + * @see java.lang.ClassLoader#findResource(java.lang.String)
  63 + */
  64 + @Override
  65 + public URL findResource(String name)
  66 + {
  67 + System.out.println("findResource " + name);
  68 + // TODO Auto-generated method stub
  69 + return super.findResource(name);
  70 + }
  71 +
  72 + /* (non-Javadoc)
  73 + * @see java.lang.ClassLoader#findResources(java.lang.String)
  74 + */
  75 + @Override
  76 + public Enumeration<URL> findResources(String name) throws IOException
  77 + {
  78 + System.out.println("findResources " + name);
  79 + // TODO Auto-generated method stub
  80 + return super.findResources(name);
  81 + }
  82 +
  83 + /* (non-Javadoc)
  84 + * @see java.lang.ClassLoader#getResourceAsStream(java.lang.String)
  85 + */
  86 + @Override
  87 + public InputStream getResourceAsStream(String name)
  88 + {
  89 + System.out.println("getResourceAsStream " + name);
  90 + // TODO Auto-generated method stub
  91 + return super.getResourceAsStream(name);
  92 + }
  93 +
  94 + /* (non-Javadoc)
  95 + * @see java.lang.ClassLoader#getPackage(java.lang.String)
  96 + */
  97 + @Override
  98 + protected Package getPackage(String name)
  99 + {
  100 + System.out.println("getPackage " + name);
  101 + // TODO Auto-generated method stub
  102 + return super.getPackage(name);
  103 + }
  104 +
  105 + /* (non-Javadoc)
  106 + * @see java.lang.ClassLoader#getPackages()
  107 + */
  108 + @Override
  109 + protected Package[] getPackages()
  110 + {
  111 + System.out.println("getPackages");
  112 + // TODO Auto-generated method stub
  113 + return super.getPackages();
  114 + }
  115 +
  116 + /* (non-Javadoc)
  117 + * @see java.lang.ClassLoader#findLibrary(java.lang.String)
  118 + */
  119 + @Override
  120 + protected String findLibrary(String libname)
  121 + {
  122 + System.out.println("findLibrary " + libname);
  123 + // TODO Auto-generated method stub
  124 + return super.findLibrary(libname);
  125 + }
  126 +
  127 + /* (non-Javadoc)
  128 + * @see java.lang.ClassLoader#setDefaultAssertionStatus(boolean)
  129 + */
  130 + @Override
  131 + public synchronized void setDefaultAssertionStatus(boolean enabled)
  132 + {
  133 + System.out.println("setDefaultAssertionStatus " + enabled);
  134 + // TODO Auto-generated method stub
  135 + super.setDefaultAssertionStatus(enabled);
  136 + }
  137 +
  138 + /* (non-Javadoc)
  139 + * @see java.lang.ClassLoader#setPackageAssertionStatus(java.lang.String, boolean)
  140 + */
  141 + @Override
  142 + public synchronized void setPackageAssertionStatus(String packageName, boolean enabled)
  143 + {
  144 + System.out.println("setPackageAssertionStatus " + packageName + " " + enabled);
  145 + // TODO Auto-generated method stub
  146 + super.setPackageAssertionStatus(packageName, enabled);
  147 + }
  148 +
  149 + /* (non-Javadoc)
  150 + * @see java.lang.ClassLoader#setClassAssertionStatus(java.lang.String, boolean)
  151 + */
  152 + @Override
  153 + public synchronized void setClassAssertionStatus(String className, boolean enabled)
  154 + {
  155 + System.out.println("setClassAssertionStatus " + className + " " + enabled);
  156 + // TODO Auto-generated method stub
  157 + super.setClassAssertionStatus(className, enabled);
  158 + }
  159 +
  160 + /* (non-Javadoc)
  161 + * @see java.lang.ClassLoader#clearAssertionStatus()
  162 + */
  163 + @Override
  164 + public synchronized void clearAssertionStatus()
  165 + {
  166 + System.out.println("clearAssertionStatus");
  167 + // TODO Auto-generated method stub
  168 + super.clearAssertionStatus();
  169 + }
  170 +}
java/com/mumfrey/liteloader/core/HookChat.java
@@ -3,16 +3,12 @@ package com.mumfrey.liteloader.core; @@ -3,16 +3,12 @@ package com.mumfrey.liteloader.core;
3 import java.io.DataInputStream; 3 import java.io.DataInputStream;
4 import java.io.DataOutputStream; 4 import java.io.DataOutputStream;
5 import java.io.IOException; 5 import java.io.IOException;
6 -import java.lang.reflect.Constructor;  
7 import java.util.Map; 6 import java.util.Map;
8 7
9 -import net.minecraft.src.IntHashMap;  
10 -import net.minecraft.src.NetHandler;  
11 -import net.minecraft.src.Packet;  
12 -import net.minecraft.src.Packet3Chat;  
13 -  
14 import com.mumfrey.liteloader.util.PrivateFields; 8 import com.mumfrey.liteloader.util.PrivateFields;
15 9
  10 +import net.minecraft.src.*;
  11 +
16 /** 12 /**
17 * Proxy packet which we will register in place of the original chat packet. The class will proxy the function calls 13 * Proxy packet which we will register in place of the original chat packet. The class will proxy the function calls
18 * through to the replaced class via reflection if the original (replaced) class is NOT the basic Packet3Chat (this 14 * through to the replaced class via reflection if the original (replaced) class is NOT the basic Packet3Chat (this
java/com/mumfrey/liteloader/core/HookPluginChannels.java
@@ -3,16 +3,11 @@ package com.mumfrey.liteloader.core; @@ -3,16 +3,11 @@ package com.mumfrey.liteloader.core;
3 import java.io.DataInputStream; 3 import java.io.DataInputStream;
4 import java.io.DataOutputStream; 4 import java.io.DataOutputStream;
5 import java.io.IOException; 5 import java.io.IOException;
6 -import java.lang.reflect.Constructor;  
7 import java.util.Map; 6 import java.util.Map;
8 7
9 import com.mumfrey.liteloader.util.PrivateFields; 8 import com.mumfrey.liteloader.util.PrivateFields;
10 9
11 -import net.minecraft.src.IntHashMap;  
12 -import net.minecraft.src.NetHandler;  
13 -import net.minecraft.src.Packet;  
14 -import net.minecraft.src.Packet250CustomPayload;  
15 -import net.minecraft.src.Packet3Chat; 10 +import net.minecraft.src.*;
16 11
17 public class HookPluginChannels extends Packet250CustomPayload 12 public class HookPluginChannels extends Packet250CustomPayload
18 { 13 {
java/com/mumfrey/liteloader/core/LiteLoader.java
1 package com.mumfrey.liteloader.core; 1 package com.mumfrey.liteloader.core;
2 2
3 -import java.io.BufferedReader;  
4 -import java.io.File;  
5 -import java.io.FileInputStream;  
6 -import java.io.FileNotFoundException;  
7 -import java.io.FilenameFilter;  
8 -import java.io.IOException;  
9 -import java.io.InputStream;  
10 -import java.io.InputStreamReader;  
11 -import java.io.PrintWriter; 3 +import java.io.*;
12 import java.lang.reflect.Constructor; 4 import java.lang.reflect.Constructor;
13 import java.lang.reflect.Method; 5 import java.lang.reflect.Method;
14 import java.net.URL; 6 import java.net.URL;
15 import java.net.URLClassLoader; 7 import java.net.URLClassLoader;
  8 +import java.nio.CharBuffer;
16 import java.nio.charset.Charset; 9 import java.nio.charset.Charset;
17 -import java.util.Arrays;  
18 -import java.util.HashMap;  
19 -import java.util.Iterator;  
20 -import java.util.LinkedList;  
21 -import java.util.List;  
22 -import java.util.logging.ConsoleHandler;  
23 -import java.util.logging.FileHandler; 10 +import java.util.*;
  11 +import java.util.concurrent.Callable;
  12 +import java.util.logging.*;
24 import java.util.logging.Formatter; 13 import java.util.logging.Formatter;
25 -import java.util.logging.Level;  
26 -import java.util.logging.Logger;  
27 -import java.util.logging.StreamHandler;  
28 import java.util.zip.ZipEntry; 14 import java.util.zip.ZipEntry;
29 import java.util.zip.ZipFile; 15 import java.util.zip.ZipFile;
30 import java.util.zip.ZipInputStream; 16 import java.util.zip.ZipInputStream;
31 17
32 -import net.minecraft.client.Minecraft;  
33 -import net.minecraft.src.ConsoleLogManager;  
34 -import net.minecraft.src.NetHandler;  
35 -import net.minecraft.src.Packet1Login;  
36 -import net.minecraft.src.Packet250CustomPayload;  
37 -import net.minecraft.src.Packet3Chat;  
38 -import net.minecraft.src.Timer;  
39 -  
40 -import com.mumfrey.liteloader.ChatFilter;  
41 -import com.mumfrey.liteloader.ChatListener;  
42 -import com.mumfrey.liteloader.InitCompleteListener;  
43 -import com.mumfrey.liteloader.LiteMod;  
44 -import com.mumfrey.liteloader.LoginListener;  
45 -import com.mumfrey.liteloader.PluginChannelListener;  
46 -import com.mumfrey.liteloader.Tickable; 18 +import com.mumfrey.liteloader.*;
47 import com.mumfrey.liteloader.util.ModUtilities; 19 import com.mumfrey.liteloader.util.ModUtilities;
48 import com.mumfrey.liteloader.util.PrivateFields; 20 import com.mumfrey.liteloader.util.PrivateFields;
  21 +import com.sun.corba.se.impl.ior.ByteBuffer;
  22 +
  23 +import net.minecraft.client.Minecraft;
  24 +import net.minecraft.src.*;
  25 +import net.minecraft.src.Timer;
49 26
50 /** 27 /**
51 * 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
52 * 29 *
53 * @author Adam Mummery-Smith 30 * @author Adam Mummery-Smith
54 - * @version 1.3.2_03 31 + * @version 1.4.0
55 */ 32 */
56 public final class LiteLoader implements FilenameFilter 33 public final class LiteLoader implements FilenameFilter
57 { 34 {
58 /** 35 /**
59 * Liteloader version 36 * Liteloader version
60 */ 37 */
61 - private static final String LOADER_VERSION = "1.3.2_03"; 38 + private static final String LOADER_VERSION = "1.4.0";
  39 +
  40 + /**
  41 + * Loader revision, can be used by mods to determine whether the loader is sufficiently up-to-date
  42 + */
  43 + private static final int LOADER_REVISION = 4;
62 44
63 /** 45 /**
64 * Minecraft versions that we will load mods for, this will be compared 46 * Minecraft versions that we will load mods for, this will be compared
65 * against the version.txt value in mod files to prevent outdated mods being 47 * against the version.txt value in mod files to prevent outdated mods being
66 * loaded!!! 48 * loaded!!!
67 */ 49 */
68 - private static final String[] SUPPORTED_VERSIONS = { "1.3.1", "1.3.2" }; 50 + private static final String[] SUPPORTED_VERSIONS = { "1.4.0", "1.4" };
69 51
70 /** 52 /**
71 * LiteLoader is a singleton, this is the singleton instance 53 * LiteLoader is a singleton, this is the singleton instance
@@ -91,6 +73,11 @@ public final class LiteLoader implements FilenameFilter @@ -91,6 +73,11 @@ public final class LiteLoader implements FilenameFilter
91 * Reference to the minecraft timer 73 * Reference to the minecraft timer
92 */ 74 */
93 private Timer minecraftTimer; 75 private Timer minecraftTimer;
  76 +
  77 + /**
  78 + * List of loaded mods, for crash reporting
  79 + */
  80 + private String loadedModsList = "none";
94 81
95 /** 82 /**
96 * Global list of mods which we have loaded 83 * Global list of mods which we have loaded
@@ -157,16 +144,44 @@ public final class LiteLoader implements FilenameFilter @@ -157,16 +144,44 @@ public final class LiteLoader implements FilenameFilter
157 return instance; 144 return instance;
158 } 145 }
159 146
  147 + /**
  148 + * Get the LiteLoader logger object
  149 + *
  150 + * @return
  151 + */
160 public static final Logger getLogger() 152 public static final Logger getLogger()
161 { 153 {
162 return logger; 154 return logger;
163 } 155 }
164 156
165 /** 157 /**
  158 + * Get LiteLoader version
  159 + *
  160 + * @return
  161 + */
  162 + public static final String getVersion()
  163 + {
  164 + return LOADER_VERSION;
  165 + }
  166 +
  167 + /**
  168 + * Get the loader revision
  169 + *
  170 + * @return
  171 + */
  172 + public static final int getRevision()
  173 + {
  174 + return LOADER_REVISION;
  175 + }
  176 +
  177 + /**
166 * LiteLoader constructor 178 * LiteLoader constructor
167 */ 179 */
168 private LiteLoader() 180 private LiteLoader()
169 { 181 {
  182 + // Set up base class overrides
  183 + prepareClassOverrides();
  184 +
170 // Set up loader, initialises any reflection methods needed 185 // Set up loader, initialises any reflection methods needed
171 prepareLoader(); 186 prepareLoader();
172 187
@@ -183,6 +198,52 @@ public final class LiteLoader implements FilenameFilter @@ -183,6 +198,52 @@ public final class LiteLoader implements FilenameFilter
183 } 198 }
184 199
185 /** 200 /**
  201 + *
  202 + */
  203 + private void prepareClassOverrides()
  204 + {
  205 + registerBaseClassOverride(ModUtilities.getObfuscatedFieldName("net.minecraft.src.CallableJVMFlags", "g"), "g");
  206 + }
  207 +
  208 + /**
  209 + * Reads a base class overrride from a resource file
  210 + *
  211 + * @param binaryClassName
  212 + * @param fileName
  213 + */
  214 + private void registerBaseClassOverride(String binaryClassName, String fileName)
  215 + {
  216 + try
  217 + {
  218 + Method mDefineClass = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class);
  219 + mDefineClass.setAccessible(true);
  220 +
  221 + InputStream resourceInputStream = LiteLoader.class.getResourceAsStream("/classes/" + fileName + ".bin");
  222 +
  223 + if (resourceInputStream != null)
  224 + {
  225 + ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  226 +
  227 + for (int readBytes = resourceInputStream.read(); readBytes >= 0; readBytes = resourceInputStream.read())
  228 + {
  229 + outputStream.write(readBytes);
  230 + }
  231 +
  232 + byte[] data = outputStream.toByteArray();
  233 +
  234 + outputStream.close();
  235 + resourceInputStream.close();
  236 +
  237 + mDefineClass.invoke(Minecraft.class.getClassLoader(), binaryClassName, data, 0, data.length);
  238 + }
  239 + }
  240 + catch (Throwable th)
  241 + {
  242 + th.printStackTrace();
  243 + }
  244 + }
  245 +
  246 + /**
186 * Set up reflection methods required by the loader 247 * Set up reflection methods required by the loader
187 */ 248 */
188 @SuppressWarnings("unchecked") 249 @SuppressWarnings("unchecked")
@@ -205,7 +266,7 @@ public final class LiteLoader implements FilenameFilter @@ -205,7 +266,7 @@ public final class LiteLoader implements FilenameFilter
205 } 266 }
206 catch (Exception ex) 267 catch (Exception ex)
207 { 268 {
208 - ConsoleLogManager.func_73699_a(); 269 + ConsoleLogManager.init();
209 minecraftLogFormatter = ConsoleLogManager.loggerLogManager.getHandlers()[0].getFormatter(); 270 minecraftLogFormatter = ConsoleLogManager.loggerLogManager.getHandlers()[0].getFormatter();
210 } 271 }
211 272
@@ -250,6 +311,16 @@ public final class LiteLoader implements FilenameFilter @@ -250,6 +311,16 @@ public final class LiteLoader implements FilenameFilter
250 } 311 }
251 312
252 /** 313 /**
  314 + * Used for crash reporting
  315 + *
  316 + * @return List of loaded mods as a string
  317 + */
  318 + public String getLoadedModsList()
  319 + {
  320 + return loadedModsList;
  321 + }
  322 +
  323 + /**
253 * Enumerate the java class path and "mods" folder to find mod classes, then load the classes 324 * Enumerate the java class path and "mods" folder to find mod classes, then load the classes
254 */ 325 */
255 private void prepareMods() 326 private void prepareMods()
@@ -425,6 +496,9 @@ public final class LiteLoader implements FilenameFilter @@ -425,6 +496,9 @@ public final class LiteLoader implements FilenameFilter
425 */ 496 */
426 private void initMods() 497 private void initMods()
427 { 498 {
  499 + loadedModsList = "";
  500 + int loadedModsCount = 0;
  501 +
428 for (Iterator<LiteMod> iter = mods.iterator(); iter.hasNext();) 502 for (Iterator<LiteMod> iter = mods.iterator(); iter.hasNext();)
429 { 503 {
430 LiteMod mod = iter.next(); 504 LiteMod mod = iter.next();
@@ -464,6 +538,9 @@ public final class LiteLoader implements FilenameFilter @@ -464,6 +538,9 @@ public final class LiteLoader implements FilenameFilter
464 { 538 {
465 pluginChannelListeners.add((PluginChannelListener)mod); 539 pluginChannelListeners.add((PluginChannelListener)mod);
466 } 540 }
  541 +
  542 + loadedModsList += String.format("\n - %s version %s", mod.getName(), mod.getVersion());
  543 + loadedModsCount++;
467 } 544 }
468 catch (Throwable th) 545 catch (Throwable th)
469 { 546 {
@@ -471,6 +548,8 @@ public final class LiteLoader implements FilenameFilter @@ -471,6 +548,8 @@ public final class LiteLoader implements FilenameFilter
471 iter.remove(); 548 iter.remove();
472 } 549 }
473 } 550 }
  551 +
  552 + loadedModsList = String.format("%s loaded mod(s)%s", loadedModsCount, loadedModsList);
474 } 553 }
475 554
476 /** 555 /**
@@ -633,6 +712,7 @@ public final class LiteLoader implements FilenameFilter @@ -633,6 +712,7 @@ public final class LiteLoader implements FilenameFilter
633 * @param classes 712 * @param classes
634 * @param className 713 * @param className
635 */ 714 */
  715 + @SuppressWarnings("unchecked")
636 private static void checkAndAddClass(ClassLoader classloader, Class superClass, LinkedList<Class> classes, String className) 716 private static void checkAndAddClass(ClassLoader classloader, Class superClass, LinkedList<Class> classes, String className)
637 { 717 {
638 if (className.indexOf('$') > -1) 718 if (className.indexOf('$') > -1)
@@ -714,14 +794,15 @@ public final class LiteLoader implements FilenameFilter @@ -714,14 +794,15 @@ public final class LiteLoader implements FilenameFilter
714 if (tick || minecraftTimer == null) 794 if (tick || minecraftTimer == null)
715 { 795 {
716 minecraftTimer = PrivateFields.minecraftTimer.Get(minecraft); 796 minecraftTimer = PrivateFields.minecraftTimer.Get(minecraft);
  797 + }
717 798
718 - // Hooray, we got the timer reference  
719 - if (minecraftTimer != null)  
720 - {  
721 - partialTicks = minecraftTimer.elapsedPartialTicks;  
722 - } 799 + // Hooray, we got the timer reference
  800 + if (minecraftTimer != null)
  801 + {
  802 + partialTicks = minecraftTimer.elapsedPartialTicks;
  803 + tick = minecraftTimer.elapsedTicks > 0;
723 } 804 }
724 - 805 +
725 // Flag indicates whether we are in game at the moment 806 // Flag indicates whether we are in game at the moment
726 boolean inGame = minecraft.renderViewEntity != null && minecraft.renderViewEntity.worldObj != null; 807 boolean inGame = minecraft.renderViewEntity != null && minecraft.renderViewEntity.worldObj != null;
727 808
@@ -845,20 +926,4 @@ public final class LiteLoader implements FilenameFilter @@ -845,20 +926,4 @@ public final class LiteLoader implements FilenameFilter
845 sendPluginChannelMessage("REGISTER", registrationData); 926 sendPluginChannelMessage("REGISTER", registrationData);
846 } 927 }
847 } 928 }
848 -}  
849 -  
850 -  
851 -  
852 -  
853 -  
854 -  
855 -  
856 -  
857 -  
858 -  
859 -  
860 -  
861 -  
862 -  
863 -  
864 - 929 +}
865 \ No newline at end of file 930 \ No newline at end of file
java/com/mumfrey/liteloader/core/LiteLoaderHook.java
@@ -105,6 +105,7 @@ public class LiteLoaderHook extends Profiler @@ -105,6 +105,7 @@ public class LiteLoaderHook extends Profiler
105 105
106 if (config != null) 106 if (config != null)
107 { 107 {
  108 + @SuppressWarnings("unchecked")
108 Method getVersion = config.getDeclaredMethod("getVersion"); 109 Method getVersion = config.getDeclaredMethod("getVersion");
109 110
110 if (getVersion != null) 111 if (getVersion != null)
java/com/mumfrey/liteloader/util/ModUtilities.java
1 package com.mumfrey.liteloader.util; 1 package com.mumfrey.liteloader.util;
2 2
3 -import java.lang.reflect.Field;  
4 import java.util.Arrays; 3 import java.util.Arrays;
5 import java.util.LinkedList; 4 import java.util.LinkedList;
6 import java.util.Map; 5 import java.util.Map;
7 6
8 -import net.minecraft.client.Minecraft;  
9 -import net.minecraft.src.IntHashMap;  
10 -import net.minecraft.src.KeyBinding;  
11 -import net.minecraft.src.Packet;  
12 -import net.minecraft.src.Packet250CustomPayload;  
13 -import net.minecraft.src.Render;  
14 -import net.minecraft.src.RenderManager;  
15 -import net.minecraft.src.Tessellator;  
16 -  
17 import com.mumfrey.liteloader.core.LiteLoader; 7 import com.mumfrey.liteloader.core.LiteLoader;
18 8
  9 +import net.minecraft.client.Minecraft;
  10 +import net.minecraft.src.*;
  11 +
19 public abstract class ModUtilities 12 public abstract class ModUtilities
20 { 13 {
21 /** 14 /**
@@ -24,9 +17,10 @@ public abstract class ModUtilities @@ -24,9 +17,10 @@ public abstract class ModUtilities
24 * @param entityClass 17 * @param entityClass
25 * @param renderer 18 * @param renderer
26 */ 19 */
27 - public static void addRenderer(Class entityClass, Render renderer) 20 + @SuppressWarnings("unchecked")
  21 + public static void addRenderer(Class<? extends Entity> entityClass, Render renderer)
28 { 22 {
29 - Map entityRenderMap = PrivateFields.entityRenderMap.Get(RenderManager.instance); 23 + Map<Class<? extends Entity>, Render> entityRenderMap = PrivateFields.entityRenderMap.Get(RenderManager.instance);
30 entityRenderMap.put(entityClass, renderer); 24 entityRenderMap.put(entityClass, renderer);
31 renderer.setRenderManager(RenderManager.instance); 25 renderer.setRenderManager(RenderManager.instance);
32 } 26 }
@@ -37,13 +31,14 @@ public abstract class ModUtilities @@ -37,13 +31,14 @@ public abstract class ModUtilities
37 * @param packetId 31 * @param packetId
38 * @param newPacket 32 * @param newPacket
39 */ 33 */
40 - public static boolean registerPacketOverride(int packetId, Class newPacket) 34 + @SuppressWarnings("unchecked")
  35 + public static boolean registerPacketOverride(int packetId, Class<? extends Packet> newPacket)
41 { 36 {
42 try 37 try
43 { 38 {
44 IntHashMap packetIdToClassMap = Packet.packetIdToClassMap; 39 IntHashMap packetIdToClassMap = Packet.packetIdToClassMap;
45 PrivateFields.StaticFields.packetClassToIdMap.Get(); 40 PrivateFields.StaticFields.packetClassToIdMap.Get();
46 - Map packetClassToIdMap = PrivateFields.StaticFields.packetClassToIdMap.Get(); 41 + Map<Class<? extends Packet>, Integer> packetClassToIdMap = PrivateFields.StaticFields.packetClassToIdMap.Get();
47 42
48 packetIdToClassMap.removeObject(packetId); 43 packetIdToClassMap.removeObject(packetId);
49 packetIdToClassMap.addKey(packetId, newPacket); 44 packetIdToClassMap.addKey(packetId, newPacket);
@@ -111,6 +106,7 @@ public abstract class ModUtilities @@ -111,6 +106,7 @@ public abstract class ModUtilities
111 { 106 {
112 keyBindings.add(newBinding); 107 keyBindings.add(newBinding);
113 mc.gameSettings.keyBindings = keyBindings.toArray(new KeyBinding[0]); 108 mc.gameSettings.keyBindings = keyBindings.toArray(new KeyBinding[0]);
  109 + mc.gameSettings.loadOptions();
114 } 110 }
115 } 111 }
116 112
java/com/mumfrey/liteloader/util/PrivateFields.java
1 package com.mumfrey.liteloader.util; 1 package com.mumfrey.liteloader.util;
2 2
3 -import java.io.File;  
4 import java.lang.reflect.Field; 3 import java.lang.reflect.Field;
5 import java.lang.reflect.Modifier; 4 import java.lang.reflect.Modifier;
6 import java.util.Map; 5 import java.util.Map;
7 -import java.util.Properties;  
8 -import java.util.zip.ZipFile;  
9 6
10 import net.minecraft.client.Minecraft; 7 import net.minecraft.client.Minecraft;
11 -import net.minecraft.src.GuiButton;  
12 -import net.minecraft.src.GuiIngame;  
13 -import net.minecraft.src.GuiScreen;  
14 -import net.minecraft.src.GuiSlot;  
15 -import net.minecraft.src.GuiTexturePacks;  
16 -import net.minecraft.src.NetClientHandler;  
17 -import net.minecraft.src.NetworkManager;  
18 -import net.minecraft.src.Packet;  
19 -import net.minecraft.src.Profiler;  
20 -import net.minecraft.src.RenderEngine;  
21 -import net.minecraft.src.RenderGlobal;  
22 -import net.minecraft.src.RenderManager;  
23 -import net.minecraft.src.SoundManager;  
24 -import net.minecraft.src.SoundPool;  
25 -import net.minecraft.src.StringTranslate;  
26 -import net.minecraft.src.TexturePackCustom;  
27 -import net.minecraft.src.TexturePackImplementation;  
28 -import net.minecraft.src.TexturePackList;  
29 -import net.minecraft.src.TileEntity;  
30 -import net.minecraft.src.Timer;  
31 -import net.minecraft.src.WorldInfo;  
32 -import net.minecraft.src.WorldRenderer;  
33 -import net.minecraft.src.WorldType; 8 +import net.minecraft.src.*;
34 9
35 /** 10 /**
36 * Wrapper for obf/mcp reflection-accessed private fields, mainly added to centralise the locations I have to update the obfuscated field names 11 * Wrapper for obf/mcp reflection-accessed private fields, mainly added to centralise the locations I have to update the obfuscated field names
java/net/minecraft/src/CallableJVMFlags.java 0 โ†’ 100644
  1 +package net.minecraft.src;
  2 +
  3 +import java.lang.management.ManagementFactory;
  4 +import java.lang.management.RuntimeMXBean;
  5 +import java.util.Iterator;
  6 +import java.util.List;
  7 +import java.util.concurrent.Callable;
  8 +
  9 +import com.mumfrey.liteloader.core.CallableLiteLoaderMods;
  10 +
  11 +class CallableJVMFlags implements Callable
  12 +{
  13 + /** Gets additional Java Enviroment info for Crash Report. */
  14 + final CrashReport crashReportJVMFlags;
  15 +
  16 + CallableJVMFlags(CrashReport par1CrashReport)
  17 + {
  18 + this.crashReportJVMFlags = par1CrashReport;
  19 + par1CrashReport.addCrashSectionCallable("LiteLoader Mods", new CallableLiteLoaderMods(par1CrashReport));
  20 + }
  21 +
  22 + public String func_71487_a()
  23 + {
  24 + RuntimeMXBean var1 = ManagementFactory.getRuntimeMXBean();
  25 + List var2 = var1.getInputArguments();
  26 + int var3 = 0;
  27 + StringBuilder var4 = new StringBuilder();
  28 + Iterator var5 = var2.iterator();
  29 +
  30 + while (var5.hasNext())
  31 + {
  32 + String var6 = (String)var5.next();
  33 +
  34 + if (var6.startsWith("-X"))
  35 + {
  36 + if (var3++ > 0)
  37 + {
  38 + var4.append(" ");
  39 + }
  40 +
  41 + var4.append(var6);
  42 + }
  43 + }
  44 +
  45 + return String.format("%d total; %s", new Object[] {Integer.valueOf(var3), var4.toString()});
  46 + }
  47 +
  48 + @Override
  49 + public Object call()
  50 + {
  51 + return this.func_71487_a();
  52 + }
  53 +}