Commit 189931b8aae31a0b6aca5704340600fb35499d27

Authored by Mumfrey
1 parent d34ad93d

added 2 new listeners, some refactoring and minor bugfixes

Showing 29 changed files with 398 additions and 209 deletions
debug/obfuscation.properties
@@ -24,4 +24,8 @@ func_147612_c=bindFramebufferTexture @@ -24,4 +24,8 @@ func_147612_c=bindFramebufferTexture
24 func_146230_a=drawChat 24 func_146230_a=drawChat
25 func_179086_m=clear 25 func_179086_m=clear
26 func_175068_a=renderWorldPass 26 func_175068_a=renderWorldPass
27 -func_148256_e=getProfile  
28 \ No newline at end of file 27 \ No newline at end of file
  28 +func_148256_e=getProfile
  29 +func_148260_a=saveScreenshot
  30 +func_148822_b=isFramebufferEnabled
  31 +func_147939_a=doRenderEntity
  32 +func_76986_a=doRender
29 \ No newline at end of file 33 \ No newline at end of file
java/client/com/mumfrey/liteloader/ChatFilter.java
1 package com.mumfrey.liteloader; 1 package com.mumfrey.liteloader;
2 2
3 -import net.minecraft.network.play.server.S02PacketChat; 3 +import com.mumfrey.liteloader.core.LiteLoaderEventBroker.ReturnValue;
  4 +
4 import net.minecraft.util.IChatComponent; 5 import net.minecraft.util.IChatComponent;
5 6
6 7
@@ -14,10 +15,11 @@ public interface ChatFilter extends LiteMod @@ -14,10 +15,11 @@ public interface ChatFilter extends LiteMod
14 /** 15 /**
15 * Chat filter function, return false to filter this packet, true to pass the packet 16 * Chat filter function, return false to filter this packet, true to pass the packet
16 * 17 *
17 - * @param chatPacket Chat packet to examine  
18 * @param chat ChatMessageComponent parsed from the chat packet 18 * @param chat ChatMessageComponent parsed from the chat packet
19 * @param message Chat message parsed from the chat message component 19 * @param message Chat message parsed from the chat message component
  20 + * @param newMessage If you wish to mutate the message, set the value using newMessage.set()
  21 + *
20 * @return True to keep the packet, false to discard 22 * @return True to keep the packet, false to discard
21 */ 23 */
22 - public abstract boolean onChat(S02PacketChat chatPacket, IChatComponent chat, String message); 24 + public abstract boolean onChat(IChatComponent chat, String message, ReturnValue<IChatComponent> newMessage);
23 } 25 }
java/client/com/mumfrey/liteloader/ChatListener.java
@@ -13,7 +13,7 @@ public interface ChatListener extends LiteMod @@ -13,7 +13,7 @@ public interface ChatListener extends LiteMod
13 /** 13 /**
14 * Handle an inbound message 14 * Handle an inbound message
15 * 15 *
16 - * @param chat ChatMessageComponent parsed from the chat packet 16 + * @param chat IChatComponent parsed from the chat packet
17 * @param message Chat message parsed from the chat message component 17 * @param message Chat message parsed from the chat message component
18 */ 18 */
19 public abstract void onChat(IChatComponent chat, String message); 19 public abstract void onChat(IChatComponent chat, String message);
java/client/com/mumfrey/liteloader/EntityRenderListener.java 0 → 100644
  1 +package com.mumfrey.liteloader;
  2 +
  3 +import net.minecraft.client.renderer.entity.Render;
  4 +import net.minecraft.entity.Entity;
  5 +
  6 +/**
  7 + * Interface for mods which want to receive callbacks when entities are rendered into the world
  8 + *
  9 + * @author Adam Mummery-Smith
  10 + */
  11 +public interface EntityRenderListener extends LiteMod
  12 +{
  13 + /**
  14 + * Called immediately prior to an entity being rendered
  15 + *
  16 + * @param render
  17 + * @param entity
  18 + * @param xPos
  19 + * @param yPos
  20 + * @param zPos
  21 + * @param yaw
  22 + * @param partialTicks
  23 + */
  24 + public abstract void onRenderEntity(Render render, Entity entity, double xPos, double yPos, double zPos, float yaw, float partialTicks);
  25 +
  26 + /**
  27 + * Called immediately following an entity being rendered
  28 + *
  29 + * @param render
  30 + * @param entity
  31 + * @param xPos
  32 + * @param yPos
  33 + * @param zPos
  34 + * @param yaw
  35 + * @param partialTicks
  36 + */
  37 + public abstract void onPostRenderEntity(Render render, Entity entity, double xPos, double yPos, double zPos, float yaw, float partialTicks);
  38 +}
java/client/com/mumfrey/liteloader/ScreenshotListener.java 0 → 100644
  1 +package com.mumfrey.liteloader;
  2 +
  3 +import net.minecraft.client.shader.Framebuffer;
  4 +import net.minecraft.util.IChatComponent;
  5 +
  6 +import com.mumfrey.liteloader.core.LiteLoaderEventBroker.ReturnValue;
  7 +
  8 +/**
  9 + * Interface for mods which want to handle or inhibit the saving of screenshots
  10 + *
  11 + * @author Adam Mummery-Smith
  12 + */
  13 +public interface ScreenshotListener extends LiteMod
  14 +{
  15 + /**
  16 + * Called when a screenshot is taken, mods should return FALSE to suspend further processing, or TRUE to allow
  17 + * processing to continue normally
  18 + *
  19 + * @param screenshotName
  20 + * @param width
  21 + * @param height
  22 + * @param fbo
  23 + * @param message Message to return if the event is cancelled
  24 + * @return FALSE to suspend further processing, or TRUE to allow processing to continue normally
  25 + */
  26 + public boolean onSaveScreenshot(String screenshotName, int width, int height, Framebuffer fbo, ReturnValue<IChatComponent> message);
  27 +}
java/client/com/mumfrey/liteloader/client/CallbackProxyClient.java
1 package com.mumfrey.liteloader.client; 1 package com.mumfrey.liteloader.client;
2 2
  3 +import java.io.File;
3 import java.util.UUID; 4 import java.util.UUID;
4 5
5 import net.minecraft.client.Minecraft; 6 import net.minecraft.client.Minecraft;
@@ -7,12 +8,17 @@ import net.minecraft.client.entity.EntityPlayerSP; @@ -7,12 +8,17 @@ import net.minecraft.client.entity.EntityPlayerSP;
7 import net.minecraft.client.gui.GuiIngame; 8 import net.minecraft.client.gui.GuiIngame;
8 import net.minecraft.client.renderer.EntityRenderer; 9 import net.minecraft.client.renderer.EntityRenderer;
9 import net.minecraft.client.renderer.OpenGlHelper; 10 import net.minecraft.client.renderer.OpenGlHelper;
  11 +import net.minecraft.client.renderer.entity.Render;
  12 +import net.minecraft.client.renderer.entity.RenderManager;
10 import net.minecraft.client.shader.Framebuffer; 13 import net.minecraft.client.shader.Framebuffer;
  14 +import net.minecraft.entity.Entity;
11 import net.minecraft.entity.player.EntityPlayer; 15 import net.minecraft.entity.player.EntityPlayer;
12 import net.minecraft.entity.player.EntityPlayerMP; 16 import net.minecraft.entity.player.EntityPlayerMP;
13 import net.minecraft.network.NetworkManager; 17 import net.minecraft.network.NetworkManager;
14 import net.minecraft.server.integrated.IntegratedServer; 18 import net.minecraft.server.integrated.IntegratedServer;
15 import net.minecraft.server.management.ServerConfigurationManager; 19 import net.minecraft.server.management.ServerConfigurationManager;
  20 +import net.minecraft.util.IChatComponent;
  21 +import net.minecraft.util.ScreenShotHelper;
