Commit 104bd7e59b0934c734f1179b7d6ce04caeb1e020

Authored by Mumfrey
1 parent 10c0f192

internal reshuffling to support dedicated server

Showing 30 changed files with 900 additions and 566 deletions
debug/com/mumfrey/liteloader/debug/Start.java
@@ -14,6 +14,7 @@ import net.minecraft.launchwrapper.Launch; @@ -14,6 +14,7 @@ import net.minecraft.launchwrapper.Launch;
14 import com.google.common.base.Strings; 14 import com.google.common.base.Strings;
15 import com.google.common.collect.ImmutableSet; 15 import com.google.common.collect.ImmutableSet;
16 import com.mumfrey.liteloader.launch.LiteLoaderTweaker; 16 import com.mumfrey.liteloader.launch.LiteLoaderTweaker;
  17 +import com.mumfrey.liteloader.launch.LiteLoaderTweakerServer;
17 import com.mumfrey.liteloader.util.log.LiteLoaderLogger; 18 import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
18 19
19 /** 20 /**
@@ -56,12 +57,32 @@ public abstract class Start @@ -56,12 +57,32 @@ public abstract class Start
56 Map<String, Set<String>> qualifiedArgs = new HashMap<String, Set<String>>(); 57 Map<String, Set<String>> qualifiedArgs = new HashMap<String, Set<String>>();
57 58
58 Start.parseArgs(args, unqualifiedArgs, qualifiedArgs); 59 Start.parseArgs(args, unqualifiedArgs, qualifiedArgs);
59 - Start.addRequiredArgs(args, unqualifiedArgs, qualifiedArgs); 60 +
  61 + if (Start.hasArg(unqualifiedArgs, "server"))
  62 + {
  63 + Start.addRequiredArgsServer(args, unqualifiedArgs, qualifiedArgs);
  64 + }
  65 + else
  66 + {
  67 + Start.addRequiredArgsClient(args, unqualifiedArgs, qualifiedArgs);
  68 + }
  69 +
60 args = Start.combineArgs(args, unqualifiedArgs, qualifiedArgs); 70 args = Start.combineArgs(args, unqualifiedArgs, qualifiedArgs);
61 71
62 return args; 72 return args;
63 } 73 }
64 74
  75 + private static boolean hasArg(List<String> args, String target)
  76 + {
  77 + for (String arg : args)
  78 + {
  79 + if (target.equalsIgnoreCase(arg))
  80 + return true;
  81 + }
  82 +
  83 + return false;
  84 + }
  85 +
65 /** 86 /**
66 * Read the args from the command line into the qualified and unqualified collections 87 * Read the args from the command line into the qualified and unqualified collections
67 */ 88 */
@@ -91,7 +112,7 @@ public abstract class Start @@ -91,7 +112,7 @@ public abstract class Start
91 if (qualifier != null) unqualifiedArgs.add(qualifier); 112 if (qualifier != null) unqualifiedArgs.add(qualifier);
92 } 113 }
93 114
94 - private static void addRequiredArgs(String[] args, List<String> unqualifiedArgs, Map<String, Set<String>> qualifiedArgs) 115 + private static void addRequiredArgsClient(String[] args, List<String> unqualifiedArgs, Map<String, Set<String>> qualifiedArgs)
95 { 116 {
96 LoginManager loginManager = Start.doLogin(qualifiedArgs); 117 LoginManager loginManager = Start.doLogin(qualifiedArgs);
97 118
@@ -109,6 +130,15 @@ public abstract class Start @@ -109,6 +130,15 @@ public abstract class Start
109 Start.addArg(qualifiedArgs, "--assetIndex", LiteLoaderTweaker.VERSION); 130 Start.addArg(qualifiedArgs, "--assetIndex", LiteLoaderTweaker.VERSION);
110 Start.addArg(qualifiedArgs, "--assetsDir", assetsDir.getAbsolutePath()); 131 Start.addArg(qualifiedArgs, "--assetsDir", assetsDir.getAbsolutePath());
111 } 132 }
  133 +
  134 + private static void addRequiredArgsServer(String[] args, List<String> unqualifiedArgs, Map<String, Set<String>> qualifiedArgs)
  135 + {
  136 + File gameDir = new File(System.getProperty("user.dir"));
  137 +
  138 + Start.addArg(qualifiedArgs, "--tweakClass", LiteLoaderTweakerServer.class.getName());
  139 + Start.addArg(qualifiedArgs, "--version", "mcp");
  140 + Start.addArg(qualifiedArgs, "--gameDir", gameDir.getAbsolutePath());
  141 + }
112 142
113 private static LoginManager doLogin(Map<String, Set<String>> qualifiedArgs) 143 private static LoginManager doLogin(Map<String, Set<String>> qualifiedArgs)
114 { 144 {
java/client/com/mumfrey/liteloader/client/GameEngineClient.java
1 package com.mumfrey.liteloader.client; 1 package com.mumfrey.liteloader.client;
2 2
3 import java.util.Arrays; 3 import java.util.Arrays;
4 -import java.util.HashMap;  
5 import java.util.LinkedList; 4 import java.util.LinkedList;
6 import java.util.List; 5 import java.util.List;
7 -import java.util.Map;  
8 6
9 import net.minecraft.client.Minecraft; 7 import net.minecraft.client.Minecraft;
10 import net.minecraft.client.audio.SoundHandler; 8 import net.minecraft.client.audio.SoundHandler;
11 import net.minecraft.client.gui.GuiNewChat; 9 import net.minecraft.client.gui.GuiNewChat;
12 import net.minecraft.client.gui.GuiScreen; 10 import net.minecraft.client.gui.GuiScreen;
13 import net.minecraft.client.gui.ScaledResolution; 11 import net.minecraft.client.gui.ScaledResolution;
14 -import net.minecraft.client.resources.IResourceManager;  
15 -import net.minecraft.client.resources.IResourcePack;  
16 import net.minecraft.client.settings.GameSettings; 12 import net.minecraft.client.settings.GameSettings;
17 import net.minecraft.client.settings.KeyBinding; 13 import net.minecraft.client.settings.KeyBinding;
18 import net.minecraft.profiler.Profiler; 14 import net.minecraft.profiler.Profiler;
@@ -20,7 +16,7 @@ import net.minecraft.server.integrated.IntegratedServer; @@ -20,7 +16,7 @@ import net.minecraft.server.integrated.IntegratedServer;
20 16
21 import com.mumfrey.liteloader.client.overlays.IMinecraft; 17 import com.mumfrey.liteloader.client.overlays.IMinecraft;
22 import com.mumfrey.liteloader.common.GameEngine; 18 import com.mumfrey.liteloader.common.GameEngine;
23 -import com.mumfrey.liteloader.common.LoadingProgress; 19 +import com.mumfrey.liteloader.common.Resources;
24 20
25 /** 21 /**
26 * 22 *
@@ -30,15 +26,7 @@ public class GameEngineClient implements GameEngine&lt;Minecraft, IntegratedServer&gt; @@ -30,15 +26,7 @@ public class GameEngineClient implements GameEngine&lt;Minecraft, IntegratedServer&gt;
30 { 26 {
31 private final Minecraft engine = Minecraft.getMinecraft(); 27 private final Minecraft engine = Minecraft.getMinecraft();
32 28
33 - /**  
34 - * Registered resource packs  
35 - */  
36 - private final Map<String, IResourcePack> registeredResourcePacks = new HashMap<String, IResourcePack>();  
37 -  
38 - /**  
39 - * True while initialising mods if we need to do a resource manager reload once the process is completed  
40 - */  
41 - private boolean pendingResourceReload; 29 + private final Resources<?, ?> resources = new ResourcesClient();
42 30
43 /* (non-Javadoc) 31 /* (non-Javadoc)
44 * @see com.mumfrey.liteloader.common.GameEngine#getProfiler() 32 * @see com.mumfrey.liteloader.common.GameEngine#getProfiler()
@@ -50,20 +38,6 @@ public class GameEngineClient implements GameEngine&lt;Minecraft, IntegratedServer&gt; @@ -50,20 +38,6 @@ public class GameEngineClient implements GameEngine&lt;Minecraft, IntegratedServer&gt;
50 } 38 }
51 39
52 /* (non-Javadoc) 40 /* (non-Javadoc)
53 - * @see com.mumfrey.liteloader.common.GameEngine#refreshResources(boolean)  
54 - */  
55 - @Override  
56 - public void refreshResources(boolean force)  
57 - {  
58 - if (this.pendingResourceReload || force)  
59 - {  
60 - LoadingProgress.setMessage("Reloading Resources...");  
61 - this.pendingResourceReload = false;  
62 - this.engine.refreshResources();  
63 - }  
64 - }  
65 -  
66 - /* (non-Javadoc)  
67 * @see com.mumfrey.liteloader.common.GameEngine#isClient() 41 * @see com.mumfrey.liteloader.common.GameEngine#isClient()
68 */ 42 */
69 @Override 43 @Override
@@ -126,6 +100,12 @@ public class GameEngineClient implements GameEngine&lt;Minecraft, IntegratedServer&gt; @@ -126,6 +100,12 @@ public class GameEngineClient implements GameEngine&lt;Minecraft, IntegratedServer&gt;
126 return this.engine.getIntegratedServer(); 100 return this.engine.getIntegratedServer();
127 } 101 }
128 102
  103 + @Override
  104 + public Resources<?, ?> getResources()
  105 + {
  106 + return this.resources;
  107 + }
  108 +
129 public GameSettings getGameSettings() 109 public GameSettings getGameSettings()
130 { 110 {
131 return this.engine.gameSettings; 111 return this.engine.gameSettings;
@@ -151,61 +131,11 @@ public class GameEngineClient implements GameEngine&lt;Minecraft, IntegratedServer&gt; @@ -151,61 +131,11 @@ public class GameEngineClient implements GameEngine&lt;Minecraft, IntegratedServer&gt;
151 return this.engine.gameSettings.hideGUI; 131 return this.engine.gameSettings.hideGUI;
152 } 132 }
153 133
154 - /* (non-Javadoc)  
155 - * @see com.mumfrey.liteloader.common.GameEngine#getResourceManager()  
156 - */  
157 - @Override  
158 - public IResourceManager getResourceManager()  
159 - {  
160 - return this.engine.getResourceManager();  
161 - }  
162 -  
163 public SoundHandler getSoundHandler() 134 public SoundHandler getSoundHandler()
164 { 135 {
165 return this.engine.getSoundHandler(); 136 return this.engine.getSoundHandler();
166 } 137 }
167 -  
168 - /* (non-Javadoc)  
169 - * @see com.mumfrey.liteloader.common.GameEngine#registerResourcePack(net.minecraft.client.resources.IResourcePack)  
170 - */  
171 - @Override  
172 - public boolean registerResourcePack(IResourcePack resourcePack)  
173 - {  
174 - if (!this.registeredResourcePacks.containsKey(resourcePack.getPackName()))  
175 - {  
176 - this.pendingResourceReload = true;  
177 -  
178 - List<IResourcePack> defaultResourcePacks = ((IMinecraft)this.engine).getDefaultResourcePacks();  
179 - if (!defaultResourcePacks.contains(resourcePack))  
180 - {  
181 - defaultResourcePacks.add(resourcePack);  
182 - this.registeredResourcePacks.put(resourcePack.getPackName(), resourcePack);  
183 - return true;  
184 - }  
185 - }  
186 -  
187 - return false;  
188 - }  
189 -  
190 - /* (non-Javadoc)  
191 - * @see com.mumfrey.liteloader.common.GameEngine#unRegisterResourcePack(net.minecraft.client.resources.IResourcePack)  
192 - */  
193 - @Override  
194 - public boolean unRegisterResourcePack(IResourcePack resourcePack)  
195 - {  
196 - if (this.registeredResourcePacks.containsValue(resourcePack))  
197 - {  
198 - this.pendingResourceReload = true;  
199 138
200 - List<IResourcePack> defaultResourcePacks = ((IMinecraft)this.engine).getDefaultResourcePacks();  
201 - this.registeredResourcePacks.remove(resourcePack.getPackName());  
202 - defaultResourcePacks.remove(resourcePack);  
203 - return true;  
204 - }  
205 -  
206 - return false;  
207 - }  
208 -  
209 /* (non-Javadoc) 139 /* (non-Javadoc)
210 * @see com.mumfrey.liteloader.common.GameEngine#getKeyBindings() 140 * @see com.mumfrey.liteloader.common.GameEngine#getKeyBindings()
211 */ 141 */
java/client/com/mumfrey/liteloader/client/LiteLoaderCoreProviderClient.java
1 package com.mumfrey.liteloader.client; 1 package com.mumfrey.liteloader.client;
2 2
  3 +import net.minecraft.client.resources.IResourceManager;
  4 +import net.minecraft.client.resources.IResourcePack;
