Commit 96db8836297371a3bd131567d78da1f1b4ee0129

Authored by Mumfrey
1 parent c24f0490

PacketTransformers are deprecated, adding PacketHandler framework

Showing 29 changed files with 879 additions and 527 deletions
java/client/com/mumfrey/liteloader/client/CallbackProxyClient.java
... ... @@ -7,25 +7,12 @@ import net.minecraft.client.renderer.EntityRenderer;
7 7 import net.minecraft.client.renderer.OpenGlHelper;
8 8 import net.minecraft.client.shader.Framebuffer;
9 9 import net.minecraft.entity.player.EntityPlayerMP;
10   -import net.minecraft.network.INetHandler;
11 10 import net.minecraft.network.NetworkManager;
12   -import net.minecraft.network.login.INetHandlerLoginClient;
13   -import net.minecraft.network.login.server.S02PacketLoginSuccess;
14   -import net.minecraft.network.play.INetHandlerPlayClient;
15   -import net.minecraft.network.play.INetHandlerPlayServer;
16   -import net.minecraft.network.play.client.C01PacketChatMessage;
17   -import net.minecraft.network.play.client.C17PacketCustomPayload;
18   -import net.minecraft.network.play.server.S01PacketJoinGame;
19   -import net.minecraft.network.play.server.S02PacketChat;
20   -import net.minecraft.network.play.server.S3FPacketCustomPayload;
21 11 import net.minecraft.server.integrated.IntegratedServer;
22 12 import net.minecraft.server.management.ServerConfigurationManager;
23 13 import net.minecraft.world.WorldSettings;
24 14  
25 15 import com.mojang.authlib.GameProfile;
26   -import com.mumfrey.liteloader.core.ClientPluginChannels;
27   -import com.mumfrey.liteloader.core.LiteLoader;
28   -import com.mumfrey.liteloader.core.ServerPluginChannels;
29 16 import com.mumfrey.liteloader.transformers.event.EventInfo;
30 17 import com.mumfrey.liteloader.transformers.event.ReturnEventInfo;
31 18  
... ... @@ -49,83 +36,6 @@ public class CallbackProxyClient
49 36  
50 37 private static boolean renderingFBO;
51 38  
52   - public static void handleLoginSuccessPacket(INetHandler netHandler, S02PacketLoginSuccess packet)
53   - {
54   - ((INetHandlerLoginClient)netHandler).handleLoginSuccess(packet);
55   - CallbackProxyClient.events.onPostLogin((INetHandlerLoginClient)netHandler, packet);
56   - }
57   -
58   - /**
59   - * S02PacketChat::processPacket()
60   - *
61   - * @param netHandler
62   - * @param packet
63   - */
64   - public static void handleChatPacket(INetHandler netHandler, S02PacketChat packet)
65   - {
66   - if (CallbackProxyClient.events.onChat(packet))
67   - {
68   - ((INetHandlerPlayClient)netHandler).handleChat(packet);
69   - }
70   - }
71   -
72   - /**
73   - * S02PacketChat::processPacket()
74   - *
75   - * @param netHandler
76   - * @param packet
77   - */
78   - public static void handleServerChatPacket(INetHandler netHandler, C01PacketChatMessage packet)
79   - {
80   - if (CallbackProxyClient.events.onServerChat((INetHandlerPlayServer)netHandler, packet))
81   - {
82   - ((INetHandlerPlayServer)netHandler).processChatMessage(packet);
83   - }
84   - }
85   -
86   - /**
87   - * S01PacketJoinGame::processPacket()
88   - *
89   - * @param netHandler
90   - * @param packet
91   - */
92   - public static void handleJoinGamePacket(INetHandler netHandler, S01PacketJoinGame packet)
93   - {
94   - if (CallbackProxyClient.events.onPreJoinGame(netHandler, packet))
95   - {
96   - ((INetHandlerPlayClient)netHandler).handleJoinGame(packet);
97   - CallbackProxyClient.events.onJoinGame(netHandler, packet);
98   - }
99   - }
100   -
101   - /**
102   - * S3FPacketCustomPayload::processPacket()
103   - *
104   - * @param netHandler
105   - * @param packet
106   - */
107   - public static void handleCustomPayloadPacket(INetHandler netHandler, S3FPacketCustomPayload packet)
108   - {
109   - ((INetHandlerPlayClient)netHandler).handleCustomPayload(packet);;
110   -
111   - ClientPluginChannels pluginChannels = LiteLoader.getClientPluginChannels();
112   - pluginChannels.onPluginChannelMessage(packet);
113   - }
114   -
115   - /**
116   - * C17PacketCustomPayload::processPacket()
117   - *
118   - * @param netHandler
119   - * @param packet
120   - */
121   - public static void handleCustomPayloadPacket(INetHandler netHandler, C17PacketCustomPayload packet)
122   - {
123   - ((INetHandlerPlayServer)netHandler).processVanilla250Packet(packet);;
124   -
125   - ServerPluginChannels pluginChannels = LiteLoader.getServerPluginChannels();
126   - pluginChannels.onPluginChannelMessage((INetHandlerPlayServer)netHandler, packet);
127   - }
128   -
129 39 public static void onStartupComplete(EventInfo<Minecraft> e)
130 40 {
131 41 CallbackProxyClient.events = ClientEvents.getInstance();
... ...
java/client/com/mumfrey/liteloader/client/ClientEvents.java
... ... @@ -5,15 +5,9 @@ import net.minecraft.client.entity.EntityClientPlayerMP;
5 5 import net.minecraft.client.gui.GuiNewChat;
6 6 import net.minecraft.client.gui.ScaledResolution;
7 7 import net.minecraft.client.shader.Framebuffer;
8   -import net.minecraft.network.INetHandler;
9   -import net.minecraft.network.login.INetHandlerLoginClient;
10   -import net.minecraft.network.login.server.S02PacketLoginSuccess;
11 8 import net.minecraft.network.play.client.C01PacketChatMessage;
12   -import net.minecraft.network.play.server.S01PacketJoinGame;
13   -import net.minecraft.network.play.server.S02PacketChat;
14 9 import net.minecraft.profiler.Profiler;
15 10 import net.minecraft.server.integrated.IntegratedServer;
16   -import net.minecraft.util.IChatComponent;
17 11 import net.minecraft.util.Timer;
18 12  
19 13 import org.lwjgl.input.Mouse;
... ... @@ -23,7 +17,6 @@ import com.mumfrey.liteloader.client.gen.GenProfiler;
23 17 import com.mumfrey.liteloader.client.overlays.IMinecraft;
24 18 import com.mumfrey.liteloader.client.util.PrivateFields;
25 19 import com.mumfrey.liteloader.common.LoadingProgress;
26   -import com.mumfrey.liteloader.core.ClientPluginChannels;
27 20 import com.mumfrey.liteloader.core.Events;
28 21 import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate;
29 22 import com.mumfrey.liteloader.core.LiteLoader;
... ... @@ -90,15 +83,10 @@ public class ClientEvents extends Events&lt;Minecraft, IntegratedServer&gt;
90 83 private FastIterableDeque<PostRenderListener> postRenderListeners = new HandlerList<PostRenderListener>(PostRenderListener.class);
91 84 private FastIterableDeque<HUDRenderListener> hudRenderListeners = new HandlerList<HUDRenderListener>(HUDRenderListener.class);
92 85 private FastIterableDeque<ChatRenderListener> chatRenderListeners = new HandlerList<ChatRenderListener>(ChatRenderListener.class);
93   - private FastIterableDeque<ChatListener> chatListeners = new HandlerList<ChatListener>(ChatListener.class);
94   - private FastIterableDeque<PostLoginListener> postLoginListeners = new HandlerList<PostLoginListener>(PostLoginListener.class);
95   - private FastIterableDeque<JoinGameListener> joinGameListeners = new HandlerList<JoinGameListener>(JoinGameListener.class);
96 86 private FastIterableDeque<OutboundChatListener> outboundChatListeners = new HandlerList<OutboundChatListener>(OutboundChatListener.class);
97 87 private FastIterableDeque<ViewportListener> viewportListeners = new HandlerList<ViewportListener>(ViewportListener.class);
98 88 private FastIterableDeque<FrameBufferListener> frameBufferListeners = new HandlerList<FrameBufferListener>(FrameBufferListener.class);
99 89 private FastIterableDeque<InitCompleteListener> initListeners = new HandlerList<InitCompleteListener>(InitCompleteListener.class);
100   - private FastIterableDeque<ChatFilter> chatFilters = new HandlerList<ChatFilter>(ChatFilter.class, ReturnLogicOp.AND_BREAK_ON_FALSE);
101   - private FastIterableDeque<PreJoinGameListener> preJoinGameListeners = new HandlerList<PreJoinGameListener>(PreJoinGameListener.class, ReturnLogicOp.OR);
102 90 private FastIterableDeque<OutboundChatFilter> outboundChatFilters = new HandlerList<OutboundChatFilter>(OutboundChatFilter.class, ReturnLogicOp.AND);
103 91  
104 92 @SuppressWarnings("cast")
... ... @@ -141,15 +129,10 @@ public class ClientEvents extends Events&lt;Minecraft, IntegratedServer&gt;
141 129 delegate.registerInterface(PostRenderListener.class);
142 130 delegate.registerInterface(HUDRenderListener.class);
143 131 delegate.registerInterface(ChatRenderListener.class);
144   - delegate.registerInterface(ChatListener.class);
145   - delegate.registerInterface(PostLoginListener.class);
146   - delegate.registerInterface(JoinGameListener.class);
147 132 delegate.registerInterface(OutboundChatListener.class);
148 133 delegate.registerInterface(ViewportListener.class);
149 134 delegate.registerInterface(FrameBufferListener.class);
150 135 delegate.registerInterface(InitCompleteListener.class);
151   - delegate.registerInterface(ChatFilter.class);
152   - delegate.registerInterface(PreJoinGameListener.class);
153 136 delegate.registerInterface(OutboundChatFilter.class);
154 137 }
155 138  
... ... @@ -235,43 +218,6 @@ public class ClientEvents extends Events&lt;Minecraft, IntegratedServer&gt;
235 218 }
236 219  
237 220 /**
238   - * @deprecated use LiteLoader.getInterfaceManager().registerListener(listener); instead
239   - * @param chatFilter
240   - */
241   - @Deprecated
242   - @Override
243   - public void addChatFilter(Object chatFilter)
244   - {
245   - if (chatFilter instanceof ChatFilter)
246   - {
247   - this.addChatFilter((ChatFilter)chatFilter);
248   - }
249   - }
250   -
251   - /**
252   - * @param chatFilter
253   - */
254   - public void addChatFilter(ChatFilter chatFilter)
255   - {
256   - this.chatFilters.add(chatFilter);
257   - }
258   -
259   - /**
260   - * @param chatListener
261   - */
262   - public void addChatListener(ChatListener chatListener)
263   - {
264   - if (chatListener instanceof ChatFilter)
265   - {
266   - LiteLoaderLogger.warning("Interface error initialising mod '%1s'. A mod implementing ChatFilter and ChatListener is not supported! Remove one of these interfaces", chatListener.getName());
267   - }
268   - else
269   - {
270   - this.chatListeners.add(chatListener);
271   - }
272   - }
273   -
274   - /**
275 221 * @param chatRenderListener
276 222 */
277 223 public void addChatRenderListener(ChatRenderListener chatRenderListener)
... ... @@ -286,30 +232,6 @@ public class ClientEvents extends Events&lt;Minecraft, IntegratedServer&gt;
286 232 {
287 233 this.hudRenderListeners.add(hudRenderListener);
288 234 }
289   -
290   - /**
291   - * @param postLoginListener
292   - */
293   - public void addPreJoinGameListener(PostLoginListener postLoginListener)
294   - {
295   - this.postLoginListeners.add(postLoginListener);
296   - }
297   -
298   - /**
299   - * @param joinGameListener
300   - */
301   - public void addPreJoinGameListener(PreJoinGameListener joinGameListener)
302   - {
303   - this.preJoinGameListeners.add(joinGameListener);
304   - }
305   -
306   - /**
307   - * @param joinGameListener
308   - */
309   - public void addJoinGameListener(JoinGameListener joinGameListener)
310   - {
311   - this.joinGameListeners.add(joinGameListener);
312   - }
313 235  
314 236 /**
315 237 * @param outboundChatListener
... ... @@ -548,41 +470,6 @@ public class ClientEvents extends Events&lt;Minecraft, IntegratedServer&gt;
548 470  
549 471 this.profiler.endSection();
550 472 }
551   -
552   - /**
553   - * Callback from the chat hook
554   - *
555   - * @param chatPacket
556   - * @return
557   - */
558   - boolean onChat(S02PacketChat chatPacket)
559   - {
560   - if (chatPacket.func_148915_c() == null)
561   - return true;
562   -
563   - IChatComponent chat = chatPacket.func_148915_c();
564   - String message = chat.getFormattedText();
565   -
566   - // Chat filters get a stab at the chat first, if any filter returns
567   - // false the chat is discarded
568   - for (ChatFilter chatFilter : this.chatFilters)
569   - {
570   - if (chatFilter.onChat(chatPacket, chat, message))
571   - {
572   - chat = chatPacket.func_148915_c();
573   - message = chat.getFormattedText();
574   - }
575   - else
576   - {
577   - return false;
578   - }
579   - }
580   -
581   - // Chat listeners get the chat if no filter removed it
582   - this.chatListeners.all().onChat(chat, message);
583   -
584   - return true;
585   - }
586 473  
587 474 /**
588 475 * @param packet
... ... @@ -605,53 +492,6 @@ public class ClientEvents extends Events&lt;Minecraft, IntegratedServer&gt;
605 492 }
606 493  
607 494 /**
608   - * @param netHandler
609   - * @param loginPacket
610   - */
611   - void onPostLogin(INetHandlerLoginClient netHandler, S02PacketLoginSuccess loginPacket)
612   - {
613   - ClientPluginChannels clientPluginChannels = LiteLoader.getClientPluginChannels();
614   - if (clientPluginChannels instanceof ClientPluginChannelsClient)
615   - {
616   - ((ClientPluginChannelsClient)clientPluginChannels).onPostLogin(netHandler, loginPacket);
617   - }
618   -
619   - this.postLoginListeners.all().onPostLogin(netHandler, loginPacket);
620   - }
621   -
622   - /**
623   - * Pre join game callback from the login hook
624   - *
625   - * @param netHandler
626   - * @param hookLogin
627   - * @return
628   - */
629   - boolean onPreJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket)
630   - {
631   - return !this.preJoinGameListeners.all().onPreJoinGame(netHandler, loginPacket);
632   - }
633   -
634   - /**
635   - * Callback from the join game hook
636   - *
637   - * @param netHandler
638   - * @param loginPacket
639   - */
640   - @Override
641   - protected void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket)
642   - {
643   - super.onJoinGame(netHandler, loginPacket);
644   -
645   - ClientPluginChannels clientPluginChannels = LiteLoader.getClientPluginChannels();
646   - if (clientPluginChannels instanceof ClientPluginChannelsClient)
647   - {
648   - ((ClientPluginChannelsClient)clientPluginChannels).onJoinGame(netHandler, loginPacket);
649   - }
650   -
651   - this.joinGameListeners.all().onJoinGame(netHandler, loginPacket);
652   - }
653   -
654   - /**
655 495 * @param framebuffer
656 496 */
657 497 void preRenderFBO(Framebuffer framebuffer)
... ...
java/client/com/mumfrey/liteloader/client/PacketEventsClient.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.client;
  2 +
  3 +import net.minecraft.network.INetHandler;
  4 +import net.minecraft.network.Packet;
  5 +import net.minecraft.network.login.INetHandlerLoginClient;
  6 +import net.minecraft.network.login.server.S02PacketLoginSuccess;
  7 +import net.minecraft.network.play.INetHandlerPlayClient;
  8 +import net.minecraft.network.play.server.S01PacketJoinGame;
  9 +import net.minecraft.network.play.server.S02PacketChat;
  10 +import net.minecraft.util.IChatComponent;
  11 +
  12 +import com.mumfrey.liteloader.ChatFilter;
  13 +import com.mumfrey.liteloader.ChatListener;
  14 +import com.mumfrey.liteloader.PostLoginListener;
  15 +import com.mumfrey.liteloader.PreJoinGameListener;
  16 +import com.mumfrey.liteloader.common.transformers.PacketEventInfo;
  17 +import com.mumfrey.liteloader.core.ClientPluginChannels;
  18 +import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate;
  19 +import com.mumfrey.liteloader.core.LiteLoader;
  20 +import com.mumfrey.liteloader.core.PacketEvents;
  21 +import com.mumfrey.liteloader.core.event.HandlerList;
  22 +import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp;
  23 +import com.mumfrey.liteloader.interfaces.FastIterableDeque;
  24 +import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
  25 +
  26 +/**
  27 + * Client-side packet event handlers
  28 + *
  29 + * @author Adam Mummery-Smith
  30 + */
  31 +public class PacketEventsClient extends PacketEvents
  32 +{
  33 + private FastIterableDeque<ChatListener> chatListeners = new HandlerList<ChatListener>(ChatListener.class);
  34 + private FastIterableDeque<ChatFilter> chatFilters = new HandlerList<ChatFilter>(ChatFilter.class, ReturnLogicOp.AND_BREAK_ON_FALSE);
  35 + private FastIterableDeque<PreJoinGameListener> preJoinGameListeners = new HandlerList<PreJoinGameListener>(PreJoinGameListener.class, ReturnLogicOp.OR);
  36 + private FastIterableDeque<PostLoginListener> postLoginListeners = new HandlerList<PostLoginListener>(PostLoginListener.class);
  37 +
  38 + @Override
  39 + public void registerInterfaces(InterfaceRegistrationDelegate delegate)
  40 + {
  41 + super.registerInterfaces(delegate);
  42 +
  43 + delegate.registerInterface(ChatListener.class);
  44 + delegate.registerInterface(ChatFilter.class);
  45 + delegate.registerInterface(PreJoinGameListener.class);
  46 + delegate.registerInterface(PostLoginListener.class);
  47 + }
  48 +
  49 + /**
  50 + * @param chatFilter
  51 + */
  52 + public void registerChatFilter(ChatFilter chatFilter)
  53 + {
  54 + this.chatFilters.add(chatFilter);
  55 + }
  56 +
  57 + /**
  58 + * @param chatListener
  59 + */
  60 + public void registerChatListener(ChatListener chatListener)
  61 + {
  62 + if (chatListener instanceof ChatFilter)
  63 + {
  64 + LiteLoaderLogger.warning("Interface error initialising mod '%1s'. A mod implementing ChatFilter and ChatListener is not supported! Remove one of these interfaces", chatListener.getName());
  65 + }
  66 + else
  67 + {
  68 + this.chatListeners.add(chatListener);
  69 + }
  70 + }
  71 +
  72 + /**
  73 + * @param joinGameListener
  74 + */
  75 + public void registerPreJoinGameListener(PreJoinGameListener joinGameListener)
  76 + {
  77 + this.preJoinGameListeners.add(joinGameListener);
  78 + }
  79 +
  80 + /**
  81 + * @param postLoginListener
  82 + */
  83 + public void registerPostLoginListener(PostLoginListener postLoginListener)
  84 + {
  85 + this.postLoginListeners.add(postLoginListener);
  86 + }
  87 +
  88 + /* (non-Javadoc)
  89 + * @see com.mumfrey.liteloader.core.PacketEvents#handlePacket(com.mumfrey.liteloader.common.transformers.PacketEventInfo, net.minecraft.network.INetHandler, net.minecraft.network.play.server.S01PacketJoinGame)
  90 + */
  91 + @Override
  92 + protected void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, S01PacketJoinGame packet)
  93 + {
  94 + if (!(netHandler instanceof INetHandlerPlayClient))
  95 + {
  96 + return;
  97 + }
  98 +
  99 + e.cancel();
  100 +
  101 + if (this.preJoinGameListeners.all().onPreJoinGame(netHandler, packet))
  102 + {
  103 + return;
  104 + }
  105 +
  106 + ((INetHandlerPlayClient)netHandler).handleJoinGame(packet);
  107 +
  108 + super.handlePacket(e, netHandler, packet);
  109 +
  110 + ClientPluginChannels clientPluginChannels = LiteLoader.getClientPluginChannels();
  111 + if (clientPluginChannels instanceof ClientPluginChannelsClient)
  112 + {
  113 + ((ClientPluginChannelsClient)clientPluginChannels).onJoinGame(netHandler, packet);
  114 + }
  115 + }
  116 +
  117 + /* (non-Javadoc)
  118 + * @see com.mumfrey.liteloader.core.PacketEvents#handlePacket(com.mumfrey.liteloader.common.transformers.PacketEventInfo, net.minecraft.network.INetHandler, net.minecraft.network.login.server.S02PacketLoginSuccess)
  119 + */
  120 + @Override
  121 + protected void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, S02PacketLoginSuccess packet)
  122 + {
  123 + if (netHandler instanceof INetHandlerLoginClient)
  124 + {
  125 + INetHandlerLoginClient netHandlerLoginClient = (INetHandlerLoginClient)netHandler;
  126 +
  127 + ClientPluginChannels clientPluginChannels = LiteLoader.getClientPluginChannels();
  128 + if (clientPluginChannels instanceof ClientPluginChannelsClient)
  129 + {
  130 + ((ClientPluginChannelsClient)clientPluginChannels).onPostLogin(netHandlerLoginClient, packet);
  131 + }
  132 +
  133 + this.postLoginListeners.all().onPostLogin(netHandlerLoginClient, packet);
  134 + }
  135 + }
  136 +
  137 + /* (non-Javadoc)
  138 + * @see com.mumfrey.liteloader.core.PacketEvents#handlePacket(com.mumfrey.liteloader.common.transformers.PacketEventInfo, net.minecraft.network.INetHandler, net.minecraft.network.play.server.S02PacketChat)
  139 + */
  140 + @Override
  141 + protected void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, S02PacketChat packet)
  142 + {
  143 + if (packet.func_148915_c() == null)
  144 + return;
  145 +
  146 + IChatComponent chat = packet.func_148915_c();
  147 + String message = chat.getFormattedText();
  148 +
  149 + // Chat filters get a stab at the chat first, if any filter returns
  150 + // false the chat is discarded
  151 + for (ChatFilter chatFilter : this.chatFilters)
  152 + {
  153 + if (chatFilter.onChat(packet, chat, message))
  154 + {
  155 + chat = packet.func_148915_c();
  156 + message = chat.getFormattedText();
  157 + }
  158 + else
  159 + {
  160 + e.cancel();
  161 + return;
  162 + }
  163 + }
  164 +
  165 + // Chat listeners get the chat if no filter removed it
  166 + this.chatListeners.all().onChat(chat, message);
  167 + }
  168 +}
