@@ -0,0 +1,1584 @@
+package net.minecraft.src;%0A%0Aimport java.util.LinkedHashSet;%0A%0Apublic class PacketHooks %7B%0A%09public interface IPacketEventListener %7B%0A%09%09public void onPacket(Packet packet, boolean isSend);%0A%09%7D%0A%0A%09private static LinkedHashSet%3CIPacketEventListener%3E packetEventListeners = new LinkedHashSet();%0A%0A%09public static void register(IPacketEventListener listener) %7B%0A%09%09try %7B%0A%09%09%09// make sure our modifications to NetworkManager and GuiMultiplayer are present%0A%09%09%09if (!NetworkManager.packetHooks.getClass().equals(PacketHooks.class) %7C%7C%0A%09%09%09%09%09!GuiMultiplayer.packetHooks.getClass().equals(PacketHooks.class)) %7B%0A%09%09%09%09throw new RuntimeException(%22internal error%22);%0A%09%09%09%7D%0A%09%09%7D catch (LinkageError e) %7B%0A%09%09%09throw new RuntimeException(%22Unable to register packet events. This is most likely due to a mod overwriting lg.class (NetworkManager.java) or acp.class (GuiMultiplayer.java).%22, e);%0A%09%09%7D%0A%09%09packetEventListeners.add(listener);%0A%09%7D%0A%0A%09public static void unregister(IPacketEventListener listener) %7B%0A%09%09packetEventListeners.remove(listener);%0A%09%7D%0A%0A    // ====%0A%09// ==== Dispatch functions, should only be called from modified vanilla classes%0A%09// ====%0A%0A%09protected void dispatchEvent(Packet packet, boolean isSend) %7B%0A%09%09for (IPacketEventListener listener : packetEventListeners) %7B%0A%09%09%09listener.onPacket(packet, isSend);%0A%09%09%7D%0A%09%7D%0A%0A%09/** Called when there are multiple sockets open (i.e. when pinging each server on the server list) */%0A%09protected synchronized void dispatchEventSynchronized(Packet packet, boolean isSend) %7B%0A%09%09for (IPacketEventListener listener : packetEventListeners) %7B%0A%09%09%09listener.onPacket(packet, isSend);%0A%09%09%7D%0A%09%7D%0A%7D%0A

add a PacketHooks object so other mods can use the same hooks, and to validate that the hooks weren't overwritten