3 import net.minecraft.client.resources.SimpleReloadableResourceManager; 5 import net.minecraft.client.resources.SimpleReloadableResourceManager;
4 import net.minecraft.network.INetHandler; 6 import net.minecraft.network.INetHandler;
5 import net.minecraft.network.play.server.S01PacketJoinGame; 7 import net.minecraft.network.play.server.S01PacketJoinGame;
@@ -7,6 +9,7 @@ import net.minecraft.world.World; @@ -7,6 +9,7 @@ import net.minecraft.world.World;
7 9
8 import com.mumfrey.liteloader.api.CoreProvider; 10 import com.mumfrey.liteloader.api.CoreProvider;
9 import com.mumfrey.liteloader.common.GameEngine; 11 import com.mumfrey.liteloader.common.GameEngine;
  12 +import com.mumfrey.liteloader.common.Resources;
10 import com.mumfrey.liteloader.core.LiteLoader; 13 import com.mumfrey.liteloader.core.LiteLoader;
11 import com.mumfrey.liteloader.core.LiteLoaderMods; 14 import com.mumfrey.liteloader.core.LiteLoaderMods;
12 import com.mumfrey.liteloader.launch.LoaderProperties; 15 import com.mumfrey.liteloader.launch.LoaderProperties;
@@ -45,10 +48,11 @@ public class LiteLoaderCoreProviderClient implements CoreProvider @@ -45,10 +48,11 @@ public class LiteLoaderCoreProviderClient implements CoreProvider
45 this.inhibitSoundManagerReload = this.properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_SOUND_MANAGER_FIX, true); 48 this.inhibitSoundManagerReload = this.properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_SOUND_MANAGER_FIX, true);
46 } 49 }
47 50
  51 + @SuppressWarnings("unchecked")
48 @Override 52 @Override
49 public void onPostInit(GameEngine<?, ?> engine) 53 public void onPostInit(GameEngine<?, ?> engine)
50 { 54 {
51 - this.soundHandlerReloadInhibitor = new SoundHandlerReloadInhibitor((SimpleReloadableResourceManager)engine.getResourceManager(), ((GameEngineClient)engine).getSoundHandler()); 55 + this.soundHandlerReloadInhibitor = new SoundHandlerReloadInhibitor((SimpleReloadableResourceManager)engine.getResources().getResourceManager(), ((GameEngineClient)engine).getSoundHandler());
52 56
53 if (this.inhibitSoundManagerReload) 57 if (this.inhibitSoundManagerReload)
54 { 58 {
@@ -56,7 +60,8 @@ public class LiteLoaderCoreProviderClient implements CoreProvider @@ -56,7 +60,8 @@ public class LiteLoaderCoreProviderClient implements CoreProvider
56 } 60 }
57 61
58 // Add self as a resource pack for texture/lang resources 62 // Add self as a resource pack for texture/lang resources
59 - LiteLoader.getGameEngine().registerResourcePack(new InternalResourcePack("LiteLoader", LiteLoader.class, "liteloader")); 63 + Resources<IResourceManager, IResourcePack> resources = (Resources<IResourceManager, IResourcePack>)LiteLoader.getGameEngine().getResources();
  64 + resources.registerResourcePack(new InternalResourcePack("LiteLoader", LiteLoader.class, "liteloader"));
60 } 65 }
61 66
62 @Override 67 @Override
java/client/com/mumfrey/liteloader/client/LiteLoaderEventBrokerClient.java
@@ -6,6 +6,8 @@ import net.minecraft.client.gui.GuiNewChat; @@ -6,6 +6,8 @@ import net.minecraft.client.gui.GuiNewChat;
6 import net.minecraft.client.gui.ScaledResolution; 6 import net.minecraft.client.gui.ScaledResolution;
7 import net.minecraft.client.renderer.entity.Render; 7 import net.minecraft.client.renderer.entity.Render;
8 import net.minecraft.client.renderer.entity.RenderManager; 8 import net.minecraft.client.renderer.entity.RenderManager;
  9 +import net.minecraft.client.resources.IResourceManager;
  10 +import net.minecraft.client.resources.IResourceManagerReloadListener;
9 import net.minecraft.client.shader.Framebuffer; 11 import net.minecraft.client.shader.Framebuffer;
10 import net.minecraft.entity.Entity; 12 import net.minecraft.entity.Entity;
11 import net.minecraft.network.play.client.C01PacketChatMessage; 13 import net.minecraft.network.play.client.C01PacketChatMessage;
@@ -19,9 +21,9 @@ import org.lwjgl.input.Mouse; @@ -19,9 +21,9 @@ import org.lwjgl.input.Mouse;
19 import com.mumfrey.liteloader.*; 21 import com.mumfrey.liteloader.*;
20 import com.mumfrey.liteloader.client.overlays.IMinecraft; 22 import com.mumfrey.liteloader.client.overlays.IMinecraft;
21 import com.mumfrey.liteloader.common.LoadingProgress; 23 import com.mumfrey.liteloader.common.LoadingProgress;
22 -import com.mumfrey.liteloader.core.LiteLoaderEventBroker;  
23 import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate; 24 import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate;
24 import com.mumfrey.liteloader.core.LiteLoader; 25 import com.mumfrey.liteloader.core.LiteLoader;
  26 +import com.mumfrey.liteloader.core.LiteLoaderEventBroker;
25 import com.mumfrey.liteloader.core.event.HandlerList; 27 import com.mumfrey.liteloader.core.event.HandlerList;
26 import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp; 28 import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp;
27 import com.mumfrey.liteloader.interfaces.FastIterableDeque; 29 import com.mumfrey.liteloader.interfaces.FastIterableDeque;
@@ -30,7 +32,7 @@ import com.mumfrey.liteloader.transformers.event.EventInfo; @@ -30,7 +32,7 @@ import com.mumfrey.liteloader.transformers.event.EventInfo;
30 import com.mumfrey.liteloader.transformers.event.ReturnEventInfo; 32 import com.mumfrey.liteloader.transformers.event.ReturnEventInfo;
31 import com.mumfrey.liteloader.util.log.LiteLoaderLogger; 33 import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
32 34
33 -public class LiteLoaderEventBrokerClient extends LiteLoaderEventBroker<Minecraft, IntegratedServer> 35 +public class LiteLoaderEventBrokerClient extends LiteLoaderEventBroker<Minecraft, IntegratedServer> implements IResourceManagerReloadListener
34 { 36 {
35 private static LiteLoaderEventBrokerClient instance; 37 private static LiteLoaderEventBrokerClient instance;
36 38
@@ -89,6 +91,12 @@ public class LiteLoaderEventBrokerClient extends LiteLoaderEventBroker&lt;Minecraft @@ -89,6 +91,12 @@ public class LiteLoaderEventBrokerClient extends LiteLoaderEventBroker&lt;Minecraft
89 return LiteLoaderEventBrokerClient.instance; 91 return LiteLoaderEventBrokerClient.instance;
90 } 92 }
91 93
  94 + @Override
  95 + public void onResourceManagerReload(IResourceManager resourceManager)
  96 + {
  97 + LoadingProgress.setMessage("Reloading Resources...");
  98 + }
  99 +