... ...
java/client/com/mumfrey/liteloader/client/api/LiteLoaderCoreAPIClient.java
... ... @@ -32,18 +32,12 @@ public class LiteLoaderCoreAPIClient extends LiteLoaderCoreAPI
32 32 };
33 33  
34 34 private static final String[] requiredDownstreamTransformers = {
  35 + LiteLoaderCoreAPI.PKG_LITELOADER_COMMON + ".transformers.LiteLoaderPacketTransformer",
35 36 LiteLoaderCoreAPIClient.PKG_LITELOADER_CLIENT + ".transformers.LiteLoaderEventInjectionTransformer",
36 37 LiteLoaderCoreAPIClient.PKG_LITELOADER_CLIENT + ".transformers.MinecraftOverlayTransformer"
37 38 };
38 39  
39   - private static final String[] defaultPacketTransformers = {
40   - LiteLoaderCoreAPIClient.PKG_LITELOADER_CLIENT + ".transformers.LoginSuccessPacketTransformer",
41   - LiteLoaderCoreAPIClient.PKG_LITELOADER_CLIENT + ".transformers.ChatPacketTransformer",
42   - LiteLoaderCoreAPIClient.PKG_LITELOADER_CLIENT + ".transformers.JoinGamePacketTransformer",
43   - LiteLoaderCoreAPIClient.PKG_LITELOADER_CLIENT + ".transformers.CustomPayloadPacketTransformer",
44   - LiteLoaderCoreAPIClient.PKG_LITELOADER_CLIENT + ".transformers.ServerChatPacketTransformer",
45   - LiteLoaderCoreAPIClient.PKG_LITELOADER_CLIENT + ".transformers.ServerCustomPayloadPacketTransformer"
46   - };
  40 + private static final String[] defaultPacketTransformers = {};