16 import net.minecraft.util.Session; 22 import net.minecraft.util.Session;
17 import net.minecraft.world.WorldSettings; 23 import net.minecraft.world.WorldSettings;
18 24
@@ -29,12 +35,7 @@ import com.mumfrey.liteloader.transformers.event.ReturnEventInfo; @@ -29,12 +35,7 @@ import com.mumfrey.liteloader.transformers.event.ReturnEventInfo;
29 */ 35 */
30 public class CallbackProxyClient 36 public class CallbackProxyClient
31 { 37 {
32 - /**  
33 - * Tick clock, sent as a flag to the core onTick so that mods know it's a new tick  
34 - */  
35 - private static boolean clock = false;  
36 -  
37 - private static EventsClient events; 38 + private static LiteLoaderEventBrokerClient eventBroker;
38 39
39 private static boolean fboEnabled; 40 private static boolean fboEnabled;
40 41
@@ -42,147 +43,145 @@ public class CallbackProxyClient @@ -42,147 +43,145 @@ public class CallbackProxyClient
42 43
43 public static void onStartupComplete(EventInfo<Minecraft> e) 44 public static void onStartupComplete(EventInfo<Minecraft> e)
44 { 45 {
45 - CallbackProxyClient.events = EventsClient.getInstance(); 46 + CallbackProxyClient.eventBroker = LiteLoaderEventBrokerClient.getInstance();
46 47
47 - if (CallbackProxyClient.events == null) 48 + if (CallbackProxyClient.eventBroker == null)
48 { 49 {
49 throw new RuntimeException("LiteLoader failed to start up properly. The game is in an unstable state and must shut down now. Check the developer log for startup errors"); 50 throw new RuntimeException("LiteLoader failed to start up properly. The game is in an unstable state and must shut down now. Check the developer log for startup errors");
50 } 51 }
51 52
52 - CallbackProxyClient.events.onStartupComplete(); 53 + CallbackProxyClient.eventBroker.onStartupComplete();
53 } 54 }
54 55
55 public static void onTimerUpdate(EventInfo<Minecraft> e) 56 public static void onTimerUpdate(EventInfo<Minecraft> e)
56 { 57 {
57 - CallbackProxyClient.events.onTimerUpdate(); 58 + CallbackProxyClient.eventBroker.onTimerUpdate();
58 } 59 }
59 60
60 public static void newTick(EventInfo<Minecraft> e) 61 public static void newTick(EventInfo<Minecraft> e)
61 { 62 {
62 - CallbackProxyClient.clock = true;  
63 } 63 }
64 64
65 public static void onTick(EventInfo<Minecraft> e) 65 public static void onTick(EventInfo<Minecraft> e)
66 { 66 {
67 - CallbackProxyClient.events.onTick(CallbackProxyClient.clock);  
68 - CallbackProxyClient.clock = false; 67 + CallbackProxyClient.eventBroker.onTick();
69 } 68 }
70 69
71 public static void onRender(EventInfo<Minecraft> e) 70 public static void onRender(EventInfo<Minecraft> e)
72 { 71 {
73 - CallbackProxyClient.events.onRender(); 72 + CallbackProxyClient.eventBroker.onRender();
74 } 73 }
75 74
76 public static void preRenderGUI(EventInfo<EntityRenderer> e, float partialTicks) 75 public static void preRenderGUI(EventInfo<EntityRenderer> e, float partialTicks)
77 { 76 {
78 - CallbackProxyClient.events.preRenderGUI(partialTicks); 77 + CallbackProxyClient.eventBroker.preRenderGUI(partialTicks);
79 } 78 }
80 79
81 public static void onSetupCameraTransform(EventInfo<EntityRenderer> e, int pass, float partialTicks, long timeSlice) 80 public static void onSetupCameraTransform(EventInfo<EntityRenderer> e, int pass, float partialTicks, long timeSlice)
82 { 81 {
83 - CallbackProxyClient.events.onSetupCameraTransform(partialTicks, timeSlice); 82 + CallbackProxyClient.eventBroker.onSetupCameraTransform(partialTicks, timeSlice);
84 } 83 }
85 84
86 public static void postRenderEntities(EventInfo<EntityRenderer> e, int pass, float partialTicks, long timeSlice) 85 public static void postRenderEntities(EventInfo<EntityRenderer> e, int pass, float partialTicks, long timeSlice)
87 { 86 {
88 - CallbackProxyClient.events.postRenderEntities(partialTicks, timeSlice); 87 + CallbackProxyClient.eventBroker.postRenderEntities(partialTicks, timeSlice);
89 } 88 }
90 89
91 public static void postRender(EventInfo<EntityRenderer> e, float partialTicks, long timeSlice) 90 public static void postRender(EventInfo<EntityRenderer> e, float partialTicks, long timeSlice)
92 { 91 {
93 - CallbackProxyClient.events.postRender(partialTicks, timeSlice); 92 + CallbackProxyClient.eventBroker.postRender(partialTicks, timeSlice);
94 } 93 }
95 94
96 public static void onRenderHUD(EventInfo<EntityRenderer> e, float partialTicks) 95 public static void onRenderHUD(EventInfo<EntityRenderer> e, float partialTicks)
97 { 96 {
98 - CallbackProxyClient.events.onRenderHUD(partialTicks); 97 + CallbackProxyClient.eventBroker.onRenderHUD(partialTicks);
99 } 98 }
100 99
101 public static void onRenderChat(EventInfo<GuiIngame> e, float partialTicks) 100 public static void onRenderChat(EventInfo<GuiIngame> e, float partialTicks)
102 { 101 {
103 - CallbackProxyClient.events.onRenderChat(e.getSource().getChatGUI(), partialTicks); 102 + CallbackProxyClient.eventBroker.onRenderChat(e.getSource().getChatGUI(), partialTicks);
104 } 103 }
105 104
106 public static void postRenderChat(EventInfo<GuiIngame> e, float partialTicks) 105 public static void postRenderChat(EventInfo<GuiIngame> e, float partialTicks)
107 { 106 {
108 - CallbackProxyClient.events.postRenderChat(e.getSource().getChatGUI(), partialTicks); 107 + CallbackProxyClient.eventBroker.postRenderChat(e.getSource().getChatGUI(), partialTicks);
109 } 108 }
110 109
111 public static void postRenderHUD(EventInfo<EntityRenderer> e, float partialTicks) 110 public static void postRenderHUD(EventInfo<EntityRenderer> e, float partialTicks)
112 { 111 {
113 - CallbackProxyClient.events.postRenderHUD(partialTicks); 112 + CallbackProxyClient.eventBroker.postRenderHUD(partialTicks);
114 } 113 }
115 114
116 public static void IntegratedServerCtor(EventInfo<IntegratedServer> e, Minecraft minecraft, String folderName, String worldName, WorldSettings worldSettings) 115 public static void IntegratedServerCtor(EventInfo<IntegratedServer> e, Minecraft minecraft, String folderName, String worldName, WorldSettings worldSettings)
117 { 116 {
118 - CallbackProxyClient.events.onStartServer(e.getSource(), folderName, worldName, worldSettings); 117 + CallbackProxyClient.eventBroker.onStartServer(e.getSource(), folderName, worldName, worldSettings);
119 } 118 }
120 119
121 public static void onInitializePlayerConnection(EventInfo<ServerConfigurationManager> e, NetworkManager netManager, EntityPlayerMP player) 120 public static void onInitializePlayerConnection(EventInfo<ServerConfigurationManager> e, NetworkManager netManager, EntityPlayerMP player)
122 { 121 {
123 - CallbackProxyClient.events.onInitializePlayerConnection(e.getSource(), netManager, player); 122 + CallbackProxyClient.eventBroker.onInitializePlayerConnection(e.getSource(), netManager, player);
124 } 123 }
125 124
126 public static void onPlayerLogin(EventInfo<ServerConfigurationManager> e, EntityPlayerMP player) 125 public static void onPlayerLogin(EventInfo<ServerConfigurationManager> e, EntityPlayerMP player)
127 { 126 {
128 - CallbackProxyClient.events.onPlayerLogin(e.getSource(), player); 127 + CallbackProxyClient.eventBroker.onPlayerLogin(e.getSource(), player);
129 } 128 }
130 129
131 public static void onPlayerLogout(EventInfo<ServerConfigurationManager> e, EntityPlayerMP player) 130 public static void onPlayerLogout(EventInfo<ServerConfigurationManager> e, EntityPlayerMP player)
132 { 131 {
133 - CallbackProxyClient.events.onPlayerLogout(e.getSource(), player); 132 + CallbackProxyClient.eventBroker.onPlayerLogout(e.getSource(), player);
134 } 133 }
135 134
136 public static void onSpawnPlayer(ReturnEventInfo<ServerConfigurationManager, EntityPlayerMP> e, GameProfile profile) 135 public static void onSpawnPlayer(ReturnEventInfo<ServerConfigurationManager, EntityPlayerMP> e, GameProfile profile)
137 { 136 {
138 - CallbackProxyClient.events.onSpawnPlayer(e.getSource(), e.getReturnValue(), profile); 137 + CallbackProxyClient.eventBroker.onSpawnPlayer(e.getSource(), e.getReturnValue(), profile);
139 } 138 }
140 139
141 public static void onRespawnPlayer(ReturnEventInfo<ServerConfigurationManager, EntityPlayerMP> e, EntityPlayerMP oldPlayer, int dimension, boolean won) 140 public static void onRespawnPlayer(ReturnEventInfo<ServerConfigurationManager, EntityPlayerMP> e, EntityPlayerMP oldPlayer, int dimension, boolean won)
142 { 141 {
143 - CallbackProxyClient.events.onRespawnPlayer(e.getSource(), e.getReturnValue(), oldPlayer, dimension, won); 142 + CallbackProxyClient.eventBroker.onRespawnPlayer(e.getSource(), e.getReturnValue(), oldPlayer, dimension, won);
144 } 143 }
145 144
146 public static void onOutboundChat(EventInfo<EntityPlayerSP> e, String message) 145 public static void onOutboundChat(EventInfo<EntityPlayerSP> e, String message)
147 { 146 {
148 - CallbackProxyClient.events.onSendChatMessage(e, message); 147 + CallbackProxyClient.eventBroker.onSendChatMessage(e, message);
149 } 148 }
150 149
151 public static void onResize(EventInfo<Minecraft> e) 150 public static void onResize(EventInfo<Minecraft> e)
152 { 151 {
153 - if (CallbackProxyClient.events == null) return;  
154 - CallbackProxyClient.events.onResize(e.getSource()); 152 + if (CallbackProxyClient.eventBroker == null) return;
  153 + CallbackProxyClient.eventBroker.onResize(e.getSource());
155 } 154 }
156 155
157 public static void preRenderFBO(EventInfo<Minecraft> e) 156 public static void preRenderFBO(EventInfo<Minecraft> e)
158 { 157 {
159 - if (CallbackProxyClient.events == null) return; 158 + if (CallbackProxyClient.eventBroker == null) return;
160 CallbackProxyClient.fboEnabled = OpenGlHelper.isFramebufferEnabled(); 159 CallbackProxyClient.fboEnabled = OpenGlHelper.isFramebufferEnabled();
161 160
162 if (CallbackProxyClient.fboEnabled) 161 if (CallbackProxyClient.fboEnabled)
163 { 162 {
164 CallbackProxyClient.renderingFBO = true; 163 CallbackProxyClient.renderingFBO = true;
165 - CallbackProxyClient.events.preRenderFBO(e.getSource().getFramebuffer()); 164 + CallbackProxyClient.eventBroker.preRenderFBO(e.getSource().getFramebuffer());
166 } 165 }
167 } 166 }
168 167
169 public static void postRenderFBO(EventInfo<Minecraft> e) 168 public static void postRenderFBO(EventInfo<Minecraft> e)
170 { 169 {
171 - if (CallbackProxyClient.events == null) return; 170 + if (CallbackProxyClient.eventBroker == null) return;
172 CallbackProxyClient.renderingFBO = false; 171 CallbackProxyClient.renderingFBO = false;
173 172
174 if (CallbackProxyClient.fboEnabled) 173 if (CallbackProxyClient.fboEnabled)
175 { 174 {
176 - CallbackProxyClient.events.postRenderFBO(e.getSource().getFramebuffer()); 175 + CallbackProxyClient.eventBroker.postRenderFBO(e.getSource().getFramebuffer());
177 } 176 }
178 } 177 }
179 178
180 public static void renderFBO(EventInfo<Framebuffer> e, int width, int height, boolean flag) 179 public static void renderFBO(EventInfo<Framebuffer> e, int width, int height, boolean flag)
181 { 180 {
182 - if (CallbackProxyClient.events == null) return; 181 + if (CallbackProxyClient.eventBroker == null) return;
183 if (CallbackProxyClient.renderingFBO) 182 if (CallbackProxyClient.renderingFBO)
184 { 183 {
185 - CallbackProxyClient.events.onRenderFBO(e.getSource(), width, height); 184 + CallbackProxyClient.eventBroker.onRenderFBO(e.getSource(), width, height);
186 } 185 }
187 186
188 CallbackProxyClient.renderingFBO = false; 187 CallbackProxyClient.renderingFBO = false;
@@ -190,7 +189,22 @@ public class CallbackProxyClient @@ -190,7 +189,22 @@ public class CallbackProxyClient
190 189
191 public static void onRenderWorld(EventInfo<EntityRenderer> e, float partialTicks, long timeSlice) 190 public static void onRenderWorld(EventInfo<EntityRenderer> e, float partialTicks, long timeSlice)
192 { 191 {
193 - CallbackProxyClient.events.onRenderWorld(partialTicks, timeSlice); 192 + CallbackProxyClient.eventBroker.onRenderWorld(partialTicks, timeSlice);
  193 + }
  194 +
  195 + public static void onSaveScreenshot(ReturnEventInfo<ScreenShotHelper, IChatComponent> e, File gameDir, String name, int width, int height, Framebuffer fbo)
  196 + {
  197 + CallbackProxyClient.eventBroker.onScreenshot(e, name, width, height, fbo);
  198 + }
  199 +
  200 + public static void onRenderEntity(ReturnEventInfo<RenderManager, Boolean> e, Entity entity, double xPos, double yPos, double zPos, float yaw, float partialTicks, boolean hideBoundingBox, Render render)
  201 + {
  202 + CallbackProxyClient.eventBroker.onRenderEntity(e.getSource(), entity, xPos, yPos, zPos, yaw, partialTicks, render);
  203 + }
  204 +
  205 + public static void onPostRenderEntity(ReturnEventInfo<RenderManager, Boolean> e, Entity entity, double xPos, double yPos, double zPos, float yaw, float partialTicks, boolean hideBoundingBox, Render render)
  206 + {
  207 + CallbackProxyClient.eventBroker.onPostRenderEntity(e.getSource(), entity, xPos, yPos, zPos, yaw, partialTicks, render);
194 } 208 }
195 209
196 /** 210 /**
java/client/com/mumfrey/liteloader/client/EventsClient.java renamed to java/client/com/mumfrey/liteloader/client/LiteLoaderEventBrokerClient.java
@@ -4,28 +4,22 @@ import net.minecraft.client.Minecraft; @@ -4,28 +4,22 @@ import net.minecraft.client.Minecraft;
4 import net.minecraft.client.entity.EntityPlayerSP; 4 import net.minecraft.client.entity.EntityPlayerSP;
5 import net.minecraft.client.gui.GuiNewChat; 5 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;
  8 +import net.minecraft.client.renderer.entity.RenderManager;
7 import net.minecraft.client.shader.Framebuffer; 9 import net.minecraft.client.shader.Framebuffer;
8 import net.minecraft.entity.Entity; 10 import net.minecraft.entity.Entity;
9 import net.minecraft.network.play.client.C01PacketChatMessage; 11 import net.minecraft.network.play.client.C01PacketChatMessage;
10 import net.minecraft.server.integrated.IntegratedServer; 12 import net.minecraft.server.integrated.IntegratedServer;
  13 +import net.minecraft.util.IChatComponent;
  14 +import net.minecraft.util.ScreenShotHelper;
11 import net.minecraft.util.Timer; 15 import net.minecraft.util.Timer;
12 16
13 import org.lwjgl.input.Mouse; 17 import org.lwjgl.input.Mouse;
14 18
15 -import com.mumfrey.liteloader.ChatRenderListener;  
16 -import com.mumfrey.liteloader.FrameBufferListener;  
17 -import com.mumfrey.liteloader.GameLoopListener;  
18 -import com.mumfrey.liteloader.HUDRenderListener;  
19 -import com.mumfrey.liteloader.InitCompleteListener;  
20 -import com.mumfrey.liteloader.OutboundChatFilter;  
21 -import com.mumfrey.liteloader.OutboundChatListener;  
22 -import com.mumfrey.liteloader.PostRenderListener;  
23 -import com.mumfrey.liteloader.RenderListener;  
24 -import com.mumfrey.liteloader.Tickable;  
25 -import com.mumfrey.liteloader.ViewportListener; 19 +import com.mumfrey.liteloader.*;
26 import com.mumfrey.liteloader.client.overlays.IMinecraft; 20 import com.mumfrey.liteloader.client.overlays.IMinecraft;
27 import com.mumfrey.liteloader.common.LoadingProgress; 21 import com.mumfrey.liteloader.common.LoadingProgress;
28 -import com.mumfrey.liteloader.core.Events; 22 +import com.mumfrey.liteloader.core.LiteLoaderEventBroker;
29 import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate; 23 import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate;
30 import com.mumfrey.liteloader.core.LiteLoader; 24 import com.mumfrey.liteloader.core.LiteLoader;
31 import com.mumfrey.liteloader.core.event.HandlerList; 25 import com.mumfrey.liteloader.core.event.HandlerList;
@@ -33,11 +27,12 @@ import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp; @@ -33,11 +27,12 @@ import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp;
33 import com.mumfrey.liteloader.interfaces.FastIterableDeque; 27 import com.mumfrey.liteloader.interfaces.FastIterableDeque;
34 import com.mumfrey.liteloader.launch.LoaderProperties; 28 import com.mumfrey.liteloader.launch.LoaderProperties;
35 import com.mumfrey.liteloader.transformers.event.EventInfo; 29 import com.mumfrey.liteloader.transformers.event.EventInfo;
  30 +import com.mumfrey.liteloader.transformers.event.ReturnEventInfo;
36 import com.mumfrey.liteloader.util.log.LiteLoaderLogger; 31 import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
37 32
38 -public class EventsClient extends Events<Minecraft, IntegratedServer> 33 +public class LiteLoaderEventBrokerClient extends LiteLoaderEventBroker<Minecraft, IntegratedServer>
39 { 34 {
40 - private static EventsClient instance; 35 + private static LiteLoaderEventBrokerClient instance;
41 36
42 /** 37 /**
43 * Reference to the game 38 * Reference to the game
@@ -45,21 +40,6 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt; @@ -45,21 +40,6 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt;
45 protected final GameEngineClient engineClient; 40 protected final GameEngineClient engineClient;
46 41
47 /** 42 /**
48 - * Reference to the minecraft timer  
49 - */  
50 - private Timer minecraftTimer;  
51 -  
52 - /**  
53 - * Flags which keep track of whether hooks have been applied  
54 - */  
55 - private boolean lateInitDone;  
56 -  
57 - /**  
58 - * ScaledResolution used by the pre-chat and post-chat render callbacks  
59 - */  
60 - private ScaledResolution currentResolution;  
61 -  
62 - /**  
63 * Current screen width 43 * Current screen width
64 */ 44 */
65 private int screenWidth = 854; 45 private int screenWidth = 854;
@@ -91,20 +71,22 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt; @@ -91,20 +71,22 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt;
91 private FastIterableDeque<FrameBufferListener> frameBufferListeners = new HandlerList<FrameBufferListener>(FrameBufferListener.class); 71 private FastIterableDeque<FrameBufferListener> frameBufferListeners = new HandlerList<FrameBufferListener>(FrameBufferListener.class);
92 private FastIterableDeque<InitCompleteListener> initListeners = new HandlerList<InitCompleteListener>(InitCompleteListener.class); 72 private FastIterableDeque<InitCompleteListener> initListeners = new HandlerList<InitCompleteListener>(InitCompleteListener.class);
93 private FastIterableDeque<OutboundChatFilter> outboundChatFilters = new HandlerList<OutboundChatFilter>(OutboundChatFilter.class, ReturnLogicOp.AND); 73 private FastIterableDeque<OutboundChatFilter> outboundChatFilters = new HandlerList<OutboundChatFilter>(OutboundChatFilter.class, ReturnLogicOp.AND);
  74 + private FastIterableDeque<ScreenshotListener> screenshotListeners = new HandlerList<ScreenshotListener>(ScreenshotListener.class, ReturnLogicOp.AND_BREAK_ON_FALSE);
  75 + private FastIterableDeque<EntityRenderListener> entityRenderListeners = new HandlerList<EntityRenderListener>(EntityRenderListener.class);
94 76
95 @SuppressWarnings("cast") 77 @SuppressWarnings("cast")
96 - public EventsClient(LiteLoader loader, GameEngineClient engine, LoaderProperties properties) 78 + public LiteLoaderEventBrokerClient(LiteLoader loader, GameEngineClient engine, LoaderProperties properties)
97 { 79 {
98 super(loader, engine, properties); 80 super(loader, engine, properties);
99 81
100 - EventsClient.instance = this; 82 + LiteLoaderEventBrokerClient.instance = this;
101 83
102 this.engineClient = (GameEngineClient)engine; 84 this.engineClient = (GameEngineClient)engine;
103 } 85 }
104 86
105 - static EventsClient getInstance() 87 + static LiteLoaderEventBrokerClient getInstance()
106 { 88 {
107 - return EventsClient.instance; 89 + return LiteLoaderEventBrokerClient.instance;
108 } 90 }
109 91
110 /* (non-Javadoc) 92 /* (non-Javadoc)
@@ -126,6 +108,8 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt; @@ -126,6 +108,8 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt;
126 delegate.registerInterface(FrameBufferListener.class); 108 delegate.registerInterface(FrameBufferListener.class);
127 delegate.registerInterface(InitCompleteListener.class); 109 delegate.registerInterface(InitCompleteListener.class);
128 delegate.registerInterface(OutboundChatFilter.class); 110 delegate.registerInterface(OutboundChatFilter.class);
  111 + delegate.registerInterface(ScreenshotListener.class);
  112 + delegate.registerInterface(EntityRenderListener.class);
129 } 113 }
130 114
131 /* (non-Javadoc) 115 /* (non-Javadoc)
@@ -223,6 +207,22 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt; @@ -223,6 +207,22 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt;
223 { 207 {
224 this.frameBufferListeners.add(frameBufferListener); 208 this.frameBufferListeners.add(frameBufferListener);
225 } 209 }
  210 +
  211 + /**
  212 + * @param screenshotListener
  213 + */
  214 + public void addScreenshotListener(ScreenshotListener screenshotListener)
  215 + {
  216 + this.screenshotListeners.add(screenshotListener);
  217 + }
  218 +
  219 + /**
  220 + * @param entityRenderListener
  221 + */
  222 + public void addEntityRenderListener(EntityRenderListener entityRenderListener)
  223 + {
  224 + this.entityRenderListeners.add(entityRenderListener);
  225 + }
226 226
227 /** 227 /**
228 * Late initialisation callback 228 * Late initialisation callback
@@ -232,23 +232,18 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt; @@ -232,23 +232,18 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt;
232 { 232 {
233 this.engine.refreshResources(false); 233 this.engine.refreshResources(false);
234 234
235 - if (!this.lateInitDone) 235 + for (InitCompleteListener initMod : this.initListeners)
236 { 236 {
237 - this.lateInitDone = true;  
238 -  
239 - for (InitCompleteListener initMod : this.initListeners) 237 + try
240 { 238 {
241 - try  
242 - {  
243 - LoadingProgress.setMessage("Calling late init for mod %s...", initMod.getName());  
244 - LiteLoaderLogger.info("Calling late init for mod %s", initMod.getName());  
245 - initMod.onInitCompleted(this.engine.getClient(), this.loader);  
246 - }  
247 - catch (Throwable th)  
248 - {  
249 - this.mods.onLateInitFailed(initMod, th);  
250 - LiteLoaderLogger.warning(th, "Error calling late init for mod %s", initMod.getName());  
251 - } 239 + LoadingProgress.setMessage("Calling late init for mod %s...", initMod.getName());
  240 + LiteLoaderLogger.info("Calling late init for mod %s", initMod.getName());
  241 + initMod.onInitCompleted(this.engine.getClient(), this.loader);
  242 + }
  243 + catch (Throwable th)
  244 + {
  245 + this.mods.onLateInitFailed(initMod, th);
  246 + LiteLoaderLogger.warning(th, "Error calling late init for mod %s", initMod.getName());
252 } 247 }
253 } 248 }
254 249
@@ -259,9 +254,9 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt; @@ -259,9 +254,9 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt;
259 254
260 public void onResize(Minecraft minecraft) 255 public void onResize(Minecraft minecraft)
261 { 256 {
262 - this.currentResolution = this.engineClient.getScaledResolution();  
263 - this.screenWidth = this.currentResolution.getScaledWidth();  
264 - this.screenHeight = this.currentResolution.getScaledHeight(); 257 + ScaledResolution currentResolution = this.engineClient.getScaledResolution();
  258 + this.screenWidth = currentResolution.getScaledWidth();
  259 + this.screenHeight = currentResolution.getScaledHeight();
265 260
266 if (this.wasFullScreen != minecraft.isFullScreen()) 261 if (this.wasFullScreen != minecraft.isFullScreen())
267 { 262 {
@@ -269,7 +264,7 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt; @@ -269,7 +264,7 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt;
269 } 264 }
270 265
271 this.wasFullScreen = minecraft.isFullScreen(); 266 this.wasFullScreen = minecraft.isFullScreen();
272 - this.viewportListeners.all().onViewportResized(this.currentResolution, minecraft.displayWidth, minecraft.displayHeight); 267 + this.viewportListeners.all().onViewportResized(currentResolution, minecraft.displayWidth, minecraft.displayHeight);
273 } 268 }
274 269
275 /** 270 /**
@@ -286,9 +281,8 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt; @@ -286,9 +281,8 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt;
286 * @param timeSlice 281 * @param timeSlice
287 * @param partialTicks2 282 * @param partialTicks2
288 */ 283 */
289 - void postRenderEntities(float partialTicks2, long timeSlice) 284 + void postRenderEntities(float partialTicks, long timeSlice)
290 { 285 {
291 - float partialTicks = (this.minecraftTimer != null) ? this.minecraftTimer.elapsedPartialTicks : 0.0F;  
292 this.postRenderListeners.all().onPostRenderEntities(partialTicks); 286 this.postRenderListeners.all().onPostRenderEntities(partialTicks);
293 } 287 }
294 288
@@ -298,9 +292,8 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt; @@ -298,9 +292,8 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt;
298 * @param timeSlice 292 * @param timeSlice
299 * @param partialTicks2 293 * @param partialTicks2
300 */ 294 */
301 - void postRender(float partialTicks2, long timeSlice) 295 + void postRender(float partialTicks, long timeSlice)
302 { 296 {
303 - float partialTicks = (this.minecraftTimer != null) ? this.minecraftTimer.elapsedPartialTicks : 0.0F;  
304 this.postRenderListeners.all().onPostRender(partialTicks); 297 this.postRenderListeners.all().onPostRender(partialTicks);
305 } 298 }
306 299
@@ -376,24 +369,13 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt; @@ -376,24 +369,13 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt;
376 * 369 *
377 * @param clock True if this is a new tick (otherwise it's just a new frame) 370 * @param clock True if this is a new tick (otherwise it's just a new frame)
378 */ 371 */
379 - void onTick(boolean clock) 372 + void onTick()
380 { 373 {
381 this.profiler.startSection("litemods"); 374 this.profiler.startSection("litemods");
382 - float partialTicks = 0.0F;  
383 -  
384 - // Try to get the minecraft timer object and determine the value of the  
385 - // partialTicks  
386 - if (clock || this.minecraftTimer == null)  
387 - {  
388 - this.minecraftTimer = ((IMinecraft)this.engine.getClient()).getTimer();  
389 - }  
390 375
391 - // Hooray, we got the timer reference  
392 - if (this.minecraftTimer != null)  
393 - {  
394 - partialTicks = this.minecraftTimer.renderPartialTicks;  
395 - clock = this.minecraftTimer.elapsedTicks > 0;  
396 - } 376 + Timer minecraftTimer = ((IMinecraft)this.engine.getClient()).getTimer();
  377 + float partialTicks = minecraftTimer.renderPartialTicks;
  378 + boolean clock = minecraftTimer.elapsedTicks > 0;
397 379
398 Minecraft minecraft = this.engine.getClient(); 380 Minecraft minecraft = this.engine.getClient();
399 381
@@ -414,18 +396,11 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt; @@ -414,18 +396,11 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt;
414 this.tickListeners.all().onTick(minecraft, partialTicks, inGame, clock); 396 this.tickListeners.all().onTick(minecraft, partialTicks, inGame, clock);
415 397
416 // Detected world change 398 // Detected world change
417 - if (minecraft.theWorld != null) 399 + int worldHashCode = (minecraft.theWorld != null) ? minecraft.theWorld.hashCode() : 0;
  400 + if (worldHashCode != this.worldHashCode)
418 { 401 {
419 - if (minecraft.theWorld.hashCode() != this.worldHashCode)  
420 - {  
421 - this.worldHashCode = minecraft.theWorld.hashCode();  
422 - super.onWorldChanged(minecraft.theWorld);  
423 - }  
424 - }  
425 - else  
426 - {  
427 - this.worldHashCode = 0;  
428 - super.onWorldChanged(null); 402 + this.worldHashCode = worldHashCode;
  403 + super.onWorldChanged(minecraft.theWorld);
429 } 404 }
430 405
431 this.profiler.endSection(); 406 this.profiler.endSection();
@@ -481,8 +456,55 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt; @@ -481,8 +456,55 @@ public class EventsClient extends Events&lt;Minecraft, IntegratedServer&gt;
481 * @param partialTicks 456 * @param partialTicks
482 * @param timeSlice 457 * @param timeSlice
483 */ 458 */
484 - public void onRenderWorld(float partialTicks, long timeSlice) 459 + void onRenderWorld(float partialTicks, long timeSlice)
485 { 460 {
486 this.renderListeners.all().onRenderWorld(); 461 this.renderListeners.all().onRenderWorld();
487 } 462 }
  463 +
  464 + /**
  465 + * @param e
  466 + * @param name
  467 + * @param width
  468 + * @param height
  469 + * @param fbo
  470 + */
  471 + void onScreenshot(ReturnEventInfo<ScreenShotHelper, IChatComponent> e, String name, int width, int height, Framebuffer fbo)
  472 + {
  473 + ReturnValue<IChatComponent> ret = new ReturnValue<IChatComponent>(e.getReturnValue());
  474 +
  475 + if (!this.screenshotListeners.all().onSaveScreenshot(name, width, height, fbo, ret))
  476 + {
  477 + e.setReturnValue(ret.get());
  478 + }
  479 + }
  480 +
  481 + /**
  482 + * @param source
  483 + * @param entity
  484 + * @param xPos
  485 + * @param yPos
  486 + * @param zPos
  487 + * @param yaw
  488 + * @param partialTicks
  489 + * @param render
  490 + */
  491 + public void onRenderEntity(RenderManager source, Entity entity, double xPos, double yPos, double zPos, float yaw, float partialTicks, Render render)
  492 + {
  493 + this.entityRenderListeners.all().onRenderEntity(render, entity, xPos, yPos, zPos, yaw, partialTicks);
  494 + }
  495 +
  496 + /**
  497 + * @param source
  498 + * @param entity
  499 + * @param xPos
  500 + * @param yPos
  501 + * @param zPos
  502 + * @param yaw
  503 + * @param partialTicks
  504 + * @param render
  505 + */
  506 + public void onPostRenderEntity(RenderManager source, Entity entity, double xPos, double yPos, double zPos, float yaw, float partialTicks, Render render)
  507 + {
  508 + this.entityRenderListeners.all().onPostRenderEntity(render, entity, xPos, yPos, zPos, yaw, partialTicks);
  509 + }
488 } 510 }
java/client/com/mumfrey/liteloader/client/PacketEventsClient.java
@@ -7,6 +7,7 @@ import net.minecraft.network.login.server.S02PacketLoginSuccess; @@ -7,6 +7,7 @@ import net.minecraft.network.login.server.S02PacketLoginSuccess;
7 import net.minecraft.network.play.INetHandlerPlayClient; 7 import net.minecraft.network.play.INetHandlerPlayClient;
8 import net.minecraft.network.play.server.S01PacketJoinGame; 8 import net.minecraft.network.play.server.S01PacketJoinGame;
9 import net.minecraft.network.play.server.S02PacketChat; 9 import net.minecraft.network.play.server.S02PacketChat;
  10 +import net.minecraft.util.ChatComponentText;
10 import net.minecraft.util.IChatComponent; 11 import net.minecraft.util.IChatComponent;
11 12
12 import com.mumfrey.liteloader.ChatFilter; 13 import com.mumfrey.liteloader.ChatFilter;
@@ -15,6 +16,7 @@ import com.mumfrey.liteloader.PostLoginListener; @@ -15,6 +16,7 @@ import com.mumfrey.liteloader.PostLoginListener;
15 import com.mumfrey.liteloader.PreJoinGameListener; 16 import com.mumfrey.liteloader.PreJoinGameListener;
16 import com.mumfrey.liteloader.common.transformers.PacketEventInfo; 17 import com.mumfrey.liteloader.common.transformers.PacketEventInfo;
17 import com.mumfrey.liteloader.core.ClientPluginChannels; 18 import com.mumfrey.liteloader.core.ClientPluginChannels;
  19 +import com.mumfrey.liteloader.core.LiteLoaderEventBroker.ReturnValue;
18 import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate; 20 import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate;
19 import com.mumfrey.liteloader.core.LiteLoader; 21 import com.mumfrey.liteloader.core.LiteLoader;
20 import com.mumfrey.liteloader.core.PacketEvents; 22 import com.mumfrey.liteloader.core.PacketEvents;
@@ -146,14 +148,22 @@ public class PacketEventsClient extends PacketEvents @@ -146,14 +148,22 @@ public class PacketEventsClient extends PacketEvents
146 IChatComponent chat = packet.func_148915_c(); 148 IChatComponent chat = packet.func_148915_c();
147 String message = chat.getFormattedText(); 149 String message = chat.getFormattedText();
148 150
149 - // Chat filters get a stab at the chat first, if any filter returns  
150 - // false the chat is discarded 151 + // Chat filters get a stab at the chat first, if any filter returns false the chat is discarded
151 for (ChatFilter chatFilter : this.chatFilters) 152 for (ChatFilter chatFilter : this.chatFilters)
152 { 153 {
153 - if (chatFilter.onChat(packet, chat, message)) 154 + ReturnValue<IChatComponent> ret = new ReturnValue<IChatComponent>();
  155 +
  156 + if (chatFilter.onChat(chat, message, ret))
154 { 157 {
155 - chat = packet.func_148915_c();  
156 - message = chat.getFormattedText(); 158 + if (ret.isSet())
  159 + {
  160 + chat = ret.get();
  161 + if (chat == null)
  162 + {
  163 + chat = new ChatComponentText("");
  164 + }
  165 + message = chat.getFormattedText();
  166 + }
157 } 167 }
158 else 168 else
159 { 169 {
java/client/com/mumfrey/liteloader/client/api/ObjectFactoryClient.java
@@ -4,7 +4,7 @@ import net.minecraft.client.Minecraft; @@ -4,7 +4,7 @@ import net.minecraft.client.Minecraft;
4 import net.minecraft.client.gui.GuiScreen; 4 import net.minecraft.client.gui.GuiScreen;
5 import net.minecraft.server.integrated.IntegratedServer; 5 import net.minecraft.server.integrated.IntegratedServer;
6 6
7 -import com.mumfrey.liteloader.client.EventsClient; 7 +import com.mumfrey.liteloader.client.LiteLoaderEventBrokerClient;
8 import com.mumfrey.liteloader.client.ClientPluginChannelsClient; 8 import com.mumfrey.liteloader.client.ClientPluginChannelsClient;
9 import com.mumfrey.liteloader.client.GameEngineClient; 9 import com.mumfrey.liteloader.client.GameEngineClient;
10 import com.mumfrey.liteloader.client.LiteLoaderPanelManager; 10 import com.mumfrey.liteloader.client.LiteLoaderPanelManager;
@@ -12,7 +12,7 @@ import com.mumfrey.liteloader.client.PacketEventsClient; @@ -12,7 +12,7 @@ import com.mumfrey.liteloader.client.PacketEventsClient;
12 import com.mumfrey.liteloader.client.gui.startup.LoadingBar; 12 import com.mumfrey.liteloader.client.gui.startup.LoadingBar;
13 import com.mumfrey.liteloader.common.GameEngine; 13 import com.mumfrey.liteloader.common.GameEngine;
14 import com.mumfrey.liteloader.core.ClientPluginChannels; 14 import com.mumfrey.liteloader.core.ClientPluginChannels;
15 -import com.mumfrey.liteloader.core.Events; 15 +import com.mumfrey.liteloader.core.LiteLoaderEventBroker;
16 import com.mumfrey.liteloader.core.LiteLoader; 16 import com.mumfrey.liteloader.core.LiteLoader;
17 import com.mumfrey.liteloader.core.PacketEvents; 17 import com.mumfrey.liteloader.core.PacketEvents;
18 import com.mumfrey.liteloader.core.ServerPluginChannels; 18 import com.mumfrey.liteloader.core.ServerPluginChannels;
@@ -34,7 +34,7 @@ class ObjectFactoryClient implements ObjectFactory&lt;Minecraft, IntegratedServer&gt; @@ -34,7 +34,7 @@ class ObjectFactoryClient implements ObjectFactory&lt;Minecraft, IntegratedServer&gt;
34 34
35 private LoaderProperties properties; 35 private LoaderProperties properties;
36 36
37 - private EventsClient clientEvents; 37 + private LiteLoaderEventBrokerClient clientEvents;
38 38
39 private PacketEventsClient clientPacketEvents; 39 private PacketEventsClient clientPacketEvents;
40 40
@@ -53,11 +53,11 @@ class ObjectFactoryClient implements ObjectFactory&lt;Minecraft, IntegratedServer&gt; @@ -53,11 +53,11 @@ class ObjectFactoryClient implements ObjectFactory&lt;Minecraft, IntegratedServer&gt;
53 } 53 }
54 54
55 @Override 55 @Override
56 - public Events<Minecraft, IntegratedServer> getEventBroker() 56 + public LiteLoaderEventBroker<Minecraft, IntegratedServer> getEventBroker()
57 { 57 {
58 if (this.clientEvents == null) 58 if (this.clientEvents == null)
59 { 59 {
60 - this.clientEvents = new EventsClient(LiteLoader.getInstance(), (GameEngineClient)this.getGameEngine(), this.properties); 60 + this.clientEvents = new LiteLoaderEventBrokerClient(LiteLoader.getInstance(), (GameEngineClient)this.getGameEngine(), this.properties);
61 } 61 }
62 62
63 return this.clientEvents; 63 return this.clientEvents;
java/client/com/mumfrey/liteloader/client/gui/GuiPanel.java
@@ -2,7 +2,6 @@ package com.mumfrey.liteloader.client.gui; @@ -2,7 +2,6 @@ package com.mumfrey.liteloader.client.gui;
2 2
3 import static com.mumfrey.liteloader.gl.GL.*; 3 import static com.mumfrey.liteloader.gl.GL.*;
4 4
5 -import java.io.IOException;  
6 import java.util.LinkedList; 5 import java.util.LinkedList;
7 import java.util.List; 6 import java.util.List;
8 7
@@ -125,7 +124,7 @@ public abstract class GuiPanel extends Gui @@ -125,7 +124,7 @@ public abstract class GuiPanel extends Gui
125 * @param mouseY 124 * @param mouseY
126 * @param mouseButton 125 * @param mouseButton
127 */ 126 */
128 - void mousePressed(int mouseX, int mouseY, int mouseButton) throws IOException 127 + void mousePressed(int mouseX, int mouseY, int mouseButton)
129 { 128 {
130 if (mouseButton == 0) 129 if (mouseButton == 0)
131 { 130 {
java/client/com/mumfrey/liteloader/client/gui/GuiPanelAbout.java
1 package com.mumfrey.liteloader.client.gui; 1 package com.mumfrey.liteloader.client.gui;
2 2
3 -import java.io.IOException;  
4 import java.net.URI; 3 import java.net.URI;
5 import java.util.ArrayList; 4 import java.util.ArrayList;
6 import java.util.List; 5 import java.util.List;
@@ -216,7 +215,7 @@ class GuiPanelAbout extends GuiPanel implements ScrollPanelContent @@ -216,7 +215,7 @@ class GuiPanelAbout extends GuiPanel implements ScrollPanelContent
216 } 215 }
217 216
218 @Override 217 @Override
219 - void mousePressed(int mouseX, int mouseY, int mouseButton) throws IOException 218 + void mousePressed(int mouseX, int mouseY, int mouseButton)
220 { 219 {
221 this.scrollPane.mousePressed(mouseX, mouseY, mouseButton); 220 this.scrollPane.mousePressed(mouseX, mouseY, mouseButton);
222 221
java/client/com/mumfrey/liteloader/client/gui/GuiPanelConfigContainer.java
@@ -2,9 +2,6 @@ package com.mumfrey.liteloader.client.gui; @@ -2,9 +2,6 @@ package com.mumfrey.liteloader.client.gui;
2 2
3 import static com.mumfrey.liteloader.gl.GL.*; 3 import static com.mumfrey.liteloader.gl.GL.*;
4 import static com.mumfrey.liteloader.gl.GLClippingPlanes.*; 4 import static com.mumfrey.liteloader.gl.GLClippingPlanes.*;
5 -  
6 -import java.io.IOException;  
7 -  
8 import net.minecraft.client.Minecraft; 5 import net.minecraft.client.Minecraft;
9 import net.minecraft.client.gui.GuiButton; 6 import net.minecraft.client.gui.GuiButton;
10 import net.minecraft.client.resources.I18n; 7 import net.minecraft.client.resources.I18n;
@@ -218,10 +215,9 @@ class GuiPanelConfigContainer extends GuiPanel implements ConfigPanelHost @@ -218,10 +215,9 @@ class GuiPanelConfigContainer extends GuiPanel implements ConfigPanelHost
218 * @param mouseX 215 * @param mouseX
219 * @param mouseY 216 * @param mouseY
220 * @param mouseButton 217 * @param mouseButton
221 - * @throws IOException  
222 */ 218 */
223 @Override 219 @Override
224 - void mousePressed(int mouseX, int mouseY, int mouseButton) throws IOException 220 + void mousePressed(int mouseX, int mouseY, int mouseButton)
225 { 221 {
226 if (mouseButton == 0) 222 if (mouseButton == 0)
227 { 223 {
java/client/com/mumfrey/liteloader/client/gui/GuiPanelError.java
1 package com.mumfrey.liteloader.client.gui; 1 package com.mumfrey.liteloader.client.gui;
2 2
3 -import java.io.IOException;  
4 import java.io.PrintWriter; 3 import java.io.PrintWriter;
5 import java.io.StringWriter; 4 import java.io.StringWriter;
6 import java.util.ArrayList; 5 import java.util.ArrayList;
@@ -131,7 +130,7 @@ public class GuiPanelError extends GuiPanel implements ScrollPanelContent @@ -131,7 +130,7 @@ public class GuiPanelError extends GuiPanel implements ScrollPanelContent
131 } 130 }
132 131
133 @Override 132 @Override
134 - void mousePressed(int mouseX, int mouseY, int mouseButton) throws IOException 133 + void mousePressed(int mouseX, int mouseY, int mouseButton)
135 { 134 {
136 this.scrollPane.mousePressed(mouseX, mouseY, mouseButton); 135 this.scrollPane.mousePressed(mouseX, mouseY, mouseButton);
137 super.mousePressed(mouseX, mouseY, mouseButton); 136 super.mousePressed(mouseX, mouseY, mouseButton);
java/client/com/mumfrey/liteloader/client/gui/GuiPanelLiteLoaderLog.java
@@ -2,7 +2,6 @@ package com.mumfrey.liteloader.client.gui; @@ -2,7 +2,6 @@ package com.mumfrey.liteloader.client.gui;
2 2
3 import static com.mumfrey.liteloader.gl.GL.*; 3 import static com.mumfrey.liteloader.gl.GL.*;
4 4
5 -import java.io.IOException;  
6 import java.net.URI; 5 import java.net.URI;
7 import java.util.ArrayList; 6 import java.util.ArrayList;
8 import java.util.List; 7 import java.util.List;
@@ -333,10 +332,9 @@ class GuiPanelLiteLoaderLog extends GuiPanel implements ScrollPanelContent @@ -333,10 +332,9 @@ class GuiPanelLiteLoaderLog extends GuiPanel implements ScrollPanelContent
333 * @param mouseX 332 * @param mouseX
334 * @param mouseY 333 * @param mouseY
335 * @param mouseButton 334 * @param mouseButton
336 - * @throws IOException  
337 */ 335 */
338 @Override 336 @Override
339 - void mousePressed(int mouseX, int mouseY, int mouseButton) throws IOException 337 + void mousePressed(int mouseX, int mouseY, int mouseButton)
340 { 338 {
341 this.scrollPane.mousePressed(mouseX, mouseY, mouseButton); 339 this.scrollPane.mousePressed(mouseX, mouseY, mouseButton);
342 340
java/client/com/mumfrey/liteloader/client/gui/GuiPanelMods.java
@@ -3,7 +3,6 @@ package com.mumfrey.liteloader.client.gui; @@ -3,7 +3,6 @@ package com.mumfrey.liteloader.client.gui;
3 import static com.mumfrey.liteloader.gl.GL.*; 3 import static com.mumfrey.liteloader.gl.GL.*;
4 import static com.mumfrey.liteloader.gl.GLClippingPlanes.*; 4 import static com.mumfrey.liteloader.gl.GLClippingPlanes.*;
5 5
6 -import java.io.IOException;  
7 import java.util.ArrayList; 6 import java.util.ArrayList;
8 import java.util.List; 7 import java.util.List;
9 import java.util.Map; 8 import java.util.Map;
@@ -164,7 +163,7 @@ public class GuiPanelMods extends GuiPanel @@ -164,7 +163,7 @@ public class GuiPanelMods extends GuiPanel
164 } 163 }
165 164
166 @Override 165 @Override
167 - void mousePressed(int mouseX, int mouseY, int mouseButton) throws IOException 166 + void mousePressed(int mouseX, int mouseY, int mouseButton)
168 { 167 {
169 if (mouseButton == 0) 168 if (mouseButton == 0)
170 { 169 {
java/client/com/mumfrey/liteloader/client/gui/GuiScrollPanel.java
@@ -2,9 +2,6 @@ package com.mumfrey.liteloader.client.gui; @@ -2,9 +2,6 @@ package com.mumfrey.liteloader.client.gui;
2 2
3 import static com.mumfrey.liteloader.gl.GL.*; 3 import static com.mumfrey.liteloader.gl.GL.*;
4 import static com.mumfrey.liteloader.gl.GLClippingPlanes.*; 4 import static com.mumfrey.liteloader.gl.GLClippingPlanes.*;
5 -  
6 -import java.io.IOException;  
7 -  
8 import net.minecraft.client.Minecraft; 5 import net.minecraft.client.Minecraft;
9 import net.minecraft.client.gui.GuiButton; 6 import net.minecraft.client.gui.GuiButton;
10 7
@@ -142,7 +139,7 @@ class GuiScrollPanel extends GuiPanel @@ -142,7 +139,7 @@ class GuiScrollPanel extends GuiPanel
142 } 139 }
143 140
144 @Override 141 @Override
145 - public void mousePressed(int mouseX, int mouseY, int mouseButton) throws IOException 142 + public void mousePressed(int mouseX, int mouseY, int mouseButton)
146 { 143 {
147 mouseY += this.scrollBar.getValue() - this.top; 144 mouseY += this.scrollBar.getValue() - this.top;
148 mouseX -= this.left; 145 mouseX -= this.left;
java/client/com/mumfrey/liteloader/client/transformers/LiteLoaderEventInjectionTransformer.java
@@ -51,6 +51,9 @@ public class LiteLoaderEventInjectionTransformer extends EventInjectionTransform @@ -51,6 +51,9 @@ public class LiteLoaderEventInjectionTransformer extends EventInjectionTransform
51 Event onRespawnPlayer = Event.getOrCreate("onRespawnPlayer", false); 51 Event onRespawnPlayer = Event.getOrCreate("onRespawnPlayer", false);
52 Event onStartupComplete = Event.getOrCreate("onStartupComplete", false); 52 Event onStartupComplete = Event.getOrCreate("onStartupComplete", false);
53 Event onSessionProfileBad = Event.getOrCreate("onSessionProfileBad", true); 53 Event onSessionProfileBad = Event.getOrCreate("onSessionProfileBad", true);
  54 + Event onSaveScreenshot = Event.getOrCreate("onSaveScreenshot", true);
  55 + Event onRenderEntity = Event.getOrCreate("onRenderEntity", false);
  56 + Event onPostRenderEntity = Event.getOrCreate("onPostRenderEntity", false);
54 57
55 // Injection Points 58 // Injection Points
56 InjectionPoint methodHead = new MethodHead(); 59 InjectionPoint methodHead = new MethodHead();
@@ -62,6 +65,8 @@ public class LiteLoaderEventInjectionTransformer extends EventInjectionTransform @@ -62,6 +65,8 @@ public class LiteLoaderEventInjectionTransformer extends EventInjectionTransform
62 InjectionPoint beforeRender = new BeforeInvoke(updateCameraAndRender); 65 InjectionPoint beforeRender = new BeforeInvoke(updateCameraAndRender);
63 InjectionPoint beforeDrawChat = new BeforeInvoke(drawChat); 66 InjectionPoint beforeDrawChat = new BeforeInvoke(drawChat);
64 InjectionPoint beforeEndProfiler = new BeforeInvoke(endSection); 67 InjectionPoint beforeEndProfiler = new BeforeInvoke(endSection);
  68 + InjectionPoint beforeIsFBOEnabled = new BeforeInvoke(isFramebufferEnabled);
  69 + InjectionPoint beforeRenderEntity = new BeforeInvoke(doRender).setCaptureLocals(true);
65 InjectionPoint beforeTickProfiler = new BeforeStringInvoke("tick", startSection); 70 InjectionPoint beforeTickProfiler = new BeforeStringInvoke("tick", startSection);
66 InjectionPoint beforeCenterProfiler = new BeforeStringInvoke("center", startSection); 71 InjectionPoint beforeCenterProfiler = new BeforeStringInvoke("center", startSection);
67 InjectionPoint beforeRenderProfiler = new BeforeStringInvoke("gameRenderer", endStartSection); 72 InjectionPoint beforeRenderProfiler = new BeforeStringInvoke("gameRenderer", endStartSection);
@@ -95,6 +100,9 @@ public class LiteLoaderEventInjectionTransformer extends EventInjectionTransform @@ -95,6 +100,9 @@ public class LiteLoaderEventInjectionTransformer extends EventInjectionTransform
95 this.add(onSpawnPlayer, spawnPlayer, (methodReturn), "onSpawnPlayer"); 100 this.add(onSpawnPlayer, spawnPlayer, (methodReturn), "onSpawnPlayer");
96 this.add(onRespawnPlayer, respawnPlayer, (methodReturn), "onRespawnPlayer"); 101 this.add(onRespawnPlayer, respawnPlayer, (methodReturn), "onRespawnPlayer");
97 this.add(onStartupComplete, startGame, (methodReturn), "onStartupComplete"); 102 this.add(onStartupComplete, startGame, (methodReturn), "onStartupComplete");
  103 + this.add(onSaveScreenshot, saveScreenshot, (beforeIsFBOEnabled), "onSaveScreenshot");
  104 + this.add(onRenderEntity, doRenderEntity, (beforeRenderEntity), "onRenderEntity");
  105 + this.add(onPostRenderEntity, doRenderEntity, after(beforeRenderEntity), "onPostRenderEntity");
98 106
99 // Compatibility handlers 107 // Compatibility handlers
100 this.add(onSessionProfileBad, getProfile, (beforeNewGameProfile), "generateOfflineUUID"); 108 this.add(onSessionProfileBad, getProfile, (beforeNewGameProfile), "generateOfflineUUID");
java/common/com/mumfrey/liteloader/core/LiteLoader.java
@@ -143,7 +143,7 @@ public final class LiteLoader @@ -143,7 +143,7 @@ public final class LiteLoader
143 /** 143 /**
144 * Event manager 144 * Event manager
145 */ 145 */
146 - private Events<?, ?> events; 146 + private LiteLoaderEventBroker<?, ?> events;
147 147
148 /** 148 /**
149 * Plugin channel manager 149 * Plugin channel manager
java/common/com/mumfrey/liteloader/core/Events.java renamed to java/common/com/mumfrey/liteloader/core/LiteLoaderEventBroker.java
@@ -33,9 +33,45 @@ import com.mumfrey.liteloader.util.log.LiteLoaderLogger; @@ -33,9 +33,45 @@ import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
33 * @param <TClient> Type of the client runtime, "Minecraft" on client and null on the server 33 * @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 34 * @param <TServer> Type of the server runtime, "IntegratedServer" on the client, "MinecraftServer" on the server
35 */ 35 */
36 -public abstract class Events<TClient, TServer extends MinecraftServer> implements InterfaceProvider, IResourceManagerReloadListener 36 +public abstract class LiteLoaderEventBroker<TClient, TServer extends MinecraftServer> implements InterfaceProvider, IResourceManagerReloadListener
37 { 37 {
38 /** 38 /**
  39 + * @author Adam Mummery-Smith
  40 + *
  41 + * @param <T>
  42 + */
  43 + public static class ReturnValue<T>
  44 + {
  45 + private T value;
  46 + private boolean isSet;
  47 +
  48 + public ReturnValue(T value)
  49 + {
  50 + this.value = value;
  51 + }
  52 +
  53 + public ReturnValue()
  54 + {
  55 + }
  56 +
  57 + public boolean isSet()
  58 + {
  59 + return this.isSet;
  60 + }
  61 +
  62 + public T get()
  63 + {
  64 + return this.value;
  65 + }
  66 +
  67 + public void set(T value)
  68 + {
  69 + this.isSet = true;
  70 + this.value = value;
  71 + }
  72 + }
  73 +
  74 + /**
39 * Reference to the loader instance 75 * Reference to the loader instance
40 */ 76 */
41 protected final LiteLoader loader; 77 protected final LiteLoader loader;
@@ -61,14 +97,14 @@ public abstract class Events&lt;TClient, TServer extends MinecraftServer&gt; implement @@ -61,14 +97,14 @@ public abstract class Events&lt;TClient, TServer extends MinecraftServer&gt; implement
61 * List of mods which monitor server player events 97 * List of mods which monitor server player events
62 */ 98 */
63 private FastIterable<ServerPlayerListener> serverPlayerListeners = new HandlerList<ServerPlayerListener>(ServerPlayerListener.class); 99 private FastIterable<ServerPlayerListener> serverPlayerListeners = new HandlerList<ServerPlayerListener>(ServerPlayerListener.class);
64 - 100 +
65 /** 101 /**
66 * Package private ctor 102 * Package private ctor
67 * 103 *
68 * @param loader 104 * @param loader
69 * @param minecraft 105 * @param minecraft
70 */ 106 */
71 - public Events(LiteLoader loader, GameEngine<TClient, TServer> engine, LoaderProperties properties) 107 + public LiteLoaderEventBroker(LiteLoader loader, GameEngine<TClient, TServer> engine, LoaderProperties properties)
72 { 108 {
73 this.loader = loader; 109 this.loader = loader;
74 this.engine = engine; 110 this.engine = engine;
java/common/com/mumfrey/liteloader/core/LiteLoaderVersion.java
@@ -37,7 +37,7 @@ public enum LiteLoaderVersion @@ -37,7 +37,7 @@ public enum LiteLoaderVersion
37 MC_1_7_10_R1(28, 1404673785, "1.7.10", "1.7.10_01", "1.7.10"), 37 MC_1_7_10_R1(28, 1404673785, "1.7.10", "1.7.10_01", "1.7.10"),
38 MC_1_7_10_R2(29, 1405369406, "1.7.10", "1.7.10_02", "1.7.10"), 38 MC_1_7_10_R2(29, 1405369406, "1.7.10", "1.7.10_02", "1.7.10"),
39 MC_1_7_10_R3(30, 1407687918, "1.7.10", "1.7.10_03", "1.7.10", "1.7.10_03"), 39 MC_1_7_10_R3(30, 1407687918, "1.7.10", "1.7.10_03", "1.7.10", "1.7.10_03"),
40 - MC_1_7_10_R4(31, 0, "1.7.10", "1.7.10_04", "1.7.10", "1.7.10_03", "1.7.10_04"), 40 + MC_1_7_10_R4(31, 1412718533, "1.7.10", "1.7.10_04", "1.7.10", "1.7.10_03", "1.7.10_04"),
41 MC_1_8_0_R0(32, 0, "1.8.0", "1.8.0", "1.8", "1.8.0"); 41 MC_1_8_0_R0(32, 0, "1.8.0", "1.8.0", "1.8", "1.8.0");
42 42
43 /** 43 /**
java/common/com/mumfrey/liteloader/core/event/EventProxy.java
@@ -146,7 +146,12 @@ public final class EventProxy @@ -146,7 +146,12 @@ public final class EventProxy
146 } 146 }
147 tpl.append(")\n\t {\n\t // handler code here\n\t }"); 147 tpl.append(")\n\t {\n\t // handler code here\n\t }");
148 148
149 - return tpl.toString(); 149 + String template = tpl.toString();
  150 + if (template.contains(", ReturnType>"))
  151 + {
  152 + template = template.replace("static void", "static <ReturnType> void");
  153 + }
  154 + return template;
150 } 155 }
151 156
152 private static boolean appendTypeName(StringBuilder tpl, Type type, String sourceClass) 157 private static boolean appendTypeName(StringBuilder tpl, Type type, String sourceClass)
@@ -160,7 +165,7 @@ public final class EventProxy @@ -160,7 +165,7 @@ public final class EventProxy
160 String typeName = type.getClassName(); 165 String typeName = type.getClassName();
161 typeName = typeName.substring(typeName.lastIndexOf('.') + 1); 166 typeName = typeName.substring(typeName.lastIndexOf('.') + 1);
162 tpl.append(typeName); 167 tpl.append(typeName);
163 - if (typeName.endsWith("ReturnEventInfo")) tpl.append('<').append(sourceClass).append(", ?>"); 168 + if (typeName.endsWith("ReturnEventInfo")) tpl.append('<').append(sourceClass).append(", ReturnType>");
164 else if (typeName.endsWith("EventInfo")) tpl.append('<').append(sourceClass).append('>'); 169 else if (typeName.endsWith("EventInfo")) tpl.append('<').append(sourceClass).append('>');
165 return false; 170 return false;
166 default: 171 default:
java/common/com/mumfrey/liteloader/core/event/HandlerList.java
@@ -25,6 +25,7 @@ import org.objectweb.asm.tree.*; @@ -25,6 +25,7 @@ import org.objectweb.asm.tree.*;
25 import com.mumfrey.liteloader.Priority; 25 import com.mumfrey.liteloader.Priority;
26 import com.mumfrey.liteloader.core.runtime.Obf; 26 import com.mumfrey.liteloader.core.runtime.Obf;
27 import com.mumfrey.liteloader.interfaces.FastIterableDeque; 27 import com.mumfrey.liteloader.interfaces.FastIterableDeque;
  28 +import com.mumfrey.liteloader.transformers.ByteCodeUtilities;
28 import com.mumfrey.liteloader.util.SortableValue; 29 import com.mumfrey.liteloader.util.SortableValue;
29 import com.mumfrey.liteloader.util.log.LiteLoaderLogger; 30 import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
30 31
@@ -923,7 +924,7 @@ public class HandlerList&lt;T&gt; extends LinkedList&lt;T&gt; implements FastIterableDeque&lt;T @@ -923,7 +924,7 @@ public class HandlerList&lt;T&gt; extends LinkedList&lt;T&gt; implements FastIterableDeque&lt;T
923 boolean isOrOperation = this.logicOp.isOr(); 924 boolean isOrOperation = this.logicOp.isOr();
924 boolean breakOnMatch = this.logicOp.breakOnMatch(); 925 boolean breakOnMatch = this.logicOp.breakOnMatch();
925 int initialValue = isOrOperation && (!this.logicOp.assumeTrue() || this.size > 0) ? Opcodes.ICONST_0 : Opcodes.ICONST_1; 926 int initialValue = isOrOperation && (!this.logicOp.assumeTrue() || this.size > 0) ? Opcodes.ICONST_0 : Opcodes.ICONST_1;
926 - int localIndex = this.getFirstLocalIndex(args); 927 + int localIndex = ByteCodeUtilities.getArgsSize(args);
927 928
928 method.instructions.add(new InsnNode(initialValue)); 929 method.instructions.add(new InsnNode(initialValue));
929 method.instructions.add(new VarInsnNode(Opcodes.ISTORE, localIndex)); 930 method.instructions.add(new VarInsnNode(Opcodes.ISTORE, localIndex));
@@ -984,13 +985,6 @@ public class HandlerList&lt;T&gt; extends LinkedList&lt;T&gt; implements FastIterableDeque&lt;T @@ -984,13 +985,6 @@ public class HandlerList&lt;T&gt; extends LinkedList&lt;T&gt; implements FastIterableDeque&lt;T
984 return argNumber; 985 return argNumber;
985 } 986 }
986 987
987 - private int getFirstLocalIndex(Type[] args)  
988 - {  
989 - int argNumber = 1;  
990 - for (Type type : args) argNumber += type.getSize();  
991 - return argNumber;  
992 - }  
993 -  
994 /** 988 /**
995 * @param baseName 989 * @param baseName
996 * @param typeName 990 * @param typeName
java/common/com/mumfrey/liteloader/core/runtime/Methods.java
1 package com.mumfrey.liteloader.core.runtime; 1 package com.mumfrey.liteloader.core.runtime;
2 2
  3 +import java.io.File;
  4 +
3 import com.mumfrey.liteloader.transformers.event.MethodInfo; 5 import com.mumfrey.liteloader.transformers.event.MethodInfo;
4 6
5 /** 7 /**
@@ -29,6 +31,11 @@ public abstract class Methods @@ -29,6 +31,11 @@ public abstract class Methods
29 public static final MethodInfo respawnPlayer = new MethodInfo(Obf.ServerConfigurationManager, Obf.respawnPlayer, Obf.EntityPlayerMP, Obf.EntityPlayerMP, Integer.TYPE, Boolean.TYPE); 31 public static final MethodInfo respawnPlayer = new MethodInfo(Obf.ServerConfigurationManager, Obf.respawnPlayer, Obf.EntityPlayerMP, Obf.EntityPlayerMP, Integer.TYPE, Boolean.TYPE);
30 public static final MethodInfo glClear = new MethodInfo(Obf.GlStateManager, Obf.clear, Void.TYPE, Integer.TYPE); 32 public static final MethodInfo glClear = new MethodInfo(Obf.GlStateManager, Obf.clear, Void.TYPE, Integer.TYPE);
31 public static final MethodInfo getProfile = new MethodInfo(Obf.Session, Obf.getProfile, Obf.GameProfile); 33 public static final MethodInfo getProfile = new MethodInfo(Obf.Session, Obf.getProfile, Obf.GameProfile);
  34 + public static final MethodInfo saveScreenshot = new MethodInfo(Obf.ScreenShotHelper, Obf.saveScreenshot, Obf.IChatComponent, File.class, String.class, Integer.TYPE, Integer.TYPE, Obf.FrameBuffer);
  35 + public static final MethodInfo isFramebufferEnabled = new MethodInfo(Obf.OpenGlHelper, Obf.isFramebufferEnabled, Boolean.TYPE);
  36 + public static final MethodInfo doRenderEntity = new MethodInfo(Obf.RenderManager, Obf.doRenderEntity, Boolean.TYPE, Obf.Entity, Double.TYPE, Double.TYPE, Double.TYPE, Float.TYPE, Float.TYPE, Boolean.TYPE);
  37 + public static final MethodInfo doRender = new MethodInfo(Obf.Render, Obf.doRender, Void.TYPE, Obf.Entity, Double.TYPE, Double.TYPE, Double.TYPE, Float.TYPE, Float.TYPE);
  38 + public static final MethodInfo doRenderShadowAndFire = new MethodInfo(Obf.Render, Obf.doRenderShadowAndFire, Void.TYPE, Obf.Entity, Double.TYPE, Double.TYPE, Double.TYPE, Float.TYPE, Float.TYPE);
32 39
33 public static final MethodInfo startSection = new MethodInfo(Obf.Profiler, Obf.startSection, Void.TYPE, String.class); 40 public static final MethodInfo startSection = new MethodInfo(Obf.Profiler, Obf.startSection, Void.TYPE, String.class);
34 public static final MethodInfo endSection = new MethodInfo(Obf.Profiler, Obf.endSection, Void.TYPE); 41 public static final MethodInfo endSection = new MethodInfo(Obf.Profiler, Obf.endSection, Void.TYPE);
java/common/com/mumfrey/liteloader/core/runtime/Obf.java
@@ -51,6 +51,12 @@ public class Obf @@ -51,6 +51,12 @@ public class Obf
51 public static final Obf GuiNewChat = new Obf("net.minecraft.client.gui.GuiNewChat", "buh" ); 51 public static final Obf GuiNewChat = new Obf("net.minecraft.client.gui.GuiNewChat", "buh" );
52 public static final Obf GlStateManager = new Obf("net.minecraft.client.renderer.GlStateManager", "cjm" ); 52 public static final Obf GlStateManager = new Obf("net.minecraft.client.renderer.GlStateManager", "cjm" );
53 public static final Obf Session = new Obf("net.minecraft.util.Session", "btw" ); 53 public static final Obf Session = new Obf("net.minecraft.util.Session", "btw" );
  54 + public static final Obf IChatComponent = new Obf("net.minecraft.util.IChatComponent", "ho" );
  55 + public static final Obf ScreenShotHelper = new Obf("net.minecraft.util.ScreenShotHelper", "btt" );
  56 + public static final Obf OpenGlHelper = new Obf("net.minecraft.client.renderer.OpenGlHelper", "dax" );
  57 + public static final Obf Entity = new Obf("net.minecraft.entity.Entity", "wv" );
  58 + public static final Obf RenderManager = new Obf("net.minecraft.client.renderer.entity.RenderManager", "cpt" );
  59 + public static final Obf Render = new Obf("net.minecraft.client.renderer.entity.Render", "cpu" );
54 60
55 // Fields 61 // Fields
56 // ----------------------------------------------------------------------------------------- 62 // -----------------------------------------------------------------------------------------
@@ -94,6 +100,11 @@ public class Obf @@ -94,6 +100,11 @@ public class Obf
94 public static final Obf clear = new Obf("func_179086_m", "m" ); 100 public static final Obf clear = new Obf("func_179086_m", "m" );
95 public static final Obf renderWorldPass = new Obf("func_175068_a", "a" ); 101 public static final Obf renderWorldPass = new Obf("func_175068_a", "a" );
96 public static final Obf getProfile = new Obf("func_148256_e", "a" ); 102 public static final Obf getProfile = new Obf("func_148256_e", "a" );
  103 + public static final Obf saveScreenshot = new Obf("func_148260_a", "a" );
  104 + public static final Obf isFramebufferEnabled = new Obf("func_148822_b", "i" );
  105 + public static final Obf doRenderEntity = new Obf("func_147939_a", "a" );
  106 + public static final Obf doRender = new Obf("func_76986_a", "a" );
  107 + public static final Obf doRenderShadowAndFire = new Obf("func_76979_b", "b" );
97 108
98 public static final int MCP = 0; 109 public static final int MCP = 0;
99 public static final int SRG = 1; 110 public static final int SRG = 1;
java/common/com/mumfrey/liteloader/interfaces/ObjectFactory.java
@@ -4,7 +4,7 @@ import net.minecraft.server.MinecraftServer; @@ -4,7 +4,7 @@ import net.minecraft.server.MinecraftServer;
4 4
5 import com.mumfrey.liteloader.common.GameEngine; 5 import com.mumfrey.liteloader.common.GameEngine;
6 import com.mumfrey.liteloader.core.ClientPluginChannels; 6 import com.mumfrey.liteloader.core.ClientPluginChannels;
7 -import com.mumfrey.liteloader.core.Events; 7 +import com.mumfrey.liteloader.core.LiteLoaderEventBroker;
8 import com.mumfrey.liteloader.core.PacketEvents; 8 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;
@@ -20,7 +20,7 @@ import com.mumfrey.liteloader.permissions.PermissionsManagerServer; @@ -20,7 +20,7 @@ import com.mumfrey.liteloader.permissions.PermissionsManagerServer;
20 */ 20 */
21 public interface ObjectFactory<TClient, TServer extends MinecraftServer> 21 public interface ObjectFactory<TClient, TServer extends MinecraftServer>
22 { 22 {
23 - public abstract Events<TClient, TServer> getEventBroker(); 23 + public abstract LiteLoaderEventBroker<TClient, TServer> getEventBroker();
24 24
25 public abstract PacketEvents getPacketEventBroker(); 25 public abstract PacketEvents getPacketEventBroker();
26 26
java/common/com/mumfrey/liteloader/modconfig/ConfigPanel.java
1 package com.mumfrey.liteloader.modconfig; 1 package com.mumfrey.liteloader.modconfig;
2 2
3 -import java.io.IOException;  
4 3
5 /** 4 /**
6 * Interface for mod config panels to implement 5 * Interface for mod config panels to implement
@@ -61,7 +60,7 @@ public interface ConfigPanel @@ -61,7 +60,7 @@ public interface ConfigPanel
61 * @param mouseY 60 * @param mouseY
62 * @param mouseButton 61 * @param mouseButton
63 */ 62 */
64 - public abstract void mousePressed(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) throws IOException; 63 + public abstract void mousePressed(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton);
65 64
66 /** 65 /**
67 * Called when a mouse button is released 66 * Called when a mouse button is released
java/common/com/mumfrey/liteloader/transformers/ByteCodeUtilities.java
@@ -74,6 +74,49 @@ public abstract class ByteCodeUtilities @@ -74,6 +74,49 @@ public abstract class ByteCodeUtilities
74 } 74 }
75 } 75 }
76 } 76 }
  77 +
  78 + /**
  79 + * Get the first variable index in the supplied method which is not an argument or "this" reference, this corresponds
  80 + * to the size of the arguments passed in to the method plus an extra spot for "this" if the method is non-static
  81 + *
  82 + * @param method
  83 + * @return
  84 + */
  85 + public static int getFirstNonArgLocalIndex(MethodNode method)
  86 + {
  87 + return ByteCodeUtilities.getFirstNonArgLocalIndex(Type.getArgumentTypes(method.desc), (method.access & Opcodes.ACC_STATIC) == 0);
  88 + }
  89 +
  90 + /**
  91 + * Get the first non-arg variable index based on the supplied arg array and whether to include the "this" reference,
  92 + * this corresponds to the size of the arguments passed in to the method plus an extra spot for "this" is specified
  93 +
  94 + * @param args
  95 + * @param includeThis
  96 + * @return
  97 + */
  98 + public static int getFirstNonArgLocalIndex(Type[] args, boolean includeThis)
  99 + {
  100 + return ByteCodeUtilities.getArgsSize(args) + (includeThis ? 1 : 0);
  101 + }
  102 +
  103 + /**
  104 + * Get the size of the specified args array in local variable terms (eg. doubles and longs take two spaces)
  105 + *
  106 + * @param args
  107 + * @return
  108 + */
  109 + public static int getArgsSize(Type[] args)
  110 + {
  111 + int size = 0;
  112 +
  113 + for (Type type : args)
  114 + {
  115 + size += type.getSize();
  116 + }
  117 +
  118 + return size;
  119 + }
77 120
78 /** 121 /**
79 * Attempts to identify available locals at an arbitrary point in the bytecode specified by node. 122 * Attempts to identify available locals at an arbitrary point in the bytecode specified by node.
@@ -121,8 +164,7 @@ public abstract class ByteCodeUtilities @@ -121,8 +164,7 @@ public abstract class ByteCodeUtilities
121 FrameNode frameNode = (FrameNode)insn; 164 FrameNode frameNode = (FrameNode)insn;
122 165
123 // localPos tracks the location in the frame node's locals list, which doesn't leave space for TOP entries 166 // localPos tracks the location in the frame node's locals list, which doesn't leave space for TOP entries
124 - int localPos = 0;  
125 - for (int framePos = 0; framePos < frame.length; framePos++) 167 + for (int localPos = 0, framePos = 0; framePos < frame.length; framePos++, localPos++)
126 { 168 {
127 // Get the local at the current position in the FrameNode's locals list 169 // Get the local at the current position in the FrameNode's locals list
128 final Object localType = (localPos < frameNode.local.size()) ? frameNode.local.get(localPos) : null; 170 final Object localType = (localPos < frameNode.local.size()) ? frameNode.local.get(localPos) : null;
@@ -163,8 +205,6 @@ public abstract class ByteCodeUtilities @@ -163,8 +205,6 @@ public abstract class ByteCodeUtilities
163 { 205 {
164 throw new RuntimeException("Invalid value " + localType + " in locals array at position " + localPos + " in " + classNode.name + "." + method.name + method.desc); 206 throw new RuntimeException("Invalid value " + localType + " in locals array at position " + localPos + " in " + classNode.name + "." + method.name + method.desc);
165 } 207 }
166 -  
167 - localPos++;  
168 } 208 }
169 } 209 }
170 else if (insn instanceof VarInsnNode) 210 else if (insn instanceof VarInsnNode)
java/common/com/mumfrey/liteloader/transformers/event/Event.java
@@ -312,11 +312,11 @@ public class Event implements Comparable&lt;Event&gt; @@ -312,11 +312,11 @@ public class Event implements Comparable&lt;Event&gt;
312 // Pre-flight checks 312 // Pre-flight checks
313 this.validate(injectionPoint, cancellable, globalEventID); 313 this.validate(injectionPoint, cancellable, globalEventID);
314 314
315 - Type[] argumentTypes = Type.getArgumentTypes(this.method.desc);  
316 - int initialFrameSize = argumentTypes.length + (this.methodIsStatic ? 0 : 1); 315 + Type[] arguments = Type.getArgumentTypes(this.method.desc);
  316 + int initialFrameSize = ByteCodeUtilities.getFirstNonArgLocalIndex(arguments, !this.methodIsStatic);
317 317
318 boolean doCaptureLocals = captureLocals && locals != null && locals.length > initialFrameSize; 318 boolean doCaptureLocals = captureLocals && locals != null && locals.length > initialFrameSize;
319 - String eventDescriptor = this.generateEventDescriptor(doCaptureLocals, locals, argumentTypes, initialFrameSize); 319 + String eventDescriptor = this.generateEventDescriptor(doCaptureLocals, locals, arguments, initialFrameSize);
320 320
321 // Create the handler delegate method 321 // Create the handler delegate method
322 MethodNode handler = new MethodNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC, Event.getHandlerName(globalEventID), eventDescriptor, null, null); 322 MethodNode handler = new MethodNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC, Event.getHandlerName(globalEventID), eventDescriptor, null, null);
@@ -324,7 +324,7 @@ public class Event implements Comparable&lt;Event&gt; @@ -324,7 +324,7 @@ public class Event implements Comparable&lt;Event&gt;
324 324
325 LiteLoaderLogger.debug("Event %s is spawning handler %s in class %s", this.name, handler.name, Event.getActiveProxyRef()); 325 LiteLoaderLogger.debug("Event %s is spawning handler %s in class %s", this.name, handler.name, Event.getActiveProxyRef());
326 326
327 - int ctorMAXS = 0, invokeMAXS = argumentTypes.length + (doCaptureLocals ? locals.length - initialFrameSize : 0); 327 + int ctorMAXS = 0, invokeMAXS = arguments.length + (doCaptureLocals ? locals.length - initialFrameSize : 0);
328 int eventInfoVar = this.method.maxLocals++; 328 int eventInfoVar = this.method.maxLocals++;
329 329
330 InsnList insns = new InsnList(); 330 InsnList insns = new InsnList();
@@ -332,12 +332,12 @@ public class Event implements Comparable&lt;Event&gt; @@ -332,12 +332,12 @@ public class Event implements Comparable&lt;Event&gt;
332 // Instance the EventInfo for this event 332 // Instance the EventInfo for this event
333 insns.add(new TypeInsnNode(Opcodes.NEW, this.eventInfoClass)); ctorMAXS++; 333 insns.add(new TypeInsnNode(Opcodes.NEW, this.eventInfoClass)); ctorMAXS++;
334 insns.add(new InsnNode(Opcodes.DUP)); ctorMAXS++; invokeMAXS++; 334 insns.add(new InsnNode(Opcodes.DUP)); ctorMAXS++; invokeMAXS++;
335 - ctorMAXS += invokeEventInfoConstructor(insns, cancellable); 335 + ctorMAXS += this.invokeEventInfoConstructor(insns, cancellable);
336 insns.add(new VarInsnNode(Opcodes.ASTORE, eventInfoVar)); 336 insns.add(new VarInsnNode(Opcodes.ASTORE, eventInfoVar));
337 337
338 // Call the event handler method in the proxy 338 // Call the event handler method in the proxy
339 insns.add(new VarInsnNode(Opcodes.ALOAD, eventInfoVar)); 339 insns.add(new VarInsnNode(Opcodes.ALOAD, eventInfoVar));
340 - ByteCodeUtilities.loadArgs(argumentTypes, insns, this.methodIsStatic ? 0 : 1); 340 + ByteCodeUtilities.loadArgs(arguments, insns, this.methodIsStatic ? 0 : 1);
341 if (doCaptureLocals) 341 if (doCaptureLocals)
342 { 342 {
343 ByteCodeUtilities.loadLocals(locals, insns, initialFrameSize); 343 ByteCodeUtilities.loadLocals(locals, insns, initialFrameSize);
@@ -474,6 +474,14 @@ public class Event implements Comparable&lt;Event&gt; @@ -474,6 +474,14 @@ public class Event implements Comparable&lt;Event&gt;
474 } 474 }
475 475
476 /** 476 /**
  477 + * Get currently registered listeners for this event
  478 + */
  479 + public Set<MethodInfo> getListeners()
  480 + {
  481 + return Collections.<MethodInfo>unmodifiableSet(this.listeners);
  482 + }
  483 +
  484 + /**
477 * Get an event by name (case insensitive) 485 * Get an event by name (case insensitive)
478 * 486 *
479 * @param eventName 487 * @param eventName
@@ -487,28 +495,6 @@ public class Event implements Comparable&lt;Event&gt; @@ -487,28 +495,6 @@ public class Event implements Comparable&lt;Event&gt;
487 495
488 return null; 496 return null;
489 } 497 }
490 -  
491 - /**  
492 - * Get all of the listeners for an event by name  
493 - *  
494 - * @param eventName  
495 - * @return  
496 - */  
497 - static Set<MethodInfo> getEventListeners(String eventName)  
498 - {  
499 - return Event.getEventListeners(Event.getEvent(eventName));  
500 - }  
501 -  
502 - /**  
503 - * Get all of an event's listeners  
504 - *  
505 - * @param event  
506 - * @return  
507 - */  
508 - static Set<MethodInfo> getEventListeners(Event event)  
509 - {  
510 - return event == null ? null : Collections.unmodifiableSet(event.listeners);  
511 - }  
512 498
513 /** 499 /**
514 * Populates the event proxy class with delegating methods for all injected events 500 * Populates the event proxy class with delegating methods for all injected events
java/common/com/mumfrey/liteloader/transformers/event/EventTransformer.java
@@ -10,7 +10,6 @@ import java.util.Set; @@ -10,7 +10,6 @@ import java.util.Set;
10 import java.util.TreeSet; 10 import java.util.TreeSet;
11 11
12 import org.objectweb.asm.ClassWriter; 12 import org.objectweb.asm.ClassWriter;
13 -import org.objectweb.asm.Opcodes;  
14 import org.objectweb.asm.Type; 13 import org.objectweb.asm.Type;
15 import org.objectweb.asm.tree.AbstractInsnNode; 14 import org.objectweb.asm.tree.AbstractInsnNode;
16 import org.objectweb.asm.tree.ClassNode; 15 import org.objectweb.asm.tree.ClassNode;
@@ -283,7 +282,7 @@ public final class EventTransformer extends ClassTransformer @@ -283,7 +282,7 @@ public final class EventTransformer extends ClassTransformer
283 injection.setLocals(locals); 282 injection.setLocals(locals);
284 if (injectionPoint.logLocals()) 283 if (injectionPoint.logLocals())
285 { 284 {
286 - int startPos = ((method.access & Opcodes.ACC_STATIC) == 0 ? 1 : 0) + Type.getArgumentTypes(method.desc).length; 285 + int startPos = ByteCodeUtilities.getFirstNonArgLocalIndex(method);
287 286
288 LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); 287 LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE);
289 LiteLoaderLogger.debug("Logging local variables for " + injectionPoint.getClass().getSimpleName()); 288 LiteLoaderLogger.debug("Logging local variables for " + injectionPoint.getClass().getSimpleName());