92 /* (non-Javadoc) 100 /* (non-Javadoc)
93 * @see com.mumfrey.liteloader.api.InterfaceProvider#registerInterfaces(com.mumfrey.liteloader.core.InterfaceRegistrationDelegate) 101 * @see com.mumfrey.liteloader.api.InterfaceProvider#registerInterfaces(com.mumfrey.liteloader.core.InterfaceRegistrationDelegate)
94 */ 102 */
@@ -230,7 +238,7 @@ public class LiteLoaderEventBrokerClient extends LiteLoaderEventBroker&lt;Minecraft @@ -230,7 +238,7 @@ public class LiteLoaderEventBrokerClient extends LiteLoaderEventBroker&lt;Minecraft
230 @Override 238 @Override
231 protected void onStartupComplete() 239 protected void onStartupComplete()
232 { 240 {
233 - this.engine.refreshResources(false); 241 + this.engine.getResources().refreshResources(false);
234 242
235 for (InitCompleteListener initMod : this.initListeners) 243 for (InitCompleteListener initMod : this.initListeners)
236 { 244 {
java/client/com/mumfrey/liteloader/client/ResourceObserver.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.client;
  2 +
  3 +import java.io.File;
  4 +import java.util.HashMap;
  5 +import java.util.Map;
  6 +
  7 +import net.minecraft.client.resources.IResourceManager;
  8 +import net.minecraft.client.resources.IResourcePack;
  9 +
  10 +import com.mumfrey.liteloader.LiteMod;
  11 +import com.mumfrey.liteloader.api.ModLoadObserver;
  12 +import com.mumfrey.liteloader.common.Resources;
  13 +import com.mumfrey.liteloader.core.LiteLoader;
  14 +import com.mumfrey.liteloader.core.ModInfo;
  15 +import com.mumfrey.liteloader.interfaces.LoadableMod;
  16 +import com.mumfrey.liteloader.resources.ModResourcePack;
  17 +import com.mumfrey.liteloader.resources.ModResourcePackDir;
  18 +import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
  19 +
  20 +/**
  21 + * Observer which handles registering mods on the client as resource packs
  22 + *
  23 + * @author Adam Mummery-Smith
  24 + */
  25 +public class ResourceObserver implements ModLoadObserver
  26 +{
  27 + private final Map<String, IResourcePack> resourcePacks = new HashMap<String, IResourcePack>();
  28 +
  29 + public ResourceObserver()
  30 + {
  31 + }
  32 +
  33 + @Override
  34 + public void onModLoaded(LiteMod mod)
  35 + {
  36 + }
  37 +
  38 + @SuppressWarnings("unchecked")
  39 + @Override
  40 + public void onPostModLoaded(ModInfo<LoadableMod<?>> handle)
  41 + {
  42 + if (!handle.hasContainer()) return;
  43 +
  44 + LoadableMod<?> container = handle.getContainer();
  45 + String modName = handle.getMod().getName();
  46 +
  47 + if (modName == null) return;
  48 +
  49 + if (container.hasResources())
  50 + {
  51 + LiteLoaderLogger.info("Adding \"%s\" to active resource pack set", container.getLocation());
  52 + IResourcePack resourcePack = this.initResourcePack(container, modName);
  53 + Resources<IResourceManager, IResourcePack> resources = (Resources<IResourceManager, IResourcePack>)LiteLoader.getGameEngine().getResources();
  54 + if (resources.registerResourcePack(resourcePack))
  55 + {
  56 + LiteLoaderLogger.info("Successfully added \"%s\" to active resource pack set", container.getLocation());
  57 + }
  58 + }
  59 + }
  60 +
  61 + public IResourcePack initResourcePack(LoadableMod<?> container, String name)
  62 + {
  63 + IResourcePack resourcePack = this.getResourcePack(container);
  64 +
  65 + if (resourcePack == null)
  66 + {
  67 + if (container.isDirectory())
  68 + {
  69 + LiteLoaderLogger.info("Setting up \"%s/%s\" as mod resource pack with identifier \"%s\"", container.toFile().getParentFile().getName(), container.getName(), name);
  70 + resourcePack = new ModResourcePackDir(name, container.toFile());
  71 + }
  72 + else
  73 + {
  74 + LiteLoaderLogger.info("Setting up \"%s\" as mod resource pack with identifier \"%s\"", container.getName(), name);
  75 + resourcePack = new ModResourcePack(name, container.toFile());
  76 + }
  77 +
  78 + this.setResourcePack(container, resourcePack);
  79 + }
  80 +
  81 + return resourcePack;
  82 + }
  83 +
  84 + private IResourcePack getResourcePack(LoadableMod<?> container)
  85 + {
  86 + String path = container.getLocation();
  87 + return this.resourcePacks.get(path);
  88 + }
  89 +
  90 + private void setResourcePack(LoadableMod<?> container, IResourcePack resourcePack)
  91 + {
  92 + String path = container.getLocation();
  93 + this.resourcePacks.put(path, resourcePack);
  94 + }
  95 +
  96 + @Override
  97 + public void onModLoadFailed(LoadableMod<?> container, String identifier, String reason, Throwable th)
  98 + {
  99 + }
  100 +
  101 + @Override
  102 + public void onPreInitMod(LiteMod mod)
  103 + {
  104 + }
  105 +
  106 + @Override
  107 + public void onPostInitMod(LiteMod mod)
  108 + {
  109 + }
  110 +
  111 + @Override
  112 + public void onMigrateModConfig(LiteMod mod, File newConfigPath, File oldConfigPath)
  113 + {
  114 + }
  115 +}
java/client/com/mumfrey/liteloader/client/ResourcesClient.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.client;
  2 +
  3 +import java.util.HashMap;
  4 +import java.util.List;
  5 +import java.util.Map;
  6 +
  7 +import net.minecraft.client.Minecraft;
  8 +import net.minecraft.client.resources.IResourceManager;
  9 +import net.minecraft.client.resources.IResourcePack;
  10 +
  11 +import com.mumfrey.liteloader.client.overlays.IMinecraft;
  12 +import com.mumfrey.liteloader.common.LoadingProgress;
  13 +import com.mumfrey.liteloader.common.Resources;
  14 +
  15 +public class ResourcesClient implements Resources<IResourceManager, IResourcePack>
  16 +{
  17 + private final Minecraft engine = Minecraft.getMinecraft();
  18 +
  19 + /**
  20 + * Registered resource packs
  21 + */
  22 + private final Map<String, IResourcePack> registeredResourcePacks = new HashMap<String, IResourcePack>();
  23 +
  24 + /**
  25 + * True while initialising mods if we need to do a resource manager reload once the process is completed
  26 + */
  27 + private boolean pendingResourceReload;
  28 +
  29 + /* (non-Javadoc)
  30 + * @see com.mumfrey.liteloader.common.GameEngine#refreshResources(boolean)
  31 + */
  32 + @Override
  33 + public void refreshResources(boolean force)
  34 + {
  35 + if (this.pendingResourceReload || force)
  36 + {
  37 + LoadingProgress.setMessage("Reloading Resources...");
  38 + this.pendingResourceReload = false;
  39 + this.engine.refreshResources();
  40 + }
  41 + }
  42 +
  43 + /* (non-Javadoc)
  44 + * @see com.mumfrey.liteloader.common.GameEngine#getResourceManager()
  45 + */
  46 + @Override
  47 + public IResourceManager getResourceManager()
  48 + {
  49 + return this.engine.getResourceManager();
  50 + }
  51 +
  52 + /* (non-Javadoc)
  53 + * @see com.mumfrey.liteloader.common.GameEngine#registerResourcePack(net.minecraft.client.resources.IResourcePack)
  54 + */
  55 + @Override
  56 + public boolean registerResourcePack(IResourcePack resourcePack)
  57 + {
  58 + if (!this.registeredResourcePacks.containsKey(resourcePack.getPackName()))
  59 + {
  60 + this.pendingResourceReload = true;
  61 +
  62 + List<IResourcePack> defaultResourcePacks = ((IMinecraft)this.engine).getDefaultResourcePacks();
  63 + if (!defaultResourcePacks.contains(resourcePack))
  64 + {
  65 + defaultResourcePacks.add(resourcePack);
  66 + this.registeredResourcePacks.put(resourcePack.getPackName(), resourcePack);
  67 + return true;
  68 + }
  69 + }
  70 +
  71 + return false;
  72 + }
  73 +
  74 + /* (non-Javadoc)
  75 + * @see com.mumfrey.liteloader.common.GameEngine#unRegisterResourcePack(net.minecraft.client.resources.IResourcePack)
  76 + */
  77 + @Override
  78 + public boolean unRegisterResourcePack(IResourcePack resourcePack)
  79 + {
  80 + if (this.registeredResourcePacks.containsValue(resourcePack))
  81 + {
  82 + this.pendingResourceReload = true;
  83 +
  84 + List<IResourcePack> defaultResourcePacks = ((IMinecraft)this.engine).getDefaultResourcePacks();
  85 + this.registeredResourcePacks.remove(resourcePack.getPackName());
  86 + defaultResourcePacks.remove(resourcePack);
  87 + return true;
  88 + }
  89 +
  90 + return false;
  91 + }
  92 +}
java/client/com/mumfrey/liteloader/client/Translator.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.client;
  2 +
  3 +import net.minecraft.client.resources.I18n;
  4 +
  5 +import com.mumfrey.liteloader.api.TranslationProvider;
  6 +
  7 +public class Translator implements TranslationProvider
  8 +{
  9 + /* (non-Javadoc)
  10 + * @see com.mumfrey.liteloader.api.TranslationProvider#translate(java.lang.String, java.lang.Object[])
  11 + */
  12 + @Override
  13 + public String translate(String key, Object... args)
  14 + {
  15 + // TODO doesn't currently honour the contract of TranslationProvider::translate, should return null if translation is missing
  16 + return I18n.format(key, args);
  17 + }
  18 +
  19 +}
java/client/com/mumfrey/liteloader/client/api/LiteLoaderCoreAPIClient.java
@@ -11,6 +11,8 @@ import com.mumfrey.liteloader.api.CustomisationProvider; @@ -11,6 +11,8 @@ import com.mumfrey.liteloader.api.CustomisationProvider;
11 import com.mumfrey.liteloader.api.InterfaceProvider; 11 import com.mumfrey.liteloader.api.InterfaceProvider;
12 import com.mumfrey.liteloader.api.Observer; 12 import com.mumfrey.liteloader.api.Observer;
13 import com.mumfrey.liteloader.client.LiteLoaderCoreProviderClient; 13 import com.mumfrey.liteloader.client.LiteLoaderCoreProviderClient;
  14 +import com.mumfrey.liteloader.client.ResourceObserver;
  15 +import com.mumfrey.liteloader.client.Translator;
14 import com.mumfrey.liteloader.core.LiteLoader; 16 import com.mumfrey.liteloader.core.LiteLoader;
15 import com.mumfrey.liteloader.core.api.LiteLoaderCoreAPI; 17 import com.mumfrey.liteloader.core.api.LiteLoaderCoreAPI;
16 import com.mumfrey.liteloader.interfaces.ObjectFactory; 18 import com.mumfrey.liteloader.interfaces.ObjectFactory;
@@ -68,7 +70,8 @@ public class LiteLoaderCoreAPIClient extends LiteLoaderCoreAPI @@ -68,7 +70,8 @@ public class LiteLoaderCoreAPIClient extends LiteLoaderCoreAPI
68 return ImmutableList.<CustomisationProvider>of 70 return ImmutableList.<CustomisationProvider>of
69 ( 71 (
70 new LiteLoaderBrandingProvider(), 72 new LiteLoaderBrandingProvider(),
71 - new LiteLoaderModInfoDecorator() 73 + new LiteLoaderModInfoDecorator(),
  74 + new Translator()
72 ); 75 );
73 } 76 }
74 77
@@ -124,6 +127,7 @@ public class LiteLoaderCoreAPIClient extends LiteLoaderCoreAPI @@ -124,6 +127,7 @@ public class LiteLoaderCoreAPIClient extends LiteLoaderCoreAPI
124 { 127 {
125 return ImmutableList.<Observer>of 128 return ImmutableList.<Observer>of
126 ( 129 (
  130 + new ResourceObserver(),
127 this.getObjectFactory().getPanelManager() 131 this.getObjectFactory().getPanelManager()
128 ); 132 );
129 } 133 }
java/client/com/mumfrey/liteloader/client/api/ObjectFactoryClient.java
@@ -22,6 +22,8 @@ import com.mumfrey.liteloader.launch.LoaderEnvironment; @@ -22,6 +22,8 @@ import com.mumfrey.liteloader.launch.LoaderEnvironment;
22 import com.mumfrey.liteloader.launch.LoaderProperties; 22 import com.mumfrey.liteloader.launch.LoaderProperties;
23 import com.mumfrey.liteloader.permissions.PermissionsManagerClient; 23 import com.mumfrey.liteloader.permissions.PermissionsManagerClient;
24 import com.mumfrey.liteloader.permissions.PermissionsManagerServer; 24 import com.mumfrey.liteloader.permissions.PermissionsManagerServer;
  25 +import com.mumfrey.liteloader.util.Input;
  26 +import com.mumfrey.liteloader.util.InputManager;
25 27
26 /** 28 /**
27 * Factory for lifetime loader objects for the client side 29 * Factory for lifetime loader objects for the client side
@@ -34,6 +36,8 @@ class ObjectFactoryClient implements ObjectFactory&lt;Minecraft, IntegratedServer&gt; @@ -34,6 +36,8 @@ class ObjectFactoryClient implements ObjectFactory&lt;Minecraft, IntegratedServer&gt;
34 36
35 private LoaderProperties properties; 37 private LoaderProperties properties;
36 38
  39 + private Input input;
  40 +
37 private LiteLoaderEventBrokerClient clientEvents; 41 private LiteLoaderEventBrokerClient clientEvents;
38 42
39 private PacketEventsClient clientPacketEvents; 43 private PacketEventsClient clientPacketEvents;
@@ -53,6 +57,17 @@ class ObjectFactoryClient implements ObjectFactory&lt;Minecraft, IntegratedServer&gt; @@ -53,6 +57,17 @@ class ObjectFactoryClient implements ObjectFactory&lt;Minecraft, IntegratedServer&gt;
53 } 57 }
54 58
55 @Override 59 @Override
  60 + public Input getInput()
  61 + {
  62 + if (this.input == null)
  63 + {
  64 + this.input = new InputManager(this.environment, this.properties);
  65 + }
  66 +
  67 + return this.input;
  68 + }
  69 +
  70 + @Override
56 public LiteLoaderEventBroker<Minecraft, IntegratedServer> getEventBroker() 71 public LiteLoaderEventBroker<Minecraft, IntegratedServer> getEventBroker()
57 { 72 {
58 if (this.clientEvents == null) 73 if (this.clientEvents == null)
java/client/com/mumfrey/liteloader/client/transformers/LiteLoaderEventInjectionTransformer.java
@@ -3,11 +3,10 @@ package com.mumfrey.liteloader.client.transformers; @@ -3,11 +3,10 @@ package com.mumfrey.liteloader.client.transformers;
3 import static com.mumfrey.liteloader.core.runtime.Methods.*; 3 import static com.mumfrey.liteloader.core.runtime.Methods.*;
4 import static com.mumfrey.liteloader.transformers.event.InjectionPoint.*; 4 import static com.mumfrey.liteloader.transformers.event.InjectionPoint.*;
5 5
  6 +import com.mumfrey.liteloader.common.transformers.LiteLoaderEventTransformer;
6 import com.mumfrey.liteloader.core.runtime.Obf; 7 import com.mumfrey.liteloader.core.runtime.Obf;
7 import com.mumfrey.liteloader.transformers.event.Event; 8 import com.mumfrey.liteloader.transformers.event.Event;
8 -import com.mumfrey.liteloader.transformers.event.EventInjectionTransformer;  
9 import com.mumfrey.liteloader.transformers.event.InjectionPoint; 9 import com.mumfrey.liteloader.transformers.event.InjectionPoint;
10 -import com.mumfrey.liteloader.transformers.event.MethodInfo;  
11 import com.mumfrey.liteloader.transformers.event.inject.BeforeInvoke; 10 import com.mumfrey.liteloader.transformers.event.inject.BeforeInvoke;
12 import com.mumfrey.liteloader.transformers.event.inject.BeforeNew; 11 import com.mumfrey.liteloader.transformers.event.inject.BeforeNew;
13 import com.mumfrey.liteloader.transformers.event.inject.BeforeReturn; 12 import com.mumfrey.liteloader.transformers.event.inject.BeforeReturn;
@@ -19,11 +18,19 @@ import com.mumfrey.liteloader.transformers.event.inject.MethodHead; @@ -19,11 +18,19 @@ import com.mumfrey.liteloader.transformers.event.inject.MethodHead;
19 * 18 *
20 * @author Adam Mummery-Smith 19 * @author Adam Mummery-Smith
21 */ 20 */
22 -public class LiteLoaderEventInjectionTransformer extends EventInjectionTransformer 21 +public class LiteLoaderEventInjectionTransformer extends LiteLoaderEventTransformer
23 { 22 {
24 @Override 23 @Override
  24 + protected Obf getProxy()
  25 + {
  26 + return Obf.CallbackProxyClient;
  27 + }
  28 +
  29 + @Override
25 protected void addEvents() 30 protected void addEvents()
26 { 31 {
  32 + super.addEvents();
  33 +
27 // Event declaraions 34 // Event declaraions
28 Event onOutboundChat = Event.getOrCreate("onOutboundChat", true); 35 Event onOutboundChat = Event.getOrCreate("onOutboundChat", true);
29 Event onResize = Event.getOrCreate("updateFramebufferSize", false); 36 Event onResize = Event.getOrCreate("updateFramebufferSize", false);
@@ -44,11 +51,6 @@ public class LiteLoaderEventInjectionTransformer extends EventInjectionTransform @@ -44,11 +51,6 @@ public class LiteLoaderEventInjectionTransformer extends EventInjectionTransform
44 Event onRenderChat = Event.getOrCreate("onRenderChat", false); 51 Event onRenderChat = Event.getOrCreate("onRenderChat", false);
45 Event postRenderChat = Event.getOrCreate("postRenderChat", false); 52 Event postRenderChat = Event.getOrCreate("postRenderChat", false);
46 Event onCreateIntegratedServer = Event.getOrCreate("onCreateIntegratedServer", false); 53 Event onCreateIntegratedServer = Event.getOrCreate("onCreateIntegratedServer", false);
47 - Event onInitializePlayerConnection = Event.getOrCreate("onInitializePlayerConnection", false);  
48 - Event onPlayerLogin = Event.getOrCreate("onPlayerLogin", false);  
49 - Event onPlayerLogout = Event.getOrCreate("onPlayerLogout", false);  
50 - Event onSpawnPlayer = Event.getOrCreate("onSpawnPlayer", false);  
51 - Event onRespawnPlayer = Event.getOrCreate("onRespawnPlayer", false);  
52 Event onStartupComplete = Event.getOrCreate("onStartupComplete", false); 54 Event onStartupComplete = Event.getOrCreate("onStartupComplete", false);
53 Event onSessionProfileBad = Event.getOrCreate("onSessionProfileBad", true); 55 Event onSessionProfileBad = Event.getOrCreate("onSessionProfileBad", true);
54 Event onSaveScreenshot = Event.getOrCreate("onSaveScreenshot", true); 56 Event onSaveScreenshot = Event.getOrCreate("onSaveScreenshot", true);
@@ -96,11 +98,6 @@ public class LiteLoaderEventInjectionTransformer extends EventInjectionTransform @@ -96,11 +98,6 @@ public class LiteLoaderEventInjectionTransformer extends EventInjectionTransform
96 this.add(onRenderChat, renderGameOverlay, (beforeDrawChat), "onRenderChat"); 98 this.add(onRenderChat, renderGameOverlay, (beforeDrawChat), "onRenderChat");
97 this.add(postRenderChat, renderGameOverlay, after(beforeDrawChat), "postRenderChat"); 99 this.add(postRenderChat, renderGameOverlay, after(beforeDrawChat), "postRenderChat");
98 this.add(onCreateIntegratedServer, integratedServerCtor, (methodReturn), "IntegratedServerCtor"); 100 this.add(onCreateIntegratedServer, integratedServerCtor, (methodReturn), "IntegratedServerCtor");
99 - this.add(onInitializePlayerConnection, initPlayerConnection, (methodReturn), "onInitializePlayerConnection");  
100 - this.add(onPlayerLogin, playerLoggedIn, (methodReturn), "onPlayerLogin");  
101 - this.add(onPlayerLogout, playerLoggedOut, (methodReturn), "onPlayerLogout");  
102 - this.add(onSpawnPlayer, spawnPlayer, (methodReturn), "onSpawnPlayer");  
103 - this.add(onRespawnPlayer, respawnPlayer, (methodReturn), "onRespawnPlayer");  
104 this.add(onStartupComplete, startGame, (methodReturn), "onStartupComplete"); 101 this.add(onStartupComplete, startGame, (methodReturn), "onStartupComplete");
105 this.add(onSaveScreenshot, saveScreenshot, (beforeIsFBOEnabled), "onSaveScreenshot"); 102 this.add(onSaveScreenshot, saveScreenshot, (beforeIsFBOEnabled), "onSaveScreenshot");
106 this.add(onRenderEntity, doRenderEntity, (beforeRenderEntity), "onRenderEntity"); 103 this.add(onRenderEntity, doRenderEntity, (beforeRenderEntity), "onRenderEntity");
@@ -112,14 +109,4 @@ public class LiteLoaderEventInjectionTransformer extends EventInjectionTransform @@ -112,14 +109,4 @@ public class LiteLoaderEventInjectionTransformer extends EventInjectionTransform
112 // Protocol handlers 109 // Protocol handlers
113 this.add(onJoinRealm, realmsPlay, (beforeStopRealsmFetcher), "onJoinRealm", Obf.PacketEventsClient); 110 this.add(onJoinRealm, realmsPlay, (beforeStopRealsmFetcher), "onJoinRealm", Obf.PacketEventsClient);
114 } 111 }
115 -  
116 - protected final Event add(Event event, MethodInfo targetMethod, InjectionPoint injectionPoint, String callback)  
117 - {  
118 - return this.add(event, targetMethod, injectionPoint, callback, Obf.CallbackProxyClient);  
119 - }  
120 -  
121 - private Event add(Event event, MethodInfo targetMethod, InjectionPoint injectionPoint, String callback, Obf proxy)  
122 - {  
123 - return this.addEvent(event, targetMethod, injectionPoint).addListener(new MethodInfo(proxy, callback));  
124 - }  
125 } 112 }
java/common/com/mumfrey/liteloader/resources/InternalResourcePack.java renamed to java/client/com/mumfrey/liteloader/resources/InternalResourcePack.java
java/common/com/mumfrey/liteloader/resources/ModResourcePack.java renamed to java/client/com/mumfrey/liteloader/resources/ModResourcePack.java
java/common/com/mumfrey/liteloader/resources/ModResourcePackDir.java renamed to java/client/com/mumfrey/liteloader/resources/ModResourcePackDir.java
java/client/com/mumfrey/liteloader/util/InputManager.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.util;
  2 +
  3 +import java.io.File;
  4 +import java.io.FileReader;
  5 +import java.io.FileWriter;
  6 +import java.io.IOException;
  7 +import java.util.ArrayList;
  8 +import java.util.HashMap;
  9 +import java.util.HashSet;
  10 +import java.util.List;
  11 +import java.util.Map;
  12 +import java.util.Properties;
  13 +import java.util.Set;
  14 +
  15 +import net.java.games.input.Component;
  16 +import net.java.games.input.Controller;
  17 +import net.java.games.input.Event;
  18 +import net.java.games.input.EventQueue;
  19 +import net.minecraft.client.settings.KeyBinding;
  20 +import net.minecraft.network.INetHandler;
  21 +import net.minecraft.network.play.server.S01PacketJoinGame;
  22 +import net.minecraft.profiler.Profiler;
  23 +import net.minecraft.world.World;
  24 +
  25 +import com.mumfrey.liteloader.common.GameEngine;
  26 +import com.mumfrey.liteloader.core.LiteLoader;
  27 +import com.mumfrey.liteloader.core.LiteLoaderMods;
  28 +import com.mumfrey.liteloader.launch.LoaderEnvironment;
  29 +import com.mumfrey.liteloader.launch.LoaderProperties;
  30 +import com.mumfrey.liteloader.util.Input;
  31 +import com.mumfrey.liteloader.util.InputEvent;
  32 +import com.mumfrey.liteloader.util.InputHandler;
  33 +import com.mumfrey.liteloader.util.jinput.ComponentRegistry;
  34 +
  35 +/**
  36 + * Mod input class, aggregates functionality from LiteLoader's mod key registration functions and JInputLib
  37 + *
  38 + * @author Adam Mummery-Smith
  39 + */
  40 +public final class InputManager implements Input
  41 +{
  42 + private GameEngine<?, ?> engine;
  43 +
  44 + /**
  45 + *
  46 + */
  47 + private Profiler profiler;
  48 +
  49 + /**
  50 + * File in which we will store mod key mappings
  51 + */
  52 + private final File keyMapSettingsFile;
  53 +
  54 + /**
  55 + * Properties object which stores mod key mappings
  56 + */
  57 + private final Properties keyMapSettings = new Properties();
  58 +
  59 + /**
  60 + * List of all registered mod keys
  61 + */
  62 + private final List<KeyBinding> modKeyBindings = new ArrayList<KeyBinding>();
  63 +
  64 + /**
  65 + * Map of mod key bindings to their key codes, stored so that we don't need to cast from
  66 + * string in the properties file every tick
  67 + */
  68 + private final Map<KeyBinding, Integer> storedModKeyBindings = new HashMap<KeyBinding, Integer>();
  69 +
  70 + /**
  71 + * JInput component registry
  72 + */
  73 + private final ComponentRegistry jInputComponentRegistry;
  74 +
  75 + /**
  76 + * List of handlers for JInput components
  77 + */
  78 + private final Map<Component, InputEvent> componentEvents = new HashMap<Component, InputEvent>();
  79 +
  80 + /**
  81 + * JInput Controllers to poll
  82 + */
  83 + private Controller[] pollControllers = new Controller[0];
  84 +
  85 + /**
  86 + *
  87 + */
  88 + public InputManager(LoaderEnvironment environment, LoaderProperties properties)
  89 + {
  90 + if (LiteLoader.getInstance() != null && LiteLoader.getInput() != null)
  91 + {
  92 + throw new IllegalStateException("Only one instance of Input is allowed, use LiteLoader.getInput() to get the active instance");
  93 + }
  94 +
  95 + this.keyMapSettingsFile = new File(environment.getCommonConfigFolder(), "liteloader.keys.properties");
  96 + this.jInputComponentRegistry = new ComponentRegistry();
  97 +
  98 + if (!properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_JINPUT_DISABLE, false))
  99 + {
  100 + this.jInputComponentRegistry.enumerate();
  101 + }
  102 + }
  103 +
  104 + @Override
  105 + public void onInit()
  106 + {
  107 + if (this.keyMapSettingsFile.exists())
  108 + {
  109 + try
  110 + {
  111 + this.keyMapSettings.load(new FileReader(this.keyMapSettingsFile));
  112 + }
  113 + catch (Exception ex) {}
  114 + }
  115 + }
  116 +
  117 + @Override
  118 + public void onPostInit(GameEngine<?, ?> engine)
  119 + {
  120 + this.engine = engine;
  121 + this.profiler = engine.getProfiler();
  122 + }
  123 +
  124 + @Override
  125 + public void onPostInitComplete(LiteLoaderMods mods)
  126 + {
  127 + }
  128 +
  129 + @Override
  130 + public void onStartupComplete()
  131 + {
  132 + }
  133 +
  134 + @Override
  135 + public void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket)
  136 + {
  137 + }
  138 +
  139 + @Override
  140 + public void onWorldChanged(World world)
  141 + {
  142 + }
  143 +
  144 + @Override
  145 + public void onPostRender(int mouseX, int mouseY, float partialTicks)
  146 + {
  147 + }
  148 +
  149 + /**
  150 + * Register a key for a mod
  151 + *
  152 + * @param binding
  153 + */
  154 + @Override
  155 + public void registerKeyBinding(KeyBinding binding)
  156 + {
  157 + List<KeyBinding> keyBindings = this.engine.getKeyBindings();
  158 +
  159 + if (!keyBindings.contains(binding))
  160 + {
  161 + if (this.keyMapSettings.containsKey(binding.getKeyDescription()))
  162 + {
  163 + try
  164 + {
  165 + binding.setKeyCode(Integer.parseInt(this.keyMapSettings.getProperty(binding.getKeyDescription(), String.valueOf(binding.getKeyCode()))));
  166 + }
  167 + catch (NumberFormatException ex) {}
  168 + }
  169 +
  170 + keyBindings.add(binding);
  171 +
  172 + this.engine.setKeyBindings(keyBindings);
  173 + this.modKeyBindings.add(binding);
  174 +
  175 + this.updateBinding(binding);
  176 + this.storeBindings();
  177 +
  178 + KeyBinding.resetKeyBindingArrayAndHash();
  179 + }
  180 + }
  181 +
  182 + /**
  183 + * Unregisters a registered keybind with the game settings class, thus removing it from the "controls" screen
  184 + *
  185 + * @param binding
  186 + */
  187 + @Override
  188 + public void unRegisterKeyBinding(KeyBinding binding)
  189 + {
  190 + List<KeyBinding> keyBindings = this.engine.getKeyBindings();
  191 +
  192 + if (keyBindings.contains(binding))
  193 + {
  194 + keyBindings.remove(binding);
  195 + this.engine.setKeyBindings(keyBindings);
  196 +
  197 + this.modKeyBindings.remove(binding);
  198 +
  199 + KeyBinding.resetKeyBindingArrayAndHash();
  200 + }
  201 + }
  202 +
  203 + /**
  204 + * Checks for changed mod keybindings and stores any that have changed
  205 + */
  206 + @Override
  207 + public void onTick(boolean clock, float partialTicks, boolean inGame)
  208 + {
  209 + this.profiler.startSection("keybindings");
  210 + if (clock)
  211 + {
  212 + boolean updated = false;
  213 +
  214 + for (KeyBinding binding : this.modKeyBindings)
  215 + {
  216 + if (binding.getKeyCode() != this.storedModKeyBindings.get(binding))
  217 + {
  218 + this.updateBinding(binding);
  219 + updated = true;
  220 + }
  221 + }
  222 +
  223 + if (updated) this.storeBindings();
  224 + }
  225 +
  226 + this.pollControllers();
  227 + this.profiler.endSection();
  228 + }
  229 +
  230 + /**
  231 + * @param binding
  232 + */
  233 + private void updateBinding(KeyBinding binding)
  234 + {
  235 + this.keyMapSettings.setProperty(binding.getKeyDescription(), String.valueOf(binding.getKeyCode()));
  236 + this.storedModKeyBindings.put(binding, Integer.valueOf(binding.getKeyCode()));
  237 + }
  238 +
  239 + @Override
  240 + public void onShutDown()
  241 + {
  242 + this.storeBindings();
  243 + }
  244 +
  245 + /**
  246 + * Writes mod bindings to disk
  247 + */
  248 + @Override
  249 + public void storeBindings()
  250 + {
  251 + try
  252 + {
  253 + this.keyMapSettings.store(new FileWriter(this.keyMapSettingsFile), "Mod key mappings for LiteLoader mods, stored here to avoid losing settings stored in options.txt");
  254 + }
  255 + catch (IOException ex) {}
  256 + }
  257 +
  258 + /**
  259 + * Gets the underlying JInput component registry
  260 + */
  261 + @Override
  262 + public ComponentRegistry getComponentRegistry()
  263 + {
  264 + return this.jInputComponentRegistry;
  265 + }
  266 +
  267 + /**
  268 + * Returns a handle to the event described by descriptor (or null if no component is found matching the
  269 + * descriptor. Retrieving an event via this method adds the controller (if found) to the polling list and
  270 + * causes it to raise events against the specified handler.
  271 + *
  272 + * This method returns an {@link InputEvent} which is passed as an argument to the relevant callback on
  273 + * the supplied handler in order to identify the event. For example:
  274 + *
  275 + * this.joystickButton = input.getEvent(descriptor, this);
  276 + *
  277 + * then in onAxisEvent
  278 + *
  279 + * if (source == this.joystickButton) // do something with button
  280 + *
  281 + * @param descriptor
  282 + * @param handler
  283 + */
  284 + @Override
  285 + public InputEvent getEvent(String descriptor, InputHandler handler)
  286 + {
  287 + if (handler == null) return null;
  288 + Component component = this.jInputComponentRegistry.getComponent(descriptor);
  289 + Controller controller = this.jInputComponentRegistry.getController(descriptor);
  290 + return this.addEventHandler(controller, component, handler);
  291 + }
  292 +
  293 + /**
  294 + * Get events for all components which match the supplied descriptor
  295 + *
  296 + * @param descriptor
  297 + * @param handler
  298 + */
  299 + @Override
  300 + public InputEvent[] getEvents(String descriptor, InputHandler handler)
  301 + {
  302 + List<InputEvent> events = new ArrayList<InputEvent>();
  303 + Controller controller = this.jInputComponentRegistry.getController(descriptor);
  304 + if (controller != null)
  305 + {
  306 + for (Component component : controller.getComponents())
  307 + {
  308 + events.add(this.addEventHandler(controller, component, handler));
  309 + }
  310 + }
  311 +
  312 + return events.toArray(new InputEvent[0]);
  313 + }
  314 +
  315 + /**
  316 + * @param controller
  317 + * @param component
  318 + * @param handler
  319 + */
  320 + private InputEvent addEventHandler(Controller controller, Component component, InputHandler handler)
  321 + {
  322 + if (controller != null && component != null && handler != null)
  323 + {
  324 + this.addController(controller);
  325 +
  326 + InputEvent event = new InputEvent(controller, component, handler);
  327 + this.componentEvents.put(component, event.link(this.componentEvents.get(component)));
  328 +
  329 + return event;
  330 + }
  331 +
  332 + return null;
  333 + }
  334 +
  335 + /**
  336 + * @param controller
  337 + */
  338 + private void addController(Controller controller)
  339 + {
  340 + Set<Controller> controllers = this.getActiveControllers();
  341 + controllers.add(controller);
  342 + this.setActiveControllers(controllers);
  343 + }
  344 +
  345 + /**
  346 + *
  347 + */
  348 + private Set<Controller> getActiveControllers()
  349 + {
  350 + Set<Controller> allControllers = new HashSet<Controller>();
  351 + for (Controller controller : this.pollControllers)
  352 + allControllers.add(controller);
  353 + return allControllers;
  354 + }
  355 +
  356 + /**
  357 + * @param controllers
  358 + */
  359 + private void setActiveControllers(Set<Controller> controllers)
  360 + {
  361 + this.pollControllers = controllers.toArray(new Controller[controllers.size()]);
  362 + }
  363 +
  364 + /**
  365 + *
  366 + */
  367 + private void pollControllers()
  368 + {
  369 + for (Controller controller : this.pollControllers)
  370 + {
  371 + controller.poll();
  372 + EventQueue controllerQueue = controller.getEventQueue();
  373 +
  374 + for (Event event = new Event(); controllerQueue.getNextEvent(event); )
  375 + {
  376 + Component cmp = event.getComponent();
  377 +
  378 + InputEvent inputEvent = this.componentEvents.get(cmp);
  379 + if (inputEvent != null)
  380 + {
  381 + inputEvent.onEvent(event);
  382 + }
  383 + }
  384 + }
  385 + }
  386 +}