47 41  
48 42 private ObjectFactory<Minecraft, IntegratedServer> objectFactory;
49 43  
... ... @@ -112,6 +106,7 @@ public class LiteLoaderCoreAPIClient extends LiteLoaderCoreAPI
112 106 return ImmutableList.<InterfaceProvider>of
113 107 (
114 108 objectFactory.getEventBroker(),
  109 + objectFactory.getPacketEventBroker(),
115 110 objectFactory.getClientPluginChannels(),
116 111 objectFactory.getServerPluginChannels(),
117 112 MessageBus.getInstance()
... ...
java/client/com/mumfrey/liteloader/client/api/ObjectFactoryClient.java
... ... @@ -8,11 +8,13 @@ import com.mumfrey.liteloader.client.ClientEvents;
8 8 import com.mumfrey.liteloader.client.ClientPluginChannelsClient;
9 9 import com.mumfrey.liteloader.client.GameEngineClient;
10 10 import com.mumfrey.liteloader.client.LiteLoaderPanelManager;
  11 +import com.mumfrey.liteloader.client.PacketEventsClient;
11 12 import com.mumfrey.liteloader.client.gui.startup.LoadingBar;
12 13 import com.mumfrey.liteloader.common.GameEngine;
13 14 import com.mumfrey.liteloader.core.ClientPluginChannels;
14 15 import com.mumfrey.liteloader.core.Events;
15 16 import com.mumfrey.liteloader.core.LiteLoader;
  17 +import com.mumfrey.liteloader.core.PacketEvents;
16 18 import com.mumfrey.liteloader.core.ServerPluginChannels;
17 19 import com.mumfrey.liteloader.interfaces.PanelManager;
18 20 import com.mumfrey.liteloader.interfaces.ObjectFactory;
... ... @@ -33,6 +35,8 @@ class ObjectFactoryClient implements ObjectFactory&lt;Minecraft, IntegratedServer&gt;
33 35 private LoaderProperties properties;
34 36  
35 37 private ClientEvents clientEvents;
  38 +
  39 + private PacketEventsClient clientPacketEvents;
36 40  
37 41 private GameEngineClient engine;
38 42  
... ... @@ -60,6 +64,17 @@ class ObjectFactoryClient implements ObjectFactory&lt;Minecraft, IntegratedServer&gt;
60 64 }
61 65  
62 66 @Override
  67 + public PacketEvents getPacketEventBroker()
  68 + {
  69 + if (this.clientPacketEvents == null)
  70 + {
  71 + this.clientPacketEvents = new PacketEventsClient();
  72 + }
  73 +
  74 + return this.clientPacketEvents;
  75 + }
  76 +
  77 + @Override