java/common/com/mumfrey/liteloader/api/EnumerationObserver.java
@@ -47,7 +47,7 @@ public interface EnumerationObserver extends Observer @@ -47,7 +47,7 @@ public interface EnumerationObserver extends Observer
47 /** 47 /**
48 * Called when a mod container is added to the pending mods list. This does not mean that the specific mod will actually be instanced since 48 * Called when a mod container is added to the pending mods list. This does not mean that the specific mod will actually be instanced since
49 * the mod can still be disabled via the exclusion list (this is to allow entire containers to be disabled or just individual mods) and so 49 * the mod can still be disabled via the exclusion list (this is to allow entire containers to be disabled or just individual mods) and so
50 - * if you wish to observe actual mod instantiation you should still provide a {@link ModLoadObserver}. However this event expresses a 50 + * if you wish to observe actual mod instantiation you should still provide a {@link ResourceObserver}. However this event expresses a
51 * declaration by the enumerator of an intention to load the specified mod. 51 * declaration by the enumerator of an intention to load the specified mod.
52 * 52 *
53 * @param enumerator 53 * @param enumerator
java/common/com/mumfrey/liteloader/api/ModLoadObserver.java
@@ -3,6 +3,7 @@ package com.mumfrey.liteloader.api; @@ -3,6 +3,7 @@ package com.mumfrey.liteloader.api;
3 import java.io.File; 3 import java.io.File;
4 4
5 import com.mumfrey.liteloader.LiteMod; 5 import com.mumfrey.liteloader.LiteMod;
  6 +import com.mumfrey.liteloader.core.ModInfo;
6 import com.mumfrey.liteloader.interfaces.LoadableMod; 7 import com.mumfrey.liteloader.interfaces.LoadableMod;
7 8
8 /** 9 /**
@@ -22,6 +23,13 @@ public interface ModLoadObserver extends Observer @@ -22,6 +23,13 @@ public interface ModLoadObserver extends Observer
22 public abstract void onModLoaded(LiteMod mod); 23 public abstract void onModLoaded(LiteMod mod);
23 24
24 /** 25 /**
  26 + * Called after a mod is instanced and has been successfully added to the active mods list
  27 + *
  28 + * @param handle Mod handle
  29 + */
  30 + public abstract void onPostModLoaded(ModInfo<LoadableMod<?>> handle);
  31 +
  32 + /**
25 * Called if mod loading fails 33 * Called if mod loading fails
26 * 34 *
27 * @param container 35 * @param container
java/common/com/mumfrey/liteloader/api/TranslationProvider.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.api;
  2 +
  3 +/**
  4 + * Interface for providers which can handle translation requests
  5 + *
  6 + * @author Adam Mummery-Smith
  7 + */
  8 +public interface TranslationProvider extends CustomisationProvider
  9 +{
  10 + /**
  11 + * Translate the supplied key or return NULL if the provider has no translation for the specified key
  12 + */
  13 + public abstract String translate(String key, Object... args);
  14 +}
java/common/com/mumfrey/liteloader/common/GameEngine.java
@@ -2,8 +2,6 @@ package com.mumfrey.liteloader.common; @@ -2,8 +2,6 @@ package com.mumfrey.liteloader.common;
2 2
3 import java.util.List; 3 import java.util.List;
4 4
5 -import net.minecraft.client.resources.IResourceManager;  
6 -import net.minecraft.client.resources.IResourcePack;  
7 import net.minecraft.client.settings.KeyBinding; 5 import net.minecraft.client.settings.KeyBinding;
8 import net.minecraft.profiler.Profiler; 6 import net.minecraft.profiler.Profiler;
9 import net.minecraft.server.MinecraftServer; 7 import net.minecraft.server.MinecraftServer;
@@ -50,33 +48,16 @@ public interface GameEngine&lt;TClient, TServer extends MinecraftServer&gt; @@ -50,33 +48,16 @@ public interface GameEngine&lt;TClient, TServer extends MinecraftServer&gt;
50 * Get the underlying server instance 48 * Get the underlying server instance
51 */ 49 */
52 public abstract TServer getServer(); 50 public abstract TServer getServer();
53 -  
54 - /**  
55 - * Get the profiler instance  
56 - */  
57 - public abstract Profiler getProfiler();  
58 -  
59 - /**  
60 - * Get the resource manager for the current environment, returns the SimpleReloadableResourceManager on client and ModResourceManager on the server  
61 - */  
62 - public abstract IResourceManager getResourceManager();  
63 -  
64 - /**  
65 - * @param resourcePack  
66 - */  
67 - public abstract boolean registerResourcePack(IResourcePack resourcePack);  
68 - 51 +
69 /** 52 /**
70 - * @param resourcePack 53 + * @return
71 */ 54 */
72 - public abstract boolean unRegisterResourcePack(IResourcePack resourcePack); 55 + public abstract Resources<?, ?> getResources();
73 56
74 /** 57 /**
75 - * Refresh resource pack list  
76 - *  
77 - * @param force 58 + * Get the profiler instance
78 */ 59 */
79 - public abstract void refreshResources(boolean force); 60 + public abstract Profiler getProfiler();
80 61
81 /** 62 /**
82 * Get the keybinding list, only supported on client will throw an exception on the server 63 * Get the keybinding list, only supported on client will throw an exception on the server
java/common/com/mumfrey/liteloader/common/Resources.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.common;
  2 +
  3 +public interface Resources<TResourceManager, TResourcePack>
  4 +{
  5 + /**
  6 + * Refresh resource pack list
  7 + *
  8 + * @param force
  9 + */
  10 + public abstract void refreshResources(boolean force);
  11 +
  12 + /**
  13 + * Get the resource manager for the current environment, returns the SimpleReloadableResourceManager on client and ModResourceManager on the server
  14 + */
  15 + public abstract TResourceManager getResourceManager();
  16 +
  17 + /**
  18 + * @param resourcePack
  19 + */
  20 + public abstract boolean registerResourcePack(TResourcePack resourcePack);
  21 +
  22 + /**
  23 + * @param resourcePack
  24 + */
  25 + public abstract boolean unRegisterResourcePack(TResourcePack resourcePack);
  26 +}
java/common/com/mumfrey/liteloader/common/transformers/LiteLoaderEventTransformer.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.common.transformers;
  2 +
  3 +import static com.mumfrey.liteloader.core.runtime.Methods.*;
  4 +
  5 +import com.mumfrey.liteloader.core.runtime.Obf;
  6 +import com.mumfrey.liteloader.transformers.event.Event;
  7 +import com.mumfrey.liteloader.transformers.event.EventInjectionTransformer;
  8 +import com.mumfrey.liteloader.transformers.event.InjectionPoint;
  9 +import com.mumfrey.liteloader.transformers.event.MethodInfo;
  10 +import com.mumfrey.liteloader.transformers.event.inject.BeforeNew;
  11 +import com.mumfrey.liteloader.transformers.event.inject.BeforeReturn;
  12 +
  13 +/**
  14 + * Injector for LiteLoader's common events
  15 + *
  16 + * @author Adam Mummery-Smith
  17 + */
  18 +public abstract class LiteLoaderEventTransformer extends EventInjectionTransformer
  19 +{
  20 + protected abstract Obf getProxy();
  21 +
  22 + @Override
  23 + protected void addEvents()
  24 + {
  25 + // Event declaraions
  26 + Event onInitializePlayerConnection = Event.getOrCreate("onInitializePlayerConnection", false);
  27 + Event onPlayerLogin = Event.getOrCreate("onPlayerLogin", false);
  28 + Event onPlayerLogout = Event.getOrCreate("onPlayerLogout", false);
  29 + Event onSpawnPlayer = Event.getOrCreate("onSpawnPlayer", false);
  30 + Event onRespawnPlayer = Event.getOrCreate("onRespawnPlayer", false);
  31 + Event onSessionProfileBad = Event.getOrCreate("onSessionProfileBad", true);
  32 +
  33 + // Injection Points
  34 + InjectionPoint methodReturn = new BeforeReturn();
  35 + InjectionPoint beforeNewGameProfile = new BeforeNew(1, Obf.GameProfile);
  36 +
  37 + // Hooks
  38 + this.add(onInitializePlayerConnection, initPlayerConnection, (methodReturn), "onInitializePlayerConnection");
  39 + this.add(onPlayerLogin, playerLoggedIn, (methodReturn), "onPlayerLogin");
  40 + this.add(onPlayerLogout, playerLoggedOut, (methodReturn), "onPlayerLogout");
  41 + this.add(onSpawnPlayer, spawnPlayer, (methodReturn), "onSpawnPlayer");
  42 + this.add(onRespawnPlayer, respawnPlayer, (methodReturn), "onRespawnPlayer");
  43 +
  44 + // Compatibility handlers
  45 + this.add(onSessionProfileBad, getProfile, (beforeNewGameProfile), "generateOfflineUUID");
  46 + }
  47 +
  48 + protected final Event add(Event event, MethodInfo targetMethod, InjectionPoint injectionPoint, String callback)
  49 + {
  50 + return this.add(event, targetMethod, injectionPoint, callback, this.getProxy());
  51 + }
  52 +
  53 + protected Event add(Event event, MethodInfo targetMethod, InjectionPoint injectionPoint, String callback, Obf proxy)
  54 + {
  55 + return this.addEvent(event, targetMethod, injectionPoint).addListener(new MethodInfo(proxy, callback));
  56 + }
  57 +}