63 78 public GameEngine<Minecraft, IntegratedServer> getGameEngine()
64 79 {
65 80 if (this.engine == null)
... ...
java/client/com/mumfrey/liteloader/client/transformers/ChatPacketTransformer.java deleted 100644 โ†’ 0
1   -package com.mumfrey.liteloader.client.transformers;
2   -
3   -import com.mumfrey.liteloader.core.runtime.Obf;
4   -import com.mumfrey.liteloader.transformers.PacketTransformer;
5   -
6   -/**
7   - * Transformer for S02PacketChat
8   - *
9   - * @author Adam Mummery-Smith
10   - */
11   -public class ChatPacketTransformer extends PacketTransformer
12   -{
13   - private static boolean injected = false;
14   -
15   - public ChatPacketTransformer()
16   - {
17   - super(Obf.S02PacketChat, Obf.CallbackProxyClient.name, "handleChatPacket", 1000);
18   - }
19   -
20   - @Override
21   - protected void notifyInjectionFailed()
22   - {
23   - }
24   -
25   - @Override
26   - protected void notifyInjected()
27   - {
28   - ChatPacketTransformer.injected = true;
29   - }
30   -
31   - public static boolean isInjected()
32   - {
33   - return ChatPacketTransformer.injected;
34   - }
35   -}
java/client/com/mumfrey/liteloader/client/transformers/CustomPayloadPacketTransformer.java deleted 100644 โ†’ 0
1   -package com.mumfrey.liteloader.client.transformers;
2   -
3   -import com.mumfrey.liteloader.core.runtime.Obf;
4   -import com.mumfrey.liteloader.transformers.PacketTransformer;
5   -
6   -/**
7   - * Transformer for S3FPacketCustomPayload
8   - *
9   - * @author Adam Mummery-Smith
10   - */
11   -public class CustomPayloadPacketTransformer extends PacketTransformer
12   -{
13   - private static boolean injected = false;
14   -
15   - public CustomPayloadPacketTransformer()
16   - {
17   - super(Obf.S3FPacketCustomPayload, Obf.CallbackProxyClient.name, "handleCustomPayloadPacket", 1000);
18   - }
19   -
20   - @Override
21   - protected void notifyInjectionFailed()
22   - {
23   - }
24   -
25   - @Override
26   - protected void notifyInjected()
27   - {
28   - CustomPayloadPacketTransformer.injected = true;
29   - }
30   -
31   - public static boolean isInjected()
32   - {
33   - return CustomPayloadPacketTransformer.injected;
34   - }
35   -}
java/client/com/mumfrey/liteloader/client/transformers/JoinGamePacketTransformer.java deleted 100644 โ†’ 0
1   -package com.mumfrey.liteloader.client.transformers;
2   -
3   -import com.mumfrey.liteloader.core.runtime.Obf;
4   -import com.mumfrey.liteloader.transformers.PacketTransformer;
5   -
6   -/**
7   - * Transformer for S01PacketJoinGame
8   - *
9   - * @author Adam Mummery-Smith
10   - */
11   -public class JoinGamePacketTransformer extends PacketTransformer
12   -{
13   - private static boolean injected = false;
14   -
15   - public JoinGamePacketTransformer()
16   - {
17   - super(Obf.S01PacketJoinGame, Obf.CallbackProxyClient.name, "handleJoinGamePacket", 1000);
18   - }
19   -
20   - @Override
21   - protected void notifyInjectionFailed()
22   - {
23   - }
24   -
25   - @Override
26   - protected void notifyInjected()
27   - {
28   - JoinGamePacketTransformer.injected = true;
29   - }
30   -
31   - public static boolean isInjected()
32   - {
33   - return JoinGamePacketTransformer.injected;
34   - }
35   -}
36 0 \ No newline at end of file
java/client/com/mumfrey/liteloader/client/transformers/LiteLoaderEventInjectionTransformer.java
1 1 package com.mumfrey.liteloader.client.transformers;
2 2  
  3 +import static com.mumfrey.liteloader.core.runtime.Methods.*;
  4 +import static com.mumfrey.liteloader.transformers.event.InjectionPoint.*;
  5 +
3 6 import com.mumfrey.liteloader.core.runtime.Obf;
4 7 import com.mumfrey.liteloader.transformers.event.Event;
5 8 import com.mumfrey.liteloader.transformers.event.EventInjectionTransformer;
... ... @@ -10,9 +13,6 @@ import com.mumfrey.liteloader.transformers.event.inject.BeforeReturn;
10 13 import com.mumfrey.liteloader.transformers.event.inject.BeforeStringInvoke;
11 14 import com.mumfrey.liteloader.transformers.event.inject.MethodHead;
12 15  
13   -import static com.mumfrey.liteloader.core.runtime.Methods.*;
14   -import static com.mumfrey.liteloader.transformers.event.InjectionPoint.after;
15   -
16 16 public class LiteLoaderEventInjectionTransformer extends EventInjectionTransformer
17 17 {
18 18 @Override
... ...
java/client/com/mumfrey/liteloader/client/transformers/LoginSuccessPacketTransformer.java deleted 100644 โ†’ 0
1   -package com.mumfrey.liteloader.client.transformers;
2   -
3   -import com.mumfrey.liteloader.core.runtime.Obf;
4   -import com.mumfrey.liteloader.transformers.PacketTransformer;
5   -
6   -/**
7   - * Transformer for S02PacketLoginSuccess
8   - *
9   - * @author Adam Mummery-Smith
10   - */
11   -public class LoginSuccessPacketTransformer extends PacketTransformer
12   -{
13   - private static boolean injected = false;
14   -
15   - public LoginSuccessPacketTransformer()
16   - {
17   - super(Obf.S02PacketLoginSuccess, Obf.CallbackProxyClient.name, "handleLoginSuccessPacket", 1000);
18   - }
19   -
20   - @Override
21   - protected void notifyInjectionFailed()
22   - {
23   - }
24   -
25   - @Override
26   - protected void notifyInjected()
27   - {
28   - LoginSuccessPacketTransformer.injected = true;
29   - }
30   -
31   - public static boolean isInjected()
32   - {
33   - return LoginSuccessPacketTransformer.injected;
34   - }
35   -}
36 0 \ No newline at end of file
java/client/com/mumfrey/liteloader/client/transformers/ServerChatPacketTransformer.java deleted 100644 โ†’ 0
1   -package com.mumfrey.liteloader.client.transformers;
2   -
3   -import com.mumfrey.liteloader.core.runtime.Obf;
4   -import com.mumfrey.liteloader.transformers.PacketTransformer;
5   -
6   -/**
7   - * Transformer for S02PacketChat
8   - *
9   - * @author Adam Mummery-Smith
10   - */
11   -public class ServerChatPacketTransformer extends PacketTransformer
12   -{
13   - private static boolean injected = false;
14   -
15   - public ServerChatPacketTransformer()
16   - {
17   - super(Obf.C01PacketChatMessage, Obf.CallbackProxyClient.name, "handleServerChatPacket", 1000);
18   - }
19   -
20   - @Override
21   - protected void notifyInjectionFailed()
22   - {
23   - }
24   -
25   - @Override
26   - protected void notifyInjected()
27   - {
28   - ServerChatPacketTransformer.injected = true;
29   - }
30   -
31   - public static boolean isInjected()
32   - {
33   - return ServerChatPacketTransformer.injected;
34   - }
35   -}
java/client/com/mumfrey/liteloader/client/transformers/ServerCustomPayloadPacketTransformer.java deleted 100644 โ†’ 0
1   -package com.mumfrey.liteloader.client.transformers;
2   -
3   -import com.mumfrey.liteloader.core.runtime.Obf;
4   -import com.mumfrey.liteloader.transformers.PacketTransformer;
5   -
6   -/**
7   - * Transformer for C17PacketCustomPayload
8   - *
9   - * @author Adam Mummery-Smith
10   - */
11   -public class ServerCustomPayloadPacketTransformer extends PacketTransformer
12   -{
13   - private static boolean injected = false;
14   -
15   - public ServerCustomPayloadPacketTransformer()
16   - {
17   - super(Obf.C17PacketCustomPayload, Obf.CallbackProxyClient.name, "handleCustomPayloadPacket", 1000);
18   - }
19   -
20   - @Override
21   - protected void notifyInjectionFailed()
22   - {
23   - }
24   -
25   - @Override
26   - protected void notifyInjected()
27   - {
28   - ServerCustomPayloadPacketTransformer.injected = true;
29   - }
30   -
31   - public static boolean isInjected()
32   - {
33   - return ServerCustomPayloadPacketTransformer.injected;
34   - }
35   -}
java/common/com/mumfrey/liteloader/PacketHandler.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader;
  2 +
  3 +import java.util.List;
  4 +
  5 +import net.minecraft.network.INetHandler;
  6 +import net.minecraft.network.Packet;
  7 +
  8 +/**
  9 + * Interface for mods which want to handle raw packets
  10 + *
  11 + * @author Adam Mummery-Smith
  12 + */
  13 +public interface PacketHandler extends LiteMod
  14 +{
  15 + /**
  16 + * Get list of packets to handle
  17 + */
  18 + public List<Class<? extends Packet>> getHandledPackets();
  19 +
  20 + /**
  21 + * @param netHandler
  22 + * @param packet
  23 + * @return
  24 + */
  25 + public abstract boolean handlePacket(INetHandler netHandler, Packet packet);
  26 +}
... ...
java/common/com/mumfrey/liteloader/api/LiteAPI.java
... ... @@ -59,7 +59,10 @@ public interface LiteAPI
59 59  
60 60 /**
61 61 * Should return an array of required packet transformer names, these transformers will be injected UPSTREAM. Can return null.
  62 + *
  63 + * Deprecated - will be removed in 1.8
62 64 */
  65 + @Deprecated
63 66 public abstract String[] getPacketTransformers();
64 67  
65 68 /**
... ...
java/common/com/mumfrey/liteloader/api/manager/APIAdapter.java
... ... @@ -27,6 +27,7 @@ public interface APIAdapter
27 27 /**
28 28 * Aggregate and return required packet transformers from all registered APIs
29 29 */
  30 + @Deprecated
30 31 public abstract List<String> getPacketTransformers();
31 32  
32 33 /**
... ...
java/common/com/mumfrey/liteloader/common/transformers/LiteLoaderPacketTransformer.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.common.transformers;
  2 +
  3 +import com.mumfrey.liteloader.core.runtime.Obf;
  4 +import com.mumfrey.liteloader.core.runtime.Packets;
  5 +import com.mumfrey.liteloader.transformers.event.EventInjectionTransformer;
  6 +import com.mumfrey.liteloader.transformers.event.InjectionPoint;
  7 +import com.mumfrey.liteloader.transformers.event.MethodInfo;
  8 +import com.mumfrey.liteloader.transformers.event.inject.MethodHead;
  9 +
  10 +public class LiteLoaderPacketTransformer extends EventInjectionTransformer
  11 +{
  12 + @Override
  13 + protected void addEvents()
  14 + {
  15 + InjectionPoint methodHead = new MethodHead();
  16 + MethodInfo handlePacket = new MethodInfo(Obf.PacketEvents, "handlePacket");
  17 +
  18 + for (Packets packet : Packets.packets)
  19 + {
  20 + MethodInfo processPacket = new MethodInfo(packet, Obf.processPacket, Void.TYPE, Obf.INetHandler);
  21 + this.addEvent(new PacketEvent(packet), processPacket, methodHead).addListener(handlePacket);
  22 + }
  23 + }
  24 +}
... ...
java/common/com/mumfrey/liteloader/common/transformers/PacketEvent.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.common.transformers;
  2 +
  3 +import org.objectweb.asm.Opcodes;
  4 +import org.objectweb.asm.tree.InsnList;
  5 +import org.objectweb.asm.tree.InsnNode;
  6 +import org.objectweb.asm.tree.IntInsnNode;
  7 +import org.objectweb.asm.tree.LdcInsnNode;
  8 +import org.objectweb.asm.tree.MethodInsnNode;
  9 +import org.objectweb.asm.tree.VarInsnNode;
  10 +
  11 +import com.mumfrey.liteloader.core.runtime.Obf;
  12 +import com.mumfrey.liteloader.core.runtime.Packets;
  13 +import com.mumfrey.liteloader.transformers.event.Event;
  14 +import com.mumfrey.liteloader.transformers.event.EventInfo;
  15 +
  16 +/**
  17 + * Special event used to hook all packets
  18 + *
  19 + * @author Adam Mummery-Smith
  20 + */
  21 +public class PacketEvent extends Event
  22 +{
  23 + /**
  24 + * Soft index for this packet, used as a lookup for speed when determining handlers
  25 + */
  26 + private int packetIndex;
  27 +
  28 + PacketEvent(Packets packet)
  29 + {
  30 + super("on" + packet.getShortName(), true, 1000);
  31 + this.packetIndex = packet.getIndex();
  32 + }
  33 +
  34 + /* (non-Javadoc)
  35 + * @see com.mumfrey.liteloader.transformers.event.Event#getEventInfoClassName()
  36 + */
  37 + @Override
  38 + public String getEventInfoClassName()
  39 + {
  40 + return "com/mumfrey/liteloader/common/transformers/PacketEventInfo";
  41 + }
  42 +
  43 + /* (non-Javadoc)
  44 + * @see com.mumfrey.liteloader.transformers.event.Event#invokeEventInfoConstructor(org.objectweb.asm.tree.InsnList, boolean)
  45 + */
  46 + @Override
  47 + protected int invokeEventInfoConstructor(InsnList insns, boolean cancellable)
  48 + {
  49 + int ctorMAXS = 0;
  50 +
  51 + insns.add(new LdcInsnNode(this.name)); ctorMAXS++;
  52 + insns.add(this.methodIsStatic ? new InsnNode(Opcodes.ACONST_NULL) : new VarInsnNode(Opcodes.ALOAD, 0)); ctorMAXS++;
  53 + insns.add(new InsnNode(cancellable ? Opcodes.ICONST_1 : Opcodes.ICONST_0)); ctorMAXS++;
  54 + insns.add(new IntInsnNode(Opcodes.BIPUSH, this.packetIndex));
  55 + insns.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, this.eventInfoClass, Obf.constructor.name, EventInfo.getConstructorDescriptor().replace(")", "I)"), false));
  56 +
  57 + return ctorMAXS;
  58 + }
  59 +}
... ...
java/common/com/mumfrey/liteloader/common/transformers/PacketEventInfo.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.common.transformers;
  2 +
  3 +import com.mumfrey.liteloader.transformers.event.EventInfo;
  4 +
  5 +import net.minecraft.network.Packet;
  6 +
  7 +public class PacketEventInfo<S extends Packet> extends EventInfo<S>
  8 +{
  9 + private final int packetId;
  10 +
  11 + @SuppressWarnings("unchecked")
  12 + public PacketEventInfo(String name, Object source, boolean cancellable, int packetId)
  13 + {
  14 + super(name, (S)source, cancellable);
  15 +
  16 + this.packetId = packetId;
  17 + }
  18 +
  19 + public int getPacketId()
  20 + {
  21 + return this.packetId;
  22 + }
  23 +}