java/common/com/mumfrey/liteloader/core/LiteLoader.java
@@ -19,11 +19,13 @@ import net.minecraft.world.World; @@ -19,11 +19,13 @@ import net.minecraft.world.World;
19 import com.mumfrey.liteloader.LiteMod; 19 import com.mumfrey.liteloader.LiteMod;
20 import com.mumfrey.liteloader.api.CoreProvider; 20 import com.mumfrey.liteloader.api.CoreProvider;
21 import com.mumfrey.liteloader.api.CustomisationProvider; 21 import com.mumfrey.liteloader.api.CustomisationProvider;
  22 +import com.mumfrey.liteloader.api.Listener;
22 import com.mumfrey.liteloader.api.LiteAPI; 23 import com.mumfrey.liteloader.api.LiteAPI;
23 import com.mumfrey.liteloader.api.ModLoadObserver; 24 import com.mumfrey.liteloader.api.ModLoadObserver;
24 import com.mumfrey.liteloader.api.PostRenderObserver; 25 import com.mumfrey.liteloader.api.PostRenderObserver;
25 import com.mumfrey.liteloader.api.ShutdownObserver; 26 import com.mumfrey.liteloader.api.ShutdownObserver;
26 import com.mumfrey.liteloader.api.TickObserver; 27 import com.mumfrey.liteloader.api.TickObserver;
  28 +import com.mumfrey.liteloader.api.TranslationProvider;
27 import com.mumfrey.liteloader.api.WorldObserver; 29 import com.mumfrey.liteloader.api.WorldObserver;
28 import com.mumfrey.liteloader.api.manager.APIAdapter; 30 import com.mumfrey.liteloader.api.manager.APIAdapter;
29 import com.mumfrey.liteloader.api.manager.APIProvider; 31 import com.mumfrey.liteloader.api.manager.APIProvider;
@@ -178,6 +180,11 @@ public final class LiteLoader @@ -178,6 +180,11 @@ public final class LiteLoader
178 private Input input; 180 private Input input;
179 181
180 /** 182 /**
  183 + *
  184 + */
  185 + private final List<TranslationProvider> translators = new ArrayList<TranslationProvider>();
  186 +
  187 + /**
181 * ctor 188 * ctor
182 * 189 *
183 * @param environment 190 * @param environment
@@ -190,7 +197,6 @@ public final class LiteLoader @@ -190,7 +197,6 @@ public final class LiteLoader
190 this.enumerator = environment.getEnumerator(); 197 this.enumerator = environment.getEnumerator();
191 198
192 this.configManager = new ConfigManager(); 199 this.configManager = new ConfigManager();
193 - this.input = new Input(environment, properties);  
194 200
195 this.mods = new LiteLoaderMods(this, environment, properties, this.configManager); 201 this.mods = new LiteLoaderMods(this, environment, properties, this.configManager);
196 202
@@ -205,11 +211,36 @@ public final class LiteLoader @@ -205,11 +211,36 @@ public final class LiteLoader
205 211
206 this.objectFactory = this.api.getObjectFactory(); 212 this.objectFactory = this.api.getObjectFactory();
207 213
  214 + this.input = this.objectFactory.getInput();
  215 +
208 this.clientPluginChannels = this.objectFactory.getClientPluginChannels(); 216 this.clientPluginChannels = this.objectFactory.getClientPluginChannels();
209 this.serverPluginChannels = this.objectFactory.getServerPluginChannels(); 217 this.serverPluginChannels = this.objectFactory.getServerPluginChannels();
210 218
211 this.permissionsManagerClient = this.objectFactory.getClientPermissionManager(); 219 this.permissionsManagerClient = this.objectFactory.getClientPermissionManager();
212 this.permissionsManagerServer = this.objectFactory.getServerPermissionManager(); 220 this.permissionsManagerServer = this.objectFactory.getServerPermissionManager();
  221 +
  222 + this.initTranslators();
  223 + }
  224 +
  225 + /**
  226 + *
  227 + */
  228 + protected void initTranslators()
  229 + {
  230 + for (LiteAPI api : this.apiProvider.getAPIs())
  231 + {
  232 + List<CustomisationProvider> customisationProviders = api.getCustomisationProviders();
  233 + if (customisationProviders != null)
  234 + {
  235 + for (CustomisationProvider provider : customisationProviders)
  236 + {
  237 + if (provider instanceof TranslationProvider)
  238 + {
  239 + this.translators.add((TranslationProvider)provider);
  240 + }
  241 + }
  242 + }
  243 + }
213 } 244 }
214 245
215 /** 246 /**
@@ -772,6 +803,14 @@ public final class LiteLoader @@ -772,6 +803,14 @@ public final class LiteLoader
772 this.coreProviders.all().onPostInit(this.engine); 803 this.coreProviders.all().onPostInit(this.engine);
773 804
774 this.interfaceManager.registerInterfaces(); 805 this.interfaceManager.registerInterfaces();
  806 +
  807 + for (CoreProvider provider : this.coreProviders)
  808 + {
  809 + if (provider instanceof Listener)
  810 + {
  811 + this.interfaceManager.registerListener((Listener)provider);
  812 + }
  813 + }
775 } 814 }
776 815
777 private void loadAndInitMods() 816 private void loadAndInitMods()
@@ -906,6 +945,20 @@ public final class LiteLoader @@ -906,6 +945,20 @@ public final class LiteLoader
906 945
907 this.configManager.syncConfig(); 946 this.configManager.syncConfig();
908 } 947 }
  948 +
  949 + public static String translate(String key, Object... args)
  950 + {
  951 + for (TranslationProvider translator : LiteLoader.instance.translators)
  952 + {
  953 + String translated = translator.translate(key, args);
  954 + if (translated != null)
  955 + {
  956 + return translated;
  957 + }
  958 + }
  959 +
  960 + return key;
  961 + }
909 962
910 /** 963 /**
911 * @param objCrashReport This is an object so that we don't need to transform the obfuscated name in the transformer 964 * @param objCrashReport This is an object so that we don't need to transform the obfuscated name in the transformer
java/common/com/mumfrey/liteloader/core/LiteLoaderEventBroker.java
1 package com.mumfrey.liteloader.core; 1 package com.mumfrey.liteloader.core;
2 2
3 -import net.minecraft.client.resources.IResourceManager;  
4 -import net.minecraft.client.resources.IResourceManagerReloadListener;  
5 import net.minecraft.command.ICommandManager; 3 import net.minecraft.command.ICommandManager;
6 import net.minecraft.command.ServerCommandManager; 4 import net.minecraft.command.ServerCommandManager;
7 import net.minecraft.entity.player.EntityPlayerMP; 5 import net.minecraft.entity.player.EntityPlayerMP;
@@ -33,7 +31,7 @@ import com.mumfrey.liteloader.util.log.LiteLoaderLogger; @@ -33,7 +31,7 @@ import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
33 * @param <TClient> Type of the client runtime, "Minecraft" on client and null on the server 31 * @param <TClient> Type of the client runtime, "Minecraft" on client and null on the server
34 * @param <TServer> Type of the server runtime, "IntegratedServer" on the client, "MinecraftServer" on the server 32 * @param <TServer> Type of the server runtime, "IntegratedServer" on the client, "MinecraftServer" on the server
35 */ 33 */
36 -public abstract class LiteLoaderEventBroker<TClient, TServer extends MinecraftServer> implements InterfaceProvider, IResourceManagerReloadListener 34 +public abstract class LiteLoaderEventBroker<TClient, TServer extends MinecraftServer> implements InterfaceProvider
37 { 35 {
38 /** 36 /**
39 * @author Adam Mummery-Smith 37 * @author Adam Mummery-Smith
@@ -182,12 +180,6 @@ public abstract class LiteLoaderEventBroker&lt;TClient, TServer extends MinecraftSe @@ -182,12 +180,6 @@ public abstract class LiteLoaderEventBroker&lt;TClient, TServer extends MinecraftSe
182 { 180 {
183 this.serverPlayerListeners.add(serverPlayerListener); 181 this.serverPlayerListeners.add(serverPlayerListener);
184 } 182 }
185 -  
186 - @Override  
187 - public void onResourceManagerReload(IResourceManager resourceManager)  
188 - {  
189 - LoadingProgress.setMessage("Reloading Resources...");  
190 - }  
191 183
192 /** 184 /**
193 * @param instance 185 * @param instance
java/common/com/mumfrey/liteloader/core/LiteLoaderMods.java
@@ -9,8 +9,6 @@ import java.util.List; @@ -9,8 +9,6 @@ import java.util.List;
9 import java.util.Map; 9 import java.util.Map;
10 import java.util.Set; 10 import java.util.Set;
11 11
12 -import net.minecraft.client.resources.IResourcePack;  
13 -  
14 import com.mumfrey.liteloader.LiteMod; 12 import com.mumfrey.liteloader.LiteMod;
15 import com.mumfrey.liteloader.api.ModLoadObserver; 13 import com.mumfrey.liteloader.api.ModLoadObserver;
16 import com.mumfrey.liteloader.common.LoadingProgress; 14 import com.mumfrey.liteloader.common.LoadingProgress;
@@ -455,6 +453,8 @@ public class LiteLoaderMods @@ -455,6 +453,8 @@ public class LiteLoaderMods
455 this.onModLoadFailed(container, mod.getModClassName(), "an error occurred", th); 453 this.onModLoadFailed(container, mod.getModClassName(), "an error occurred", th);
456 this.registerModStartupError(mod, th); 454 this.registerModStartupError(mod, th);
457 } 455 }
  456 +
  457 + this.observers.all().onPostModLoaded(mod);
458 } 458 }
459 } 459 }
460 460
@@ -486,22 +486,6 @@ public class LiteLoaderMods @@ -486,22 +486,6 @@ public class LiteLoaderMods
486 486
487 String modName = mod.getDisplayName(); 487 String modName = mod.getDisplayName();
488 LiteLoaderLogger.info("Successfully added mod %s version %s", modName, newMod.getVersion()); 488 LiteLoaderLogger.info("Successfully added mod %s version %s", modName, newMod.getVersion());
489 -  
490 - // Register the mod as a resource pack if the container exists  
491 - if (mod.hasContainer())  
492 - {  
493 - LoadableMod<?> container = mod.getContainer();  
494 - LiteLoaderLogger.info("Adding \"%s\" to active resource pack set", container.getLocation());  
495 - if (modName != null)  
496 - {  
497 - container.initResourcePack(modName);  
498 -  
499 - if (container.hasResourcePack() && LiteLoader.getGameEngine().registerResourcePack((IResourcePack)container.getResourcePack()))  
500 - {  
501 - LiteLoaderLogger.info("Successfully added \"%s\" to active resource pack set", container.getLocation());  
502 - }  
503 - }  
504 - }  
505 } 489 }
506 490
507 /** 491 /**
java/common/com/mumfrey/liteloader/core/api/LoadableModClassPath.java
@@ -6,9 +6,6 @@ import java.net.MalformedURLException; @@ -6,9 +6,6 @@ import java.net.MalformedURLException;
6 import net.minecraft.launchwrapper.LaunchClassLoader; 6 import net.minecraft.launchwrapper.LaunchClassLoader;
7 7
8 import com.mumfrey.liteloader.core.LiteLoaderVersion; 8 import com.mumfrey.liteloader.core.LiteLoaderVersion;
9 -import com.mumfrey.liteloader.resources.ModResourcePack;  
10 -import com.mumfrey.liteloader.resources.ModResourcePackDir;  
11 -import com.mumfrey.liteloader.util.log.LiteLoaderLogger;  
12 9
13 /** 10 /**
14 * Mod file reference for a file loaded from class path 11 * Mod file reference for a file loaded from class path
@@ -67,24 +64,6 @@ public class LoadableModClassPath extends LoadableModFile @@ -67,24 +64,6 @@ public class LoadableModClassPath extends LoadableModFile
67 { 64 {
68 return this.getModName(); 65 return this.getModName();
69 } 66 }
70 -  
71 - @Override  
72 - public void initResourcePack(String name)  
73 - {  
74 - if (this.resourcePack == null)  
75 - {  
76 - if (this.isDirectory())  
77 - {  
78 - LiteLoaderLogger.info("Setting up \"%s/%s\" as mod resource pack with identifier \"%s\"", this.getParentFile().getName(), this.getName(), name);  
79 - this.resourcePack = new ModResourcePackDir(name, this);  
80 - }  
81 - else  
82 - {  
83 - LiteLoaderLogger.info("Setting up \"%s\" as mod resource pack with identifier \"%s\"", this.getName(), name);  
84 - this.resourcePack = new ModResourcePack(name, this);  
85 - }  
86 - }  
87 - }  
88 67
89 @Override 68 @Override
90 public boolean injectIntoClassPath(LaunchClassLoader classLoader, boolean injectIntoParent) throws MalformedURLException 69 public boolean injectIntoClassPath(LaunchClassLoader classLoader, boolean injectIntoParent) throws MalformedURLException
java/common/com/mumfrey/liteloader/core/api/LoadableModFile.java
@@ -18,18 +18,17 @@ import java.util.zip.ZipEntry; @@ -18,18 +18,17 @@ import java.util.zip.ZipEntry;
18 import java.util.zip.ZipFile; 18 import java.util.zip.ZipFile;
19 19
20 import joptsimple.internal.Strings; 20 import joptsimple.internal.Strings;
21 -import net.minecraft.client.resources.I18n;  
22 21
23 import com.google.common.base.Charsets; 22 import com.google.common.base.Charsets;
24 import com.google.common.io.ByteStreams; 23 import com.google.common.io.ByteStreams;
25 import com.google.gson.Gson; 24 import com.google.gson.Gson;
26 import com.google.gson.JsonSyntaxException; 25 import com.google.gson.JsonSyntaxException;
27 import com.mumfrey.liteloader.api.manager.APIProvider; 26 import com.mumfrey.liteloader.api.manager.APIProvider;
  27 +import com.mumfrey.liteloader.core.LiteLoader;
28 import com.mumfrey.liteloader.interfaces.LoadableFile; 28 import com.mumfrey.liteloader.interfaces.LoadableFile;
29 import com.mumfrey.liteloader.interfaces.LoadableMod; 29 import com.mumfrey.liteloader.interfaces.LoadableMod;
30 import com.mumfrey.liteloader.launch.InjectionStrategy; 30 import com.mumfrey.liteloader.launch.InjectionStrategy;
31 import com.mumfrey.liteloader.launch.LoaderEnvironment; 31 import com.mumfrey.liteloader.launch.LoaderEnvironment;
32 -import com.mumfrey.liteloader.resources.ModResourcePack;  
33 import com.mumfrey.liteloader.util.log.LiteLoaderLogger; 32 import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
34 33
35 /** 34 /**
@@ -89,11 +88,6 @@ public class LoadableModFile extends LoadableFile implements LoadableMod&lt;File&gt; @@ -89,11 +88,6 @@ public class LoadableModFile extends LoadableFile implements LoadableMod&lt;File&gt;
89 protected boolean hasRevision = false; 88 protected boolean hasRevision = false;
90 89
91 /** 90 /**
92 - * Resource pack we have registered with minecraft  
93 - */  
94 - protected Object resourcePack = null;  
95 -  
96 - /**  
97 * ALL of the parsed metadata from the file, associated with the mod later on for retrieval via the loader 91 * ALL of the parsed metadata from the file, associated with the mod later on for retrieval via the loader
98 */ 92 */
99 protected Map<String, Object> metaData = new HashMap<String, Object>(); 93 protected Map<String, Object> metaData = new HashMap<String, Object>();
@@ -241,12 +235,12 @@ public class LoadableModFile extends LoadableFile implements LoadableMod&lt;File&gt; @@ -241,12 +235,12 @@ public class LoadableModFile extends LoadableFile implements LoadableMod&lt;File&gt;
241 { 235 {
242 if (this.missingAPIs.size() > 0) 236 if (this.missingAPIs.size() > 0)
243 { 237 {
244 - return I18n.format("gui.description.missingapis", "\n" + compileMissingAPIList()); 238 + return LiteLoader.translate("gui.description.missingapis", "\n" + compileMissingAPIList());
245 } 239 }
246 240
247 if (this.missingDependencies.size() > 0) 241 if (this.missingDependencies.size() > 0)
248 { 242 {
249 - return I18n.format("gui.description.missingdeps", "\n" + this.missingDependencies.toString()); 243 + return LiteLoader.translate("gui.description.missingdeps", "\n" + this.missingDependencies.toString());
250 } 244 }
251 245
252 String descriptionKey = "description"; 246 String descriptionKey = "description";
@@ -374,33 +368,11 @@ public class LoadableModFile extends LoadableFile implements LoadableMod&lt;File&gt; @@ -374,33 +368,11 @@ public class LoadableModFile extends LoadableFile implements LoadableMod&lt;File&gt;
374 { 368 {
375 return this.classTransformerClassNames; 369 return this.classTransformerClassNames;
376 } 370 }
377 -  
378 - @Override  
379 - @SuppressWarnings("unchecked")  
380 - public <T> T getResourcePack()  
381 - {  
382 - return (T)this.resourcePack;  
383 - }  
384 -  
385 - /**  
386 - * Initialise the mod resource pack  
387 - *  
388 - * @param name  
389 - */  
390 - @Override  
391 - public void initResourcePack(String name)  
392 - {  
393 - if (this.resourcePack == null)  
394 - {  
395 - LiteLoaderLogger.info("Setting up \"%s\" as mod resource pack with identifier \"%s\"", this.getName(), name);  
396 - this.resourcePack = new ModResourcePack(name, this);  
397 - }  
398 - }  
399 371
400 @Override 372 @Override
401 - public boolean hasResourcePack() 373 + public boolean hasResources()
402 { 374 {
403 - return (this.resourcePack != null); 375 + return true;
404 } 376 }
405 377
406 @Override 378 @Override
java/common/com/mumfrey/liteloader/core/runtime/Methods.java
@@ -13,6 +13,7 @@ import com.mumfrey.liteloader.transformers.event.MethodInfo; @@ -13,6 +13,7 @@ import com.mumfrey.liteloader.transformers.event.MethodInfo;
13 */ 13 */
14 public abstract class Methods 14 public abstract class Methods
15 { 15 {
  16 + // Client & General
16 public static final MethodInfo startGame = new MethodInfo(Obf.Minecraft, Obf.startGame, Void.TYPE); 17 public static final MethodInfo startGame = new MethodInfo(Obf.Minecraft, Obf.startGame, Void.TYPE);
17 public static final MethodInfo runGameLoop = new MethodInfo(Obf.Minecraft, Obf.runGameLoop, Void.TYPE); 18 public static final MethodInfo runGameLoop = new MethodInfo(Obf.Minecraft, Obf.runGameLoop, Void.TYPE);
18 public static final MethodInfo runTick = new MethodInfo(Obf.Minecraft, Obf.runTick, Void.TYPE); 19 public static final MethodInfo runTick = new MethodInfo(Obf.Minecraft, Obf.runTick, Void.TYPE);
@@ -42,9 +43,14 @@ public abstract class Methods @@ -42,9 +43,14 @@ public abstract class Methods
42 public static final MethodInfo realmsPlay = new MethodInfo(Obf.RealmsMainScreen, "play", Void.TYPE, Long.TYPE); 43 public static final MethodInfo realmsPlay = new MethodInfo(Obf.RealmsMainScreen, "play", Void.TYPE, Long.TYPE);
43 public static final MethodInfo realmsStopFetcher = new MethodInfo(Obf.RealmsMainScreen, "stopRealmsFetcherAndPinger", Void.TYPE); 44 public static final MethodInfo realmsStopFetcher = new MethodInfo(Obf.RealmsMainScreen, "stopRealmsFetcherAndPinger", Void.TYPE);
44 45
  46 + // Profiler
45 public static final MethodInfo startSection = new MethodInfo(Obf.Profiler, Obf.startSection, Void.TYPE, String.class); 47 public static final MethodInfo startSection = new MethodInfo(Obf.Profiler, Obf.startSection, Void.TYPE, String.class);
46 public static final MethodInfo endSection = new MethodInfo(Obf.Profiler, Obf.endSection, Void.TYPE); 48 public static final MethodInfo endSection = new MethodInfo(Obf.Profiler, Obf.endSection, Void.TYPE);
47 public static final MethodInfo endStartSection = new MethodInfo(Obf.Profiler, Obf.endStartSection, Void.TYPE, String.class); 49 public static final MethodInfo endStartSection = new MethodInfo(Obf.Profiler, Obf.endStartSection, Void.TYPE, String.class);
  50 +
  51 + // Dedicated Server
  52 + public static final MethodInfo startServer = new MethodInfo(Obf.DedicatedServer, Obf.startServer, Boolean.TYPE);
  53 + public static final MethodInfo startServerThread = new MethodInfo(Obf.MinecraftServer, Obf.startServerThread, Void.TYPE);
48 54
49 private Methods() {} 55 private Methods() {}
50 56
java/common/com/mumfrey/liteloader/interfaces/LoadableMod.java
@@ -101,17 +101,7 @@ public interface LoadableMod&lt;L&gt; extends Loadable&lt;L&gt;, Injectable @@ -101,17 +101,7 @@ public interface LoadableMod&lt;L&gt; extends Loadable&lt;L&gt;, Injectable
101 /** 101 /**
102 * Returns true if this mod can be added as a resource pack 102 * Returns true if this mod can be added as a resource pack
103 */ 103 */
104 - public abstract boolean hasResourcePack();  
105 -  
106 - /**  
107 - * Returns the resource pack for this mod, duck typed via generic to avoid ResourcePack being in the method signature  
108 - */  
109 - public abstract <T> T getResourcePack();  
110 -  
111 - /**  
112 - * Initialise the resource pack with the specified name  
113 - */  
114 - public abstract void initResourcePack(String name); 104 + public abstract boolean hasResources();
115 105
116 /** 106 /**
117 * Get all class names in this container 107 * Get all class names in this container
@@ -297,21 +287,10 @@ public interface LoadableMod&lt;L&gt; extends Loadable&lt;L&gt;, Injectable @@ -297,21 +287,10 @@ public interface LoadableMod&lt;L&gt; extends Loadable&lt;L&gt;, Injectable
297 } 287 }
298 288
299 @Override 289 @Override
300 - public boolean hasResourcePack() 290 + public boolean hasResources()
301 { 291 {
302 return false; 292 return false;
303 } 293 }
304 -  
305 - @Override  
306 - public <T> T getResourcePack()  
307 - {  
308 - return null;  
309 - }  
310 -  
311 - @Override  
312 - public void initResourcePack(String name)  
313 - {  
314 - }  
315 294
316 @Override 295 @Override
317 public boolean hasDependencies() 296 public boolean hasDependencies()
java/common/com/mumfrey/liteloader/interfaces/ObjectFactory.java
@@ -9,6 +9,7 @@ import com.mumfrey.liteloader.core.PacketEvents; @@ -9,6 +9,7 @@ import com.mumfrey.liteloader.core.PacketEvents;
9 import com.mumfrey.liteloader.core.ServerPluginChannels; 9 import com.mumfrey.liteloader.core.ServerPluginChannels;
10 import com.mumfrey.liteloader.permissions.PermissionsManagerClient; 10 import com.mumfrey.liteloader.permissions.PermissionsManagerClient;
11 import com.mumfrey.liteloader.permissions.PermissionsManagerServer; 11 import com.mumfrey.liteloader.permissions.PermissionsManagerServer;
  12 +import com.mumfrey.liteloader.util.Input;
12 13
13 /** 14 /**
14 * Factory for generating loader managament objects based on the environment 15 * Factory for generating loader managament objects based on the environment
@@ -24,6 +25,8 @@ public interface ObjectFactory&lt;TClient, TServer extends MinecraftServer&gt; @@ -24,6 +25,8 @@ public interface ObjectFactory&lt;TClient, TServer extends MinecraftServer&gt;
24 25
25 public abstract PacketEvents getPacketEventBroker(); 26 public abstract PacketEvents getPacketEventBroker();
26 27
  28 + public abstract Input getInput();
  29 +
27 public abstract GameEngine<TClient, TServer> getGameEngine(); 30 public abstract GameEngine<TClient, TServer> getGameEngine();
28 31
29 public abstract PanelManager<?> getPanelManager(); 32 public abstract PanelManager<?> getPanelManager();
java/common/com/mumfrey/liteloader/launch/LiteLoaderTweaker.java
@@ -14,6 +14,7 @@ import net.minecraft.launchwrapper.ITweaker; @@ -14,6 +14,7 @@ import net.minecraft.launchwrapper.ITweaker;
14 import net.minecraft.launchwrapper.Launch; 14 import net.minecraft.launchwrapper.Launch;
15 import net.minecraft.launchwrapper.LaunchClassLoader; 15 import net.minecraft.launchwrapper.LaunchClassLoader;
16 16
  17 +import com.mumfrey.liteloader.transformers.event.EventInfo;
17 import com.mumfrey.liteloader.util.SortableValue; 18 import com.mumfrey.liteloader.util.SortableValue;
18 import com.mumfrey.liteloader.util.log.LiteLoaderLogger; 19 import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
19 20
@@ -617,4 +618,10 @@ public class LiteLoaderTweaker implements ITweaker @@ -617,4 +618,10 @@ public class LiteLoaderTweaker implements ITweaker
617 { 618 {
618 LiteLoaderTweaker.instance.onPostInit(); 619 LiteLoaderTweaker.instance.onPostInit();
619 } 620 }
  621 +
  622 + public static void dedicatedServerInit(EventInfo<?> e)
  623 + {
  624 + LiteLoaderTweaker.instance.onInit();
  625 + LiteLoaderTweaker.instance.onPostInit();
  626 + }
620 } 627 }
621 \ No newline at end of file 628 \ No newline at end of file
java/common/com/mumfrey/liteloader/util/Input.java
1 package com.mumfrey.liteloader.util; 1 package com.mumfrey.liteloader.util;
2 2
3 -import java.io.File;  
4 -import java.io.FileReader;  
5 -import java.io.FileWriter;  
6 -import java.io.IOException;  
7 -import java.util.ArrayList;  
8 -import java.util.HashMap;  
9 -import java.util.HashSet;  
10 -import java.util.List;  
11 -import java.util.Map;  
12 -import java.util.Properties;  
13 -import java.util.Set;  
14 -  
15 -import net.java.games.input.Component;  
16 -import net.java.games.input.Controller;  
17 -import net.java.games.input.Event;  
18 -import net.java.games.input.EventQueue;  
19 import net.minecraft.client.settings.KeyBinding; 3 import net.minecraft.client.settings.KeyBinding;
20 -import net.minecraft.network.INetHandler;  
21 -import net.minecraft.network.play.server.S01PacketJoinGame;  
22 -import net.minecraft.profiler.Profiler;  
23 -import net.minecraft.world.World;  
24 4
25 import com.mumfrey.liteloader.api.CoreProvider; 5 import com.mumfrey.liteloader.api.CoreProvider;
26 -import com.mumfrey.liteloader.common.GameEngine;  
27 -import com.mumfrey.liteloader.core.LiteLoader;  
28 -import com.mumfrey.liteloader.core.LiteLoaderMods;  
29 -import com.mumfrey.liteloader.launch.LoaderEnvironment;  
30 -import com.mumfrey.liteloader.launch.LoaderProperties;  
31 import com.mumfrey.liteloader.util.jinput.ComponentRegistry; 6 import com.mumfrey.liteloader.util.jinput.ComponentRegistry;
32 7
33 -/**  
34 - * Mod input class, aggregates functionality from LiteLoader's mod key registration functions and JInputLib  
35 - *  
36 - * @author Adam Mummery-Smith  
37 - */  
38 -public final class Input implements CoreProvider 8 +public interface Input extends CoreProvider
39 { 9 {
40 - private GameEngine<?, ?> engine;  
41 -  
42 - /**  
43 - *  
44 - */  
45 - private Profiler profiler;  
46 -  
47 - /**  
48 - * File in which we will store mod key mappings  
49 - */  
50 - private final File keyMapSettingsFile;  
51 -  
52 - /**  
53 - * Properties object which stores mod key mappings  
54 - */  
55 - private final Properties keyMapSettings = new Properties();  
56 -  
57 - /**  
58 - * List of all registered mod keys  
59 - */  
60 - private final List<KeyBinding> modKeyBindings = new ArrayList<KeyBinding>();  
61 -  
62 - /**  
63 - * Map of mod key bindings to their key codes, stored so that we don't need to cast from  
64 - * string in the properties file every tick  
65 - */  
66 - private final Map<KeyBinding, Integer> storedModKeyBindings = new HashMap<KeyBinding, Integer>();  
67 -  
68 - /**  
69 - * JInput component registry  
70 - */  
71 - private final ComponentRegistry jInputComponentRegistry;  
72 -  
73 - /**  
74 - * List of handlers for JInput components  
75 - */  
76 - private final Map<Component, InputEvent> componentEvents = new HashMap<Component, InputEvent>();  
77 -  
78 - /**  
79 - * JInput Controllers to poll  
80 - */  
81 - private Controller[] pollControllers = new Controller[0];  
82 -  
83 - /**  
84 - *  
85 - */  
86 - public Input(LoaderEnvironment environment, LoaderProperties properties)  
87 - {  
88 - if (LiteLoader.getInstance() != null && LiteLoader.getInput() != null)  
89 - {  
90 - throw new IllegalStateException("Only one instance of Input is allowed, use LiteLoader.getInput() to get the active instance");  
91 - }  
92 -  
93 - this.keyMapSettingsFile = new File(environment.getCommonConfigFolder(), "liteloader.keys.properties");  
94 - this.jInputComponentRegistry = new ComponentRegistry();  
95 -  
96 - if (!properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_JINPUT_DISABLE, false))  
97 - {  
98 - this.jInputComponentRegistry.enumerate();  
99 - }  
100 - }  
101 -  
102 - @Override  
103 - public void onInit()  
104 - {  
105 - if (this.keyMapSettingsFile.exists())  
106 - {  
107 - try  
108 - {  
109 - this.keyMapSettings.load(new FileReader(this.keyMapSettingsFile));  
110 - }  
111 - catch (Exception ex) {}  
112 - }  
113 - }  
114 -  
115 - @Override  
116 - public void onPostInit(GameEngine<?, ?> engine)  
117 - {  
118 - this.engine = engine;  
119 - this.profiler = engine.getProfiler();  
120 - }  
121 -  
122 - @Override  
123 - public void onPostInitComplete(LiteLoaderMods mods)  
124 - {  
125 - }  
126 -  
127 - @Override  
128 - public void onStartupComplete()  
129 - {  
130 - }  
131 -  
132 - @Override  
133 - public void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket)  
134 - {  
135 - }  
136 -  
137 - @Override  
138 - public void onWorldChanged(World world)  
139 - {  
140 - }  
141 -  
142 - @Override  
143 - public void onPostRender(int mouseX, int mouseY, float partialTicks)  
144 - {  
145 - }  
146 -  
147 /** 10 /**
148 * Register a key for a mod 11 * Register a key for a mod
149 * 12 *
150 * @param binding 13 * @param binding
151 */ 14 */
152 - public void registerKeyBinding(KeyBinding binding)  
153 - {  
154 - List<KeyBinding> keyBindings = this.engine.getKeyBindings();  
155 -  
156 - if (!keyBindings.contains(binding))  
157 - {  
158 - if (this.keyMapSettings.containsKey(binding.getKeyDescription()))  
159 - {  
160 - try  
161 - {  
162 - binding.setKeyCode(Integer.parseInt(this.keyMapSettings.getProperty(binding.getKeyDescription(), String.valueOf(binding.getKeyCode()))));  
163 - }  
164 - catch (NumberFormatException ex) {}  
165 - }  
166 -  
167 - keyBindings.add(binding);  
168 -  
169 - this.engine.setKeyBindings(keyBindings);  
170 - this.modKeyBindings.add(binding);  
171 -  
172 - this.updateBinding(binding);  
173 - this.storeBindings();  
174 -  
175 - KeyBinding.resetKeyBindingArrayAndHash();  
176 - }  
177 - } 15 + public abstract void registerKeyBinding(KeyBinding binding);
178 16
179 /** 17 /**
180 * Unregisters a registered keybind with the game settings class, thus removing it from the "controls" screen 18 * Unregisters a registered keybind with the game settings class, thus removing it from the "controls" screen
181 * 19 *
182 * @param binding 20 * @param binding
183 */ 21 */
184 - public void unRegisterKeyBinding(KeyBinding binding)  
185 - {  
186 - List<KeyBinding> keyBindings = this.engine.getKeyBindings();  
187 -  
188 - if (keyBindings.contains(binding))  
189 - {  
190 - keyBindings.remove(binding);  
191 - this.engine.setKeyBindings(keyBindings);  
192 -  
193 - this.modKeyBindings.remove(binding);  
194 -  
195 - KeyBinding.resetKeyBindingArrayAndHash();  
196 - }  
197 - }  
198 -  
199 - /**  
200 - * Checks for changed mod keybindings and stores any that have changed  
201 - */  
202 - @Override  
203 - public void onTick(boolean clock, float partialTicks, boolean inGame)  
204 - {  
205 - this.profiler.startSection("keybindings");  
206 - if (clock)  
207 - {  
208 - boolean updated = false;  
209 -  
210 - for (KeyBinding binding : this.modKeyBindings)  
211 - {  
212 - if (binding.getKeyCode() != this.storedModKeyBindings.get(binding))  
213 - {  
214 - this.updateBinding(binding);  
215 - updated = true;  
216 - }  
217 - }  
218 -  
219 - if (updated) this.storeBindings();  
220 - }  
221 -  
222 - this.pollControllers();  
223 - this.profiler.endSection();  
224 - } 22 + public abstract void unRegisterKeyBinding(KeyBinding binding);
225 23
226 /** 24 /**
227 - * @param binding  
228 - */  
229 - private void updateBinding(KeyBinding binding)  
230 - {  
231 - this.keyMapSettings.setProperty(binding.getKeyDescription(), String.valueOf(binding.getKeyCode()));  
232 - this.storedModKeyBindings.put(binding, Integer.valueOf(binding.getKeyCode()));  
233 - }  
234 -  
235 - @Override  
236 - public void onShutDown()  
237 - {  
238 - this.storeBindings();  
239 - }  
240 -  
241 - /**  
242 * Writes mod bindings to disk 25 * Writes mod bindings to disk
243 */ 26 */
244 - public void storeBindings()  
245 - {  
246 - try  
247 - {  
248 - this.keyMapSettings.store(new FileWriter(this.keyMapSettingsFile), "Mod key mappings for LiteLoader mods, stored here to avoid losing settings stored in options.txt");  
249 - }  
250 - catch (IOException ex) {}  
251 - } 27 + public abstract void storeBindings();
252 28
253 /** 29 /**
254 * Gets the underlying JInput component registry 30 * Gets the underlying JInput component registry
255 */ 31 */
256 - public ComponentRegistry getComponentRegistry()  
257 - {  
258 - return this.jInputComponentRegistry;  
259 - }  
260 - 32 + public abstract ComponentRegistry getComponentRegistry();
  33 +
261 /** 34 /**
262 * Returns a handle to the event described by descriptor (or null if no component is found matching the 35 * Returns a handle to the event described by descriptor (or null if no component is found matching the
263 * descriptor. Retrieving an event via this method adds the controller (if found) to the polling list and 36 * descriptor. Retrieving an event via this method adds the controller (if found) to the polling list and
@@ -275,13 +48,7 @@ public final class Input implements CoreProvider @@ -275,13 +48,7 @@ public final class Input implements CoreProvider
275 * @param descriptor 48 * @param descriptor
276 * @param handler 49 * @param handler
277 */ 50 */
278 - public InputEvent getEvent(String descriptor, InputHandler handler)  
279 - {  
280 - if (handler == null) return null;  
281 - Component component = this.jInputComponentRegistry.getComponent(descriptor);  
282 - Controller controller = this.jInputComponentRegistry.getController(descriptor);  
283 - return this.addEventHandler(controller, component, handler);  
284 - } 51 + public abstract InputEvent getEvent(String descriptor, InputHandler handler);
285 52
286 /** 53 /**
287 * Get events for all components which match the supplied descriptor 54 * Get events for all components which match the supplied descriptor
@@ -289,90 +56,5 @@ public final class Input implements CoreProvider @@ -289,90 +56,5 @@ public final class Input implements CoreProvider
289 * @param descriptor 56 * @param descriptor
290 * @param handler 57 * @param handler
291 */ 58 */
292 - public InputEvent[] getEvents(String descriptor, InputHandler handler)  
293 - {  
294 - List<InputEvent> events = new ArrayList<InputEvent>();  
295 - Controller controller = this.jInputComponentRegistry.getController(descriptor);  
296 - if (controller != null)  
297 - {  
298 - for (Component component : controller.getComponents())  
299 - {  
300 - events.add(this.addEventHandler(controller, component, handler));  
301 - }  
302 - }  
303 -  
304 - return events.toArray(new InputEvent[0]);  
305 - }  
306 -  
307 - /**  
308 - * @param controller  
309 - * @param component  
310 - * @param handler  
311 - */  
312 - private InputEvent addEventHandler(Controller controller, Component component, InputHandler handler)  
313 - {  
314 - if (controller != null && component != null && handler != null)  
315 - {  
316 - this.addController(controller);  
317 -  
318 - InputEvent event = new InputEvent(controller, component, handler);  
319 - this.componentEvents.put(component, event.link(this.componentEvents.get(component)));  
320 -  
321 - return event;  
322 - }  
323 -  
324 - return null;  
325 - }  
326 -  
327 - /**  
328 - * @param controller  
329 - */  
330 - private void addController(Controller controller)  
331 - {  
332 - Set<Controller> controllers = this.getActiveControllers();  
333 - controllers.add(controller);  
334 - this.setActiveControllers(controllers);  
335 - }  
336 -  
337 - /**  
338 - *  
339 - */  
340 - private Set<Controller> getActiveControllers()  
341 - {  
342 - Set<Controller> allControllers = new HashSet<Controller>();  
343 - for (Controller controller : this.pollControllers)  
344 - allControllers.add(controller);  
345 - return allControllers;  
346 - }  
347 -  
348 - /**  
349 - * @param controllers  
350 - */  
351 - private void setActiveControllers(Set<Controller> controllers)  
352 - {  
353 - this.pollControllers = controllers.toArray(new Controller[controllers.size()]);  
354 - }  
355 -  
356 - /**  
357 - *  
358 - */  
359 - private void pollControllers()  
360 - {  
361 - for (Controller controller : this.pollControllers)  
362 - {  
363 - controller.poll();  
364 - EventQueue controllerQueue = controller.getEventQueue();  
365 -  
366 - for (Event event = new Event(); controllerQueue.getNextEvent(event); )  
367 - {  
368 - Component cmp = event.getComponent();  
369 -  
370 - InputEvent inputEvent = this.componentEvents.get(cmp);  
371 - if (inputEvent != null)  
372 - {  
373 - inputEvent.onEvent(event);  
374 - }  
375 - }  
376 - }  
377 - }  
378 -} 59 + public abstract InputEvent[] getEvents(String descriptor, InputHandler handler);
  60 +}
379 \ No newline at end of file 61 \ No newline at end of file