... ...
java/common/com/mumfrey/liteloader/core/Events.java
... ... @@ -5,12 +5,7 @@ import net.minecraft.client.resources.IResourceManagerReloadListener;
5 5 import net.minecraft.command.ICommandManager;
6 6 import net.minecraft.command.ServerCommandManager;
7 7 import net.minecraft.entity.player.EntityPlayerMP;
8   -import net.minecraft.network.INetHandler;
9   -import net.minecraft.network.NetHandlerPlayServer;
10 8 import net.minecraft.network.NetworkManager;
11   -import net.minecraft.network.play.INetHandlerPlayServer;
12   -import net.minecraft.network.play.client.C01PacketChatMessage;
13   -import net.minecraft.network.play.server.S01PacketJoinGame;
14 9 import net.minecraft.profiler.Profiler;
15 10 import net.minecraft.server.MinecraftServer;
16 11 import net.minecraft.server.management.ServerConfigurationManager;
... ... @@ -29,7 +24,6 @@ import com.mumfrey.liteloader.api.Listener;
29 24 import com.mumfrey.liteloader.common.GameEngine;
30 25 import com.mumfrey.liteloader.common.LoadingProgress;
31 26 import com.mumfrey.liteloader.core.event.HandlerList;
32   -import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp;
33 27 import com.mumfrey.liteloader.interfaces.FastIterable;
34 28 import com.mumfrey.liteloader.launch.LoaderProperties;
35 29 import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
... ... @@ -60,11 +54,6 @@ public abstract class Events&lt;TClient, TServer extends MinecraftServer&gt; implement
60 54 protected LiteLoaderMods mods;
61 55  
62 56 /**
63   - * List of mods which can filter server chat
64   - */
65   - private FastIterable<ServerChatFilter> serverChatFilters = new HandlerList<ServerChatFilter>(ServerChatFilter.class, ReturnLogicOp.AND_BREAK_ON_FALSE);
66   -
67   - /**
68 57 * List of mods which provide server commands
69 58 */
70 59 private FastIterable<ServerCommandProvider> serverCommandProviders = new HandlerList<ServerCommandProvider>(ServerCommandProvider.class);
... ... @@ -134,10 +123,8 @@ public abstract class Events&lt;TClient, TServer extends MinecraftServer&gt; implement
134 123 @Override
135 124 public void registerInterfaces(InterfaceRegistrationDelegate delegate)
136 125 {
137   - delegate.registerInterface(ServerChatFilter.class);
138 126 delegate.registerInterface(ServerCommandProvider.class);
139 127 delegate.registerInterface(ServerPlayerListener.class);
140   -
141 128 delegate.registerInterface(CommonPluginChannelListener.class);
142 129 }
143 130  
... ... @@ -155,14 +142,6 @@ public abstract class Events&lt;TClient, TServer extends MinecraftServer&gt; implement
155 142 }
156 143  
157 144 /**
158   - * @param serverChatFilter
159   - */
160   - public void addServerChatFilter(ServerChatFilter serverChatFilter)
161   - {
162   - this.serverChatFilters.add(serverChatFilter);
163   - }
164   -
165   - /**
166 145 * @param serverCommandProvider
167 146 */
168 147 public void addServerCommandProvider(ServerCommandProvider serverCommandProvider)
... ... @@ -183,20 +162,6 @@ public abstract class Events&lt;TClient, TServer extends MinecraftServer&gt; implement
183 162 {
184 163 LoadingProgress.setMessage("Reloading Resources...");
185 164 }
186   -
187   - /**
188   - * Callback from the chat hook
189   - * @param netHandler
190   - *
191   - * @param chatPacket
192   - * @return
193   - */
194   - public boolean onServerChat(INetHandlerPlayServer netHandler, C01PacketChatMessage chatPacket)
195   - {
196   - EntityPlayerMP player = netHandler instanceof NetHandlerPlayServer ? ((NetHandlerPlayServer)netHandler).playerEntity : null;
197   -
198   - return this.serverChatFilters.all().onChat(player, chatPacket, chatPacket.func_149439_c());
199   - }
200 165  
201 166 /**
202 167 * @param instance
... ... @@ -292,11 +257,6 @@ public abstract class Events&lt;TClient, TServer extends MinecraftServer&gt; implement
292 257 this.loader.onWorldChanged(world);
293 258 }
294 259  
295   - protected void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket)
296   - {
297   - this.loader.onJoinGame(netHandler, loginPacket);
298   - }
299   -
300 260 /**
301 261 * @deprecated use LiteLoader.getInterfaceManager().registerListener(listener); instead
302 262 * @param chatFilter
... ...
java/common/com/mumfrey/liteloader/core/PacketEvents.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.core;
  2 +
  3 +import java.util.List;
  4 +
  5 +import net.minecraft.entity.player.EntityPlayerMP;
  6 +import net.minecraft.network.INetHandler;
  7 +import net.minecraft.network.NetHandlerPlayServer;
  8 +import net.minecraft.network.Packet;
  9 +import net.minecraft.network.login.server.S02PacketLoginSuccess;
  10 +import net.minecraft.network.play.client.C01PacketChatMessage;
  11 +import net.minecraft.network.play.client.C17PacketCustomPayload;
  12 +import net.minecraft.network.play.server.S01PacketJoinGame;
  13 +import net.minecraft.network.play.server.S02PacketChat;
  14 +import net.minecraft.network.play.server.S3FPacketCustomPayload;
  15 +
  16 +import com.mumfrey.liteloader.JoinGameListener;
  17 +import com.mumfrey.liteloader.PacketHandler;
  18 +import com.mumfrey.liteloader.ServerChatFilter;
  19 +import com.mumfrey.liteloader.api.InterfaceProvider;
  20 +import com.mumfrey.liteloader.api.Listener;
  21 +import com.mumfrey.liteloader.common.transformers.PacketEventInfo;
  22 +import com.mumfrey.liteloader.core.event.HandlerList;
  23 +import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp;
  24 +import com.mumfrey.liteloader.core.runtime.Packets;
  25 +import com.mumfrey.liteloader.interfaces.FastIterable;
  26 +import com.mumfrey.liteloader.interfaces.FastIterableDeque;
  27 +import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
  28 +
  29 +/**
  30 + * Packet event handling
  31 + *
  32 + * @author Adam Mummery-Smith
  33 + */
  34 +public abstract class PacketEvents implements InterfaceProvider
  35 +{
  36 + protected static PacketEvents instance;
  37 +
  38 + class PacketHandlerList extends HandlerList<PacketHandler>
  39 + {
  40 + private static final long serialVersionUID = 1L;
  41 + PacketHandlerList() { super(PacketHandler.class, ReturnLogicOp.AND_BREAK_ON_FALSE); }
  42 + }
  43 +
  44 + /**
  45 + * Reference to the loader instance
  46 + */
  47 + protected final LiteLoader loader;
  48 +
  49 + private PacketHandlerList packetHandlers[] = new PacketHandlerList[Packets.count()];
  50 +
  51 + private FastIterable<ServerChatFilter> serverChatFilters = new HandlerList<ServerChatFilter>(ServerChatFilter.class, ReturnLogicOp.AND_BREAK_ON_FALSE);
  52 + private FastIterableDeque<JoinGameListener> joinGameListeners = new HandlerList<JoinGameListener>(JoinGameListener.class);
  53 +
  54 + private final int loginSuccessPacketId = Packets.S02PacketLoginSuccess.getIndex();
  55 + private final int serverChatPacketId = Packets.S02PacketChat.getIndex();
  56 + private final int clientChatPacketId = Packets.C01PacketChatMessage.getIndex();
  57 + private final int joinGamePacketId = Packets.S01PacketJoinGame.getIndex();
  58 + private final int serverPayloadPacketId = Packets.S3FPacketCustomPayload.getIndex();
  59 + private final int clientPayloadPacketId = Packets.C17PacketCustomPayload.getIndex();
  60 +
  61 + public PacketEvents()
  62 + {
  63 + PacketEvents.instance = this;
  64 + this.loader = LiteLoader.getInstance();
  65 + }
  66 +
  67 + @Override
  68 + public Class<? extends Listener> getListenerBaseType()
  69 + {
  70 + return Listener.class;
  71 + }
  72 +
  73 + @Override
  74 + public void registerInterfaces(InterfaceRegistrationDelegate delegate)
  75 + {
  76 + delegate.registerInterface(PacketHandler.class);
  77 + delegate.registerInterface(JoinGameListener.class);
  78 + delegate.registerInterface(ServerChatFilter.class);
  79 + }
  80 +
  81 + @Override
  82 + public void initProvider()
  83 + {
  84 + }
  85 +
  86 + /**
  87 + * @param joinGameListener
  88 + */
  89 + public void registerJoinGameListener(JoinGameListener joinGameListener)
  90 + {
  91 + this.joinGameListeners.add(joinGameListener);
  92 + }
  93 +
  94 + /**
  95 + * @param serverChatFilter
  96 + */
  97 + public void registerServerChatFilter(ServerChatFilter serverChatFilter)
  98 + {
  99 + this.serverChatFilters.add(serverChatFilter);
  100 + }
  101 +
  102 + public void registerPacketHandler(PacketHandler handler)
  103 + {
  104 + List<Class<? extends Packet>> handledPackets = handler.getHandledPackets();
  105 + if (handledPackets != null)
  106 + {
  107 + for (Class<? extends Packet> packetClass : handledPackets)
  108 + {
  109 + String packetClassName = packetClass.getName();
  110 + int packetId = Packets.indexOf(packetClassName);
  111 + if (packetId == -1 || packetId >= this.packetHandlers.length)
  112 + {
  113 + LiteLoaderLogger.warning("PacketHandler %s attempted to register a handler for unupported packet class %s", handler.getName(), packetClassName);
  114 + continue;
  115 + }
  116 +
  117 + if (this.packetHandlers[packetId] == null)
  118 + {
  119 + this.packetHandlers[packetId] = new PacketHandlerList();
  120 + }
  121 +
  122 + this.packetHandlers[packetId].add(handler);
  123 + }
  124 + }
  125 + }
  126 +
  127 + public static void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler)
  128 + {
  129 + PacketEvents.instance.handlePacket(e, netHandler, e.getPacketId());
  130 + }
  131 +
  132 + private void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, int packetId)
  133 + {
  134 + this.handlePacketEvent(e, netHandler, packetId);
  135 +
  136 + if (this.packetHandlers[packetId] == null || e.isCancelled())
  137 + {
  138 + return;
  139 + }
  140 +
  141 + if (!this.packetHandlers[packetId].all().handlePacket(netHandler, e.getSource()))
  142 + {
  143 + e.cancel();
  144 + }
  145 + }
  146 +
  147 + /**
  148 + * @param e
  149 + * @param netHandler
  150 + * @param packetId
  151 + * @param packet
  152 + */
  153 + protected void handlePacketEvent(PacketEventInfo<Packet> e, INetHandler netHandler, int packetId)
  154 + {
  155 + Packet packet = e.getSource();
  156 +
  157 + if (packetId == this.loginSuccessPacketId)
  158 + {
  159 + this.handlePacket(e, netHandler, (S02PacketLoginSuccess)packet);
  160 + return;
  161 + }
  162 +
  163 + if (packetId == this.serverChatPacketId)
  164 + {
  165 + this.handlePacket(e, netHandler, (S02PacketChat)packet);
  166 + return;
  167 + }
  168 +
  169 + if (packetId == this.clientChatPacketId)
  170 + {
  171 + this.handlePacket(e, netHandler, (C01PacketChatMessage)packet);
  172 + return;
  173 + }
  174 +
  175 + if (packetId == this.joinGamePacketId)
  176 + {
  177 + this.handlePacket(e, netHandler, (S01PacketJoinGame)packet);
  178 + return;
  179 + }
  180 +
  181 + if (packetId == this.serverPayloadPacketId)
  182 + {
  183 + this.handlePacket(e, netHandler, (S3FPacketCustomPayload)packet);
  184 + return;
  185 + }
  186 +
  187 + if (packetId == this.clientPayloadPacketId)
  188 + {
  189 + this.handlePacket(e, netHandler, (C17PacketCustomPayload)packet);
  190 + return;
  191 + }
  192 + }
  193 +
  194 + /**
  195 + * @param e
  196 + * @param netHandler
  197 + * @param packet
  198 + */
  199 + protected abstract void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, S02PacketLoginSuccess packet);
  200 +
  201 + /**
  202 + * S02PacketChat::processPacket()
  203 + *
  204 + * @param netHandler
  205 + * @param packet
  206 + */
  207 + protected abstract void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, S02PacketChat packet);
  208 +
  209 + /**
  210 + * S02PacketChat::processPacket()
  211 + *
  212 + * @param netHandler
  213 + * @param packet
  214 + */
  215 + protected void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, C01PacketChatMessage packet)
  216 + {
  217 + EntityPlayerMP player = netHandler instanceof NetHandlerPlayServer ? ((NetHandlerPlayServer)netHandler).playerEntity : null;
  218 +
  219 + if (!this.serverChatFilters.all().onChat(player, packet, packet.func_149439_c()))
  220 + {
  221 + e.cancel();
  222 + }
  223 + }
  224 +
  225 + /**
  226 + * S01PacketJoinGame::processPacket()
  227 + *
  228 + * @param netHandler
  229 + * @param packet
  230 + */
  231 + protected void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, S01PacketJoinGame packet)
  232 + {
  233 + this.loader.onJoinGame(netHandler, packet);
  234 + this.joinGameListeners.all().onJoinGame(netHandler, packet);
  235 + }
  236 +
  237 + /**
  238 + * S3FPacketCustomPayload::processPacket()
  239 + *
  240 + * @param netHandler
  241 + * @param packet
  242 + */
  243 + protected void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, S3FPacketCustomPayload packet)
  244 + {
  245 + LiteLoader.getClientPluginChannels().onPluginChannelMessage(packet);
  246 + }
  247 +
  248 + /**
  249 + * C17PacketCustomPayload::processPacket()
  250 + *
  251 + * @param netHandler
  252 + * @param packet
  253 + */
  254 + protected void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, C17PacketCustomPayload packet)
  255 + {
  256 + LiteLoader.getServerPluginChannels().onPluginChannelMessage(netHandler, packet);
  257 + }
  258 +}
... ...
java/common/com/mumfrey/liteloader/core/ServerPluginChannels.java
1 1 package com.mumfrey.liteloader.core;
2 2  
3 3 import net.minecraft.entity.player.EntityPlayerMP;
  4 +import net.minecraft.network.INetHandler;
4 5 import net.minecraft.network.NetHandlerPlayServer;
5 6 import net.minecraft.network.play.INetHandlerPlayServer;
6 7 import net.minecraft.network.play.client.C17PacketCustomPayload;
... ... @@ -97,11 +98,11 @@ public class ServerPluginChannels extends PluginChannels&lt;ServerPluginChannelList
97 98  
98 99 /**
99 100 * Callback for the plugin channel hook
100   - * @param netHandler
101 101 *
  102 + * @param netHandler
102 103 * @param customPayload
103 104 */
104   - public void onPluginChannelMessage(INetHandlerPlayServer netHandler, C17PacketCustomPayload customPayload)
  105 + public void onPluginChannelMessage(INetHandler netHandler, C17PacketCustomPayload customPayload)
105 106 {
106 107 if (customPayload != null && customPayload.func_149559_c() != null)
107 108 {
... ...
java/common/com/mumfrey/liteloader/core/api/LiteLoaderCoreAPI.java
... ... @@ -21,6 +21,7 @@ import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
21 21 public abstract class LiteLoaderCoreAPI implements LiteAPI
22 22 {
23 23 protected static final String PKG_LITELOADER = "com.mumfrey.liteloader";
  24 + protected static final String PKG_LITELOADER_COMMON = LiteLoaderCoreAPI.PKG_LITELOADER + ".common";
24 25  
25 26 protected LoaderEnvironment environment;
26 27  
... ...
java/common/com/mumfrey/liteloader/core/event/HandlerList.java
... ... @@ -733,7 +733,7 @@ public class HandlerList&lt;T&gt; extends LinkedList&lt;T&gt; implements FastIterableDeque&lt;T
733 733 {
734 734 method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
735 735 method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
736   - method.instructions.add(new IntInsnNode(Opcodes.BIPUSH, handlerIndex));
  736 + method.instructions.add(handlerIndex > Short.MAX_VALUE ? new LdcInsnNode(new Integer(handlerIndex)) : new IntInsnNode(Opcodes.SIPUSH, handlerIndex));
737 737 method.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;", true));
738 738 method.instructions.add(new TypeInsnNode(Opcodes.CHECKCAST, this.typeRef));
739 739 method.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, classNode.name, HandlerListClassLoader.HANDLER_VAR_PREFIX + handlerIndex, "L" + this.typeRef + ";"));
... ...
java/common/com/mumfrey/liteloader/core/runtime/Obf.java
... ... @@ -19,6 +19,7 @@ public class Obf
19 19 public static final Obf EventProxy = new Obf("com.mumfrey.liteloader.core.event.EventProxy" );
20 20 public static final Obf HandlerList = new Obf("com.mumfrey.liteloader.core.event.HandlerList" );
21 21 public static final Obf BakedHandlerList = new Obf("com.mumfrey.liteloader.core.event.HandlerList$BakedHandlerList" );
  22 + public static final Obf PacketEvents = new Obf("com.mumfrey.liteloader.core.PacketEvents" );
22 23 public static final Obf LoadingBar = new Obf("com.mumfrey.liteloader.client.gui.startup.LoadingBar" );
23 24 public static final Obf GameProfile = new Obf("com.mojang.authlib.GameProfile" );
24 25 public static final Obf MinecraftMain = new Obf("net.minecraft.client.main.Main" );
... ... @@ -33,13 +34,7 @@ public class Obf
33 34 public static final Obf GuiIngame = new Obf("net.minecraft.client.gui.GuiIngame", "bbv" );
34 35 public static final Obf Profiler = new Obf("net.minecraft.profiler.Profiler", "qi" );
35 36 public static final Obf CrashReport$6 = new Obf("net.minecraft.crash.CrashReport$6", "h" );
36   - public static final Obf S01PacketJoinGame = new Obf("net.minecraft.network.play.server.S01PacketJoinGame", "hd" );
37   - public static final Obf S02PacketLoginSuccess = new Obf("net.minecraft.network.login.server.S02PacketLoginSuccess", "js" );
38   - public static final Obf S02PacketChat = new Obf("net.minecraft.network.play.server.S02PacketChat", "gj" );
39   - public static final Obf S3FPacketCustomPayload = new Obf("net.minecraft.network.play.server.S3FPacketCustomPayload", "gr" );
40 37 public static final Obf INetHandler = new Obf("net.minecraft.network.INetHandler", "fb" );
41   - public static final Obf C01PacketChatMessage = new Obf("net.minecraft.network.play.client.C01PacketChatMessage", "ir" );
42   - public static final Obf C17PacketCustomPayload = new Obf("net.minecraft.network.play.client.C17PacketCustomPayload", "iz" );
43 38 public static final Obf IntegratedServer = new Obf("net.minecraft.server.integrated.IntegratedServer", "bsx" );
44 39 public static final Obf WorldSettings = new Obf("net.minecraft.world.WorldSettings", "ahj" );
45 40 public static final Obf ServerConfigurationManager = new Obf("net.minecraft.server.management.ServerConfigurationManager", "oi" );
... ... @@ -52,6 +47,15 @@ public class Obf
52 47 public static final Obf FrameBuffer = new Obf("net.minecraft.client.shader.Framebuffer", "bmg" );
53 48 public static final Obf GuiNewChat = new Obf("net.minecraft.client.gui.GuiNewChat", "bcc" );
54 49  
  50 + // Packets
  51 + // -----------------------------------------------------------------------------------------
  52 + @Deprecated public static final Obf S01PacketJoinGame = Packets.S01PacketJoinGame;
  53 + @Deprecated public static final Obf S02PacketLoginSuccess = Packets.S02PacketLoginSuccess;
  54 + @Deprecated public static final Obf S02PacketChat = Packets.S02PacketChat;
  55 + @Deprecated public static final Obf S3FPacketCustomPayload = Packets.S3FPacketCustomPayload;
  56 + @Deprecated public static final Obf C01PacketChatMessage = Packets.C01PacketChatMessage;
  57 + @Deprecated public static final Obf C17PacketCustomPayload = Packets.C17PacketCustomPayload;
  58 +
55 59 // Fields
56 60 // -----------------------------------------------------------------------------------------
57 61 public static final Obf minecraftProfiler = new Obf("field_71424_I", "z" ); // Minecraft/mcProfiler
... ...
java/common/com/mumfrey/liteloader/core/runtime/Packets.java 0 โ†’ 100644
  1 +package com.mumfrey.liteloader.core.runtime;
  2 +
  3 +/**
  4 + * Packet obfuscation table
  5 + *
  6 + * @author Adam Mummery-Smith
  7 + * TODO Obfuscation 1.7.10
  8 + */
  9 +@SuppressWarnings("hiding")
  10 +public class Packets extends Obf
  11 +{
  12 + public static final Packets S08PacketPlayerPosLook = new Packets("net.minecraft.network.play.server.S08PacketPlayerPosLook", "fu");
  13 + public static final Packets S0EPacketSpawnObject = new Packets("net.minecraft.network.play.server.S0EPacketSpawnObject", "fw");
  14 + public static final Packets S11PacketSpawnExperienceOrb = new Packets("net.minecraft.network.play.server.S11PacketSpawnExperienceOrb", "fx");
  15 + public static final Packets S2CPacketSpawnGlobalEntity = new Packets("net.minecraft.network.play.server.S2CPacketSpawnGlobalEntity", "fy");
  16 + public static final Packets S0FPacketSpawnMob = new Packets("net.minecraft.network.play.server.S0FPacketSpawnMob", "fz");
  17 + public static final Packets S10PacketSpawnPainting = new Packets("net.minecraft.network.play.server.S10PacketSpawnPainting", "ga");
  18 + public static final Packets S0CPacketSpawnPlayer = new Packets("net.minecraft.network.play.server.S0CPacketSpawnPlayer", "gb");
  19 + public static final Packets S0BPacketAnimation = new Packets("net.minecraft.network.play.server.S0BPacketAnimation", "gc");
  20 + public static final Packets S37PacketStatistics = new Packets("net.minecraft.network.play.server.S37PacketStatistics", "gd");
  21 + public static final Packets S25PacketBlockBreakAnim = new Packets("net.minecraft.network.play.server.S25PacketBlockBreakAnim", "ge");
  22 + public static final Packets S35PacketUpdateTileEntity = new Packets("net.minecraft.network.play.server.S35PacketUpdateTileEntity", "gf");
  23 + public static final Packets S24PacketBlockAction = new Packets("net.minecraft.network.play.server.S24PacketBlockAction", "gg");
  24 + public static final Packets S23PacketBlockChange = new Packets("net.minecraft.network.play.server.S23PacketBlockChange", "gh");
  25 + public static final Packets S3APacketTabComplete = new Packets("net.minecraft.network.play.server.S3APacketTabComplete", "gi");
  26 + public static final Packets S02PacketChat = new Packets("net.minecraft.network.play.server.S02PacketChat", "gj");
  27 + public static final Packets S22PacketMultiBlockChange = new Packets("net.minecraft.network.play.server.S22PacketMultiBlockChange", "gk");
  28 + public static final Packets S32PacketConfirmTransaction = new Packets("net.minecraft.network.play.server.S32PacketConfirmTransaction", "gl");
  29 + public static final Packets S2EPacketCloseWindow = new Packets("net.minecraft.network.play.server.S2EPacketCloseWindow", "gm");
  30 + public static final Packets S2DPacketOpenWindow = new Packets("net.minecraft.network.play.server.S2DPacketOpenWindow", "gn");
  31 + public static final Packets S30PacketWindowItems = new Packets("net.minecraft.network.play.server.S30PacketWindowItems", "go");
  32 + public static final Packets S31PacketWindowProperty = new Packets("net.minecraft.network.play.server.S31PacketWindowProperty", "gp");
  33 + public static final Packets S2FPacketSetSlot = new Packets("net.minecraft.network.play.server.S2FPacketSetSlot", "gq");
  34 + public static final Packets S3FPacketCustomPayload = new Packets("net.minecraft.network.play.server.S3FPacketCustomPayload", "gr");
  35 + public static final Packets S40PacketDisconnect = new Packets("net.minecraft.network.play.server.S40PacketDisconnect", "gs");
  36 + public static final Packets S19PacketEntityStatus = new Packets("net.minecraft.network.play.server.S19PacketEntityStatus", "gt");
  37 + public static final Packets S27PacketExplosion = new Packets("net.minecraft.network.play.server.S27PacketExplosion", "gu");
  38 + public static final Packets S2BPacketChangeGameState = new Packets("net.minecraft.network.play.server.S2BPacketChangeGameState", "gv");
  39 + public static final Packets S00PacketKeepAlive = new Packets("net.minecraft.network.play.server.S00PacketKeepAlive", "gw");
  40 + public static final Packets S21PacketChunkData = new Packets("net.minecraft.network.play.server.S21PacketChunkData", "gx");
  41 + public static final Packets S21PacketChunkData$Extracted = new Packets("net.minecraft.network.play.server.S21PacketChunkData$Extracted", "gy");
  42 + public static final Packets S26PacketMapChunkBulk = new Packets("net.minecraft.network.play.server.S26PacketMapChunkBulk", "gz");
  43 + public static final Packets S28PacketEffect = new Packets("net.minecraft.network.play.server.S28PacketEffect", "ha");
  44 + public static final Packets S2APacketParticles = new Packets("net.minecraft.network.play.server.S2APacketParticles", "hb");
  45 + public static final Packets S29PacketSoundEffect = new Packets("net.minecraft.network.play.server.S29PacketSoundEffect", "hc");
  46 + public static final Packets S01PacketJoinGame = new Packets("net.minecraft.network.play.server.S01PacketJoinGame", "hd");
  47 + public static final Packets S34PacketMaps = new Packets("net.minecraft.network.play.server.S34PacketMaps", "he");
  48 + public static final Packets S14PacketEntity = new Packets("net.minecraft.network.play.server.S14PacketEntity", "hf");
  49 + public static final Packets S15PacketEntityRelMove = new Packets("net.minecraft.network.play.server.S14PacketEntity$S15PacketEntityRelMove", "hg");
  50 + public static final Packets S17PacketEntityLookMove = new Packets("net.minecraft.network.play.server.S14PacketEntity$S17PacketEntityLookMove", "hh");
  51 + public static final Packets S16PacketEntityLook = new Packets("net.minecraft.network.play.server.S14PacketEntity$S16PacketEntityLook", "hi");
  52 + public static final Packets S36PacketSignEditorOpen = new Packets("net.minecraft.network.play.server.S36PacketSignEditorOpen", "hj");
  53 + public static final Packets S39PacketPlayerAbilities = new Packets("net.minecraft.network.play.server.S39PacketPlayerAbilities", "hk");
  54 + public static final Packets S38PacketPlayerListItem = new Packets("net.minecraft.network.play.server.S38PacketPlayerListItem", "ho");
  55 + public static final Packets S0APacketUseBed = new Packets("net.minecraft.network.play.server.S0APacketUseBed", "hp");
  56 + public static final Packets S13PacketDestroyEntities = new Packets("net.minecraft.network.play.server.S13PacketDestroyEntities", "hq");
  57 + public static final Packets S1EPacketRemoveEntityEffect = new Packets("net.minecraft.network.play.server.S1EPacketRemoveEntityEffect", "hr");
  58 + public static final Packets S07PacketRespawn = new Packets("net.minecraft.network.play.server.S07PacketRespawn", "hs");
  59 + public static final Packets S19PacketEntityHeadLook = new Packets("net.minecraft.network.play.server.S19PacketEntityHeadLook", "ht");
  60 + public static final Packets S09PacketHeldItemChange = new Packets("net.minecraft.network.play.server.S09PacketHeldItemChange", "hu");
  61 + public static final Packets S3DPacketDisplayScoreboard = new Packets("net.minecraft.network.play.server.S3DPacketDisplayScoreboard", "hv");
  62 + public static final Packets S1CPacketEntityMetadata = new Packets("net.minecraft.network.play.server.S1CPacketEntityMetadata", "hw");
  63 + public static final Packets S1BPacketEntityAttach = new Packets("net.minecraft.network.play.server.S1BPacketEntityAttach", "hx");
  64 + public static final Packets S12PacketEntityVelocity = new Packets("net.minecraft.network.play.server.S12PacketEntityVelocity", "hy");
  65 + public static final Packets S04PacketEntityEquipment = new Packets("net.minecraft.network.play.server.S04PacketEntityEquipment", "hz");
  66 + public static final Packets S1FPacketSetExperience = new Packets("net.minecraft.network.play.server.S1FPacketSetExperience", "ia");
  67 + public static final Packets S06PacketUpdateHealth = new Packets("net.minecraft.network.play.server.S06PacketUpdateHealth", "ib");
  68 + public static final Packets S3BPacketScoreboardObjective = new Packets("net.minecraft.network.play.server.S3BPacketScoreboardObjective", "ic");
  69 + public static final Packets S3EPacketTeams = new Packets("net.minecraft.network.play.server.S3EPacketTeams", "id");
  70 + public static final Packets S3CPacketUpdateScore = new Packets("net.minecraft.network.play.server.S3CPacketUpdateScore", "ie");
  71 + public static final Packets S05PacketSpawnPosition = new Packets("net.minecraft.network.play.server.S05PacketSpawnPosition", "ig");
  72 + public static final Packets S03PacketTimeUpdate = new Packets("net.minecraft.network.play.server.S03PacketTimeUpdate", "ih");
  73 + public static final Packets S33PacketUpdateSign = new Packets("net.minecraft.network.play.server.S33PacketUpdateSign", "ii");
  74 + public static final Packets S0DPacketCollectItem = new Packets("net.minecraft.network.play.server.S0DPacketCollectItem", "ij");
  75 + public static final Packets S18PacketEntityTeleport = new Packets("net.minecraft.network.play.server.S18PacketEntityTeleport", "ik");
  76 + public static final Packets S20PacketEntityProperties = new Packets("net.minecraft.network.play.server.S20PacketEntityProperties", "il");
  77 + public static final Packets S20PacketEntityProperties$Snapshot = new Packets("net.minecraft.network.play.server.S20PacketEntityProperties$Snapshot", "im");
  78 + public static final Packets S1DPacketEntityEffect = new Packets("net.minecraft.network.play.server.S1DPacketEntityEffect", "in");
  79 + public static final Packets C0APacketAnimation = new Packets("net.minecraft.network.play.client.C0APacketAnimation", "ip");
  80 + public static final Packets C14PacketTabComplete = new Packets("net.minecraft.network.play.client.C14PacketTabComplete", "iq");
  81 + public static final Packets C01PacketChatMessage = new Packets("net.minecraft.network.play.client.C01PacketChatMessage", "ir");
  82 + public static final Packets C16PacketClientStatus = new Packets("net.minecraft.network.play.client.C16PacketClientStatus", "is");
  83 + public static final Packets C16PacketClientStatus$EnumState = new Packets("net.minecraft.network.play.client.C16PacketClientStatus$EnumState", "it");
  84 + public static final Packets C15PacketClientSettings = new Packets("net.minecraft.network.play.client.C15PacketClientSettings", "iu");
  85 + public static final Packets C0FPacketConfirmTransaction = new Packets("net.minecraft.network.play.client.C0FPacketConfirmTransaction", "iv");
  86 + public static final Packets C11PacketEnchantItem = new Packets("net.minecraft.network.play.client.C11PacketEnchantItem", "iw");
  87 + public static final Packets C0EPacketClickWindow = new Packets("net.minecraft.network.play.client.C0EPacketClickWindow", "ix");
  88 + public static final Packets C0DPacketCloseWindow = new Packets("net.minecraft.network.play.client.C0DPacketCloseWindow", "iy");
  89 + public static final Packets C17PacketCustomPayload = new Packets("net.minecraft.network.play.client.C17PacketCustomPayload", "iz");
  90 + public static final Packets C02PacketUseEntity = new Packets("net.minecraft.network.play.client.C02PacketUseEntity", "ja");
  91 + public static final Packets C02PacketUseEntity$Action = new Packets("net.minecraft.network.play.client.C02PacketUseEntity$Action", "jb");
  92 + public static final Packets C00PacketKeepAlive = new Packets("net.minecraft.network.play.client.C00PacketKeepAlive", "jc");
  93 + public static final Packets C03PacketPlayer = new Packets("net.minecraft.network.play.client.C03PacketPlayer", "jd");
  94 + public static final Packets C04PacketPlayerPosition = new Packets("net.minecraft.network.play.client.C03PacketPlayer$C04PacketPlayerPosition", "je");
  95 + public static final Packets C06PacketPlayerPosLook = new Packets("net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook", "jf");
  96 + public static final Packets C05PacketPlayerLook = new Packets("net.minecraft.network.play.client.C03PacketPlayer$C05PacketPlayerLook", "jg");
  97 + public static final Packets C13PacketPlayerAbilities = new Packets("net.minecraft.network.play.client.C13PacketPlayerAbilities", "jh");
  98 + public static final Packets C07PacketPlayerDigging = new Packets("net.minecraft.network.play.client.C07PacketPlayerDigging", "ji");
  99 + public static final Packets C0BPacketEntityAction = new Packets("net.minecraft.network.play.client.C0BPacketEntityAction", "jj");
  100 + public static final Packets C0CPacketInput = new Packets("net.minecraft.network.play.client.C0CPacketInput", "jk");
  101 + public static final Packets C09PacketHeldItemChange = new Packets("net.minecraft.network.play.client.C09PacketHeldItemChange", "jl");
  102 + public static final Packets C10PacketCreativeInventoryAction = new Packets("net.minecraft.network.play.client.C10PacketCreativeInventoryAction", "jm");
  103 + public static final Packets C12PacketUpdateSign = new Packets("net.minecraft.network.play.client.C12PacketUpdateSign", "jn");
  104 + public static final Packets C08PacketPlayerBlockPlacement = new Packets("net.minecraft.network.play.client.C08PacketPlayerBlockPlacement", "jo");
  105 + public static final Packets C00Handshake = new Packets("net.minecraft.network.handshake.client.C00Handshake", "jp");
  106 + public static final Packets S02PacketLoginSuccess = new Packets("net.minecraft.network.login.server.S02PacketLoginSuccess", "js");
  107 + public static final Packets S01PacketEncryptionRequest = new Packets("net.minecraft.network.login.server.S01PacketEncryptionRequest", "jt");
  108 + public static final Packets S00PacketDisconnect = new Packets("net.minecraft.network.login.server.S00PacketDisconnect", "ju");
  109 + public static final Packets C00PacketLoginStart = new Packets("net.minecraft.network.login.client.C00PacketLoginStart", "jw");
  110 + public static final Packets C01PacketEncryptionResponse = new Packets("net.minecraft.network.login.client.C01PacketEncryptionResponse", "jx");
  111 + public static final Packets S01PacketPong = new Packets("net.minecraft.network.status.server.S01PacketPong", "jz");
  112 + public static final Packets S00PacketServerInfo = new Packets("net.minecraft.network.status.server.S00PacketServerInfo", "ka");
  113 +
  114 + public static final Packets[] packets = new Packets[] {
  115 + S08PacketPlayerPosLook,
  116 + S0EPacketSpawnObject,
  117 + S11PacketSpawnExperienceOrb,
  118 + S2CPacketSpawnGlobalEntity,
  119 + S0FPacketSpawnMob,
  120 + S10PacketSpawnPainting,
  121 + S0CPacketSpawnPlayer,
  122 + S0BPacketAnimation,
  123 + S37PacketStatistics,
  124 + S25PacketBlockBreakAnim,
  125 + S35PacketUpdateTileEntity,
  126 + S24PacketBlockAction,
  127 + S23PacketBlockChange,
  128 + S3APacketTabComplete,
  129 + S02PacketChat,
  130 + S22PacketMultiBlockChange,
  131 + S32PacketConfirmTransaction,
  132 + S2EPacketCloseWindow,
  133 + S2DPacketOpenWindow,
  134 + S30PacketWindowItems,
  135 + S31PacketWindowProperty,
  136 + S2FPacketSetSlot,
  137 + S3FPacketCustomPayload,
  138 + S40PacketDisconnect,
  139 + S19PacketEntityStatus,
  140 + S27PacketExplosion,
  141 + S2BPacketChangeGameState,
  142 + S00PacketKeepAlive,
  143 + S21PacketChunkData,
  144 + S21PacketChunkData$Extracted,
  145 + S26PacketMapChunkBulk,
  146 + S28PacketEffect,
  147 + S2APacketParticles,
  148 + S29PacketSoundEffect,
  149 + S01PacketJoinGame,
  150 + S34PacketMaps,
  151 + S14PacketEntity,
  152 + S15PacketEntityRelMove,
  153 + S17PacketEntityLookMove,
  154 + S16PacketEntityLook,
  155 + S36PacketSignEditorOpen,
  156 + S39PacketPlayerAbilities,
  157 + S38PacketPlayerListItem,
  158 + S0APacketUseBed,
  159 + S13PacketDestroyEntities,
  160 + S1EPacketRemoveEntityEffect,
  161 + S07PacketRespawn,
  162 + S19PacketEntityHeadLook,
  163 + S09PacketHeldItemChange,
  164 + S3DPacketDisplayScoreboard,
  165 + S1CPacketEntityMetadata,
  166 + S1BPacketEntityAttach,
  167 + S12PacketEntityVelocity,
  168 + S04PacketEntityEquipment,
  169 + S1FPacketSetExperience,
  170 + S06PacketUpdateHealth,
  171 + S3BPacketScoreboardObjective,
  172 + S3EPacketTeams,
  173 + S3CPacketUpdateScore,
  174 + S05PacketSpawnPosition,
  175 + S03PacketTimeUpdate,
  176 + S33PacketUpdateSign,
  177 + S0DPacketCollectItem,
  178 + S18PacketEntityTeleport,
  179 + S20PacketEntityProperties,
  180 + S20PacketEntityProperties$Snapshot,
  181 + S1DPacketEntityEffect,
  182 + C0APacketAnimation,
  183 + C14PacketTabComplete,
  184 + C01PacketChatMessage,
  185 + C16PacketClientStatus,
  186 + C16PacketClientStatus$EnumState,
  187 + C15PacketClientSettings,
  188 + C0FPacketConfirmTransaction,
  189 + C11PacketEnchantItem,
  190 + C0EPacketClickWindow,
  191 + C0DPacketCloseWindow,
  192 + C17PacketCustomPayload,
  193 + C02PacketUseEntity,
  194 + C02PacketUseEntity$Action,
  195 + C00PacketKeepAlive,
  196 + C03PacketPlayer,
  197 + C04PacketPlayerPosition,
  198 + C06PacketPlayerPosLook,
  199 + C05PacketPlayerLook,
  200 + C13PacketPlayerAbilities,
  201 + C07PacketPlayerDigging,
  202 + C0BPacketEntityAction,
  203 + C0CPacketInput,
  204 + C09PacketHeldItemChange,
  205 + C10PacketCreativeInventoryAction,
  206 + C12PacketUpdateSign,
  207 + C08PacketPlayerBlockPlacement,
  208 + C00Handshake,
  209 + S02PacketLoginSuccess,
  210 + S01PacketEncryptionRequest,
  211 + S00PacketDisconnect,
  212 + C00PacketLoginStart,
  213 + C01PacketEncryptionResponse,
  214 + S01PacketPong,
  215 + S00PacketServerInfo
  216 + };
  217 +
  218 + private static int nextPacketIndex;
  219 +
  220 + private final String shortName;
  221 +
  222 + private final int index;
  223 +
  224 + private Packets(String seargeName, String obfName)
  225 + {
  226 + super(seargeName, obfName);
  227 +
  228 + this.shortName = seargeName.substring(Math.max(seargeName.lastIndexOf('.'), seargeName.lastIndexOf('$')) + 1);
  229 + this.index = Packets.nextPacketIndex++;
  230 + }
  231 +
  232 + public int getIndex()
  233 + {
  234 + return this.index;
  235 + }
  236 +
  237 + public String getShortName()
  238 + {
  239 + return this.shortName;
  240 + }
  241 +
  242 + public static int indexOf(String packetClassName)
  243 + {
  244 + for (Packets packet : Packets.packets)
  245 + {
  246 + if (packet.name.equals(packetClassName) || packet.shortName.equals(packetClassName) || packet.obf.equals(packetClassName)) return packet.index;
  247 + }
  248 +
  249 + return -1;
  250 + }
  251 +
  252 + public static int count()
  253 + {
  254 + return Packets.nextPacketIndex;
  255 + }
  256 +}
... ...
java/common/com/mumfrey/liteloader/interfaces/ObjectFactory.java
... ... @@ -5,6 +5,7 @@ import net.minecraft.server.MinecraftServer;
5 5 import com.mumfrey.liteloader.common.GameEngine;
6 6 import com.mumfrey.liteloader.core.ClientPluginChannels;
7 7 import com.mumfrey.liteloader.core.Events;
  8 +import com.mumfrey.liteloader.core.PacketEvents;
8 9 import com.mumfrey.liteloader.core.ServerPluginChannels;
9 10 import com.mumfrey.liteloader.permissions.PermissionsManagerClient;
10 11 import com.mumfrey.liteloader.permissions.PermissionsManagerServer;
... ... @@ -21,6 +22,8 @@ public interface ObjectFactory&lt;TClient, TServer extends MinecraftServer&gt;
21 22 {
22 23 public abstract Events<TClient, TServer> getEventBroker();
23 24  
  25 + public abstract PacketEvents getPacketEventBroker();
  26 +
24 27 public abstract GameEngine<TClient, TServer> getGameEngine();
25 28  
26 29 public abstract PanelManager<?> getPanelManager();
... ...
java/common/com/mumfrey/liteloader/launch/ClassTransformerManager.java
... ... @@ -203,7 +203,7 @@ public class ClassTransformerManager
203 203 * @param classLoader
204 204 * @param transformers
205 205 */
206   - @SuppressWarnings("unchecked")
  206 + @SuppressWarnings({ "unchecked", "deprecation" })
207 207 private void sieveAndSortPacketTransformers(LaunchClassLoader classLoader, Set<String> transformers)
208 208 {
209 209 LiteLoaderLogger.info("Sorting registered packet transformers by priority");
... ...
java/common/com/mumfrey/liteloader/launch/LiteLoaderTweaker.java
... ... @@ -323,6 +323,7 @@ public class LiteLoaderTweaker implements ITweaker
323 323 public void injectIntoClassLoader(LaunchClassLoader classLoader)
324 324 {
325 325 classLoader.addClassLoaderExclusion("com.mumfrey.liteloader.core.runtime.Obf");
  326 + classLoader.addClassLoaderExclusion("com.mumfrey.liteloader.core.runtime.Packets");
326 327  
327 328 LiteLoaderTweaker.instance.transformerManager.injectUpstreamTransformers(classLoader);
328 329  
... ...
java/common/com/mumfrey/liteloader/transformers/event/Event.java
... ... @@ -95,7 +95,7 @@ public class Event implements Comparable&lt;Event&gt;
95 95  
96 96 protected Set<MethodInfo> pendingInjections;
97 97  
98   - Event(String name, boolean cancellable, int priority)
  98 + protected Event(String name, boolean cancellable, int priority)
99 99 {
100 100 this.name = name.toLowerCase();
101 101 this.priority = priority;
... ... @@ -216,7 +216,7 @@ public class Event implements Comparable&lt;Event&gt;
216 216 this.methodReturnType = Type.getReturnType(method.desc);
217 217 this.methodMAXS = method.maxStack;
218 218 this.methodIsStatic = (method.access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC;
219   - this.eventInfoClass = EventInfo.getEventInfoClassName(this.methodReturnType).replace('.', '/');
  219 + this.eventInfoClass = this.getEventInfoClassName();
220 220 this.eventDescriptor = String.format("(L%s;%s)V", this.eventInfoClass, method.desc.substring(1, method.desc.indexOf(')')));
221 221 }
222 222  
... ... @@ -306,10 +306,7 @@ public class Event implements Comparable&lt;Event&gt;
306 306 // Instance the EventInfo for this event
307 307 insns.add(new TypeInsnNode(Opcodes.NEW, this.eventInfoClass)); ctorMAXS++;
308 308 insns.add(new InsnNode(Opcodes.DUP)); ctorMAXS++; invokeMAXS++;
309   - insns.add(new LdcInsnNode(this.name)); ctorMAXS++;
310   - insns.add(this.methodIsStatic ? new InsnNode(Opcodes.ACONST_NULL) : new VarInsnNode(Opcodes.ALOAD, 0)); ctorMAXS++;
311   - insns.add(new InsnNode(cancellable ? Opcodes.ICONST_1 : Opcodes.ICONST_0)); ctorMAXS++;
312   - insns.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, this.eventInfoClass, Obf.constructor.name, EventInfo.getConstructorDescriptor(), false));
  309 + ctorMAXS += invokeEventInfoConstructor(insns, cancellable);
313 310 insns.add(new VarInsnNode(Opcodes.ASTORE, eventInfoVar));
314 311  
315 312 // Call the event handler method in the proxy
... ... @@ -330,6 +327,23 @@ public class Event implements Comparable&lt;Event&gt;
330 327 return handler;
331 328 }
332 329  
  330 + protected int invokeEventInfoConstructor(InsnList insns, boolean cancellable)
  331 + {
  332 + int ctorMAXS = 0;
  333 +
  334 + insns.add(new LdcInsnNode(this.name)); ctorMAXS++;
  335 + insns.add(this.methodIsStatic ? new InsnNode(Opcodes.ACONST_NULL) : new VarInsnNode(Opcodes.ALOAD, 0)); ctorMAXS++;
  336 + insns.add(new InsnNode(cancellable ? Opcodes.ICONST_1 : Opcodes.ICONST_0)); ctorMAXS++;
  337 + insns.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, this.eventInfoClass, Obf.constructor.name, EventInfo.getConstructorDescriptor(), false));
  338 +
  339 + return ctorMAXS;
  340 + }
  341 +
  342 + protected String getEventInfoClassName()
  343 + {
  344 + return EventInfo.getEventInfoClassName(this.methodReturnType).replace('.', '/');
  345 + }
  346 +
333 347 /**
334 348 * if (e.isCancelled()) return e.getReturnValue();
335 349 *
... ...