Commit cf1835dfa72436fdcd82ebbcd002563503241e29

Authored by Mumfrey
1 parent 30261f75

add handling to deal with packet object thread marshalling

java/client/com/mumfrey/liteloader/client/PacketEventsClient.java
@@ -8,8 +8,10 @@ import net.minecraft.network.login.server.S02PacketLoginSuccess; @@ -8,8 +8,10 @@ import net.minecraft.network.login.server.S02PacketLoginSuccess;
8 import net.minecraft.network.play.INetHandlerPlayClient; 8 import net.minecraft.network.play.INetHandlerPlayClient;
9 import net.minecraft.network.play.server.S01PacketJoinGame; 9 import net.minecraft.network.play.server.S01PacketJoinGame;
10 import net.minecraft.network.play.server.S02PacketChat; 10 import net.minecraft.network.play.server.S02PacketChat;
  11 +import net.minecraft.server.MinecraftServer;
11 import net.minecraft.util.ChatComponentText; 12 import net.minecraft.util.ChatComponentText;
12 import net.minecraft.util.IChatComponent; 13 import net.minecraft.util.IChatComponent;
  14 +import net.minecraft.util.IThreadListener;
13 15
14 import com.mojang.realmsclient.RealmsMainScreen; 16 import com.mojang.realmsclient.RealmsMainScreen;
15 import com.mojang.realmsclient.dto.RealmsServer; 17 import com.mojang.realmsclient.dto.RealmsServer;
@@ -20,13 +22,14 @@ import com.mumfrey.liteloader.PostLoginListener; @@ -20,13 +22,14 @@ import com.mumfrey.liteloader.PostLoginListener;
20 import com.mumfrey.liteloader.PreJoinGameListener; 22 import com.mumfrey.liteloader.PreJoinGameListener;
21 import com.mumfrey.liteloader.common.transformers.PacketEventInfo; 23 import com.mumfrey.liteloader.common.transformers.PacketEventInfo;
22 import com.mumfrey.liteloader.core.ClientPluginChannels; 24 import com.mumfrey.liteloader.core.ClientPluginChannels;
23 -import com.mumfrey.liteloader.core.LiteLoaderEventBroker.ReturnValue;  
24 import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate; 25 import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate;
25 import com.mumfrey.liteloader.core.LiteLoader; 26 import com.mumfrey.liteloader.core.LiteLoader;
  27 +import com.mumfrey.liteloader.core.LiteLoaderEventBroker.ReturnValue;
26 import com.mumfrey.liteloader.core.PacketEvents; 28 import com.mumfrey.liteloader.core.PacketEvents;
27 import com.mumfrey.liteloader.core.event.EventCancellationException; 29 import com.mumfrey.liteloader.core.event.EventCancellationException;
28 import com.mumfrey.liteloader.core.event.HandlerList; 30 import com.mumfrey.liteloader.core.event.HandlerList;
29 import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp; 31 import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp;
  32 +import com.mumfrey.liteloader.core.runtime.Packets;
30 import com.mumfrey.liteloader.interfaces.FastIterableDeque; 33 import com.mumfrey.liteloader.interfaces.FastIterableDeque;
31 import com.mumfrey.liteloader.transformers.event.EventInfo; 34 import com.mumfrey.liteloader.transformers.event.EventInfo;
32 import com.mumfrey.liteloader.util.log.LiteLoaderLogger; 35 import com.mumfrey.liteloader.util.log.LiteLoaderLogger;
@@ -109,6 +112,17 @@ public class PacketEventsClient extends PacketEvents @@ -109,6 +112,17 @@ public class PacketEventsClient extends PacketEvents
109 { 112 {
110 PacketEventsClient.joiningRealm = server; 113 PacketEventsClient.joiningRealm = server;
111 } 114 }
  115 +
  116 + @Override
  117 + protected IThreadListener getPacketContextListener(Packets.Context context)
  118 + {
  119 + if (context == Packets.Context.SERVER)
  120 + {
  121 + return MinecraftServer.getServer();
  122 + }
  123 +
  124 + return Minecraft.getMinecraft();
  125 + }
112 126
113 /* (non-Javadoc) 127 /* (non-Javadoc)
114 * @see com.mumfrey.liteloader.core.PacketEvents#handlePacket(com.mumfrey.liteloader.common.transformers.PacketEventInfo, net.minecraft.network.INetHandler, net.minecraft.network.play.server.S01PacketJoinGame) 128 * @see com.mumfrey.liteloader.core.PacketEvents#handlePacket(com.mumfrey.liteloader.common.transformers.PacketEventInfo, net.minecraft.network.INetHandler, net.minecraft.network.play.server.S01PacketJoinGame)
java/common/com/mumfrey/liteloader/core/PacketEvents.java
@@ -12,6 +12,7 @@ import net.minecraft.network.play.client.C17PacketCustomPayload; @@ -12,6 +12,7 @@ import net.minecraft.network.play.client.C17PacketCustomPayload;
12 import net.minecraft.network.play.server.S01PacketJoinGame; 12 import net.minecraft.network.play.server.S01PacketJoinGame;
13 import net.minecraft.network.play.server.S02PacketChat; 13 import net.minecraft.network.play.server.S02PacketChat;
14 import net.minecraft.network.play.server.S3FPacketCustomPayload; 14 import net.minecraft.network.play.server.S3FPacketCustomPayload;
  15 +import net.minecraft.util.IThreadListener;
15 16
16 import com.mumfrey.liteloader.PacketHandler; 17 import com.mumfrey.liteloader.PacketHandler;
17 import com.mumfrey.liteloader.ServerChatFilter; 18 import com.mumfrey.liteloader.ServerChatFilter;
@@ -119,6 +120,13 @@ public abstract class PacketEvents implements InterfaceProvider @@ -119,6 +120,13 @@ public abstract class PacketEvents implements InterfaceProvider
119 120
120 private void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, int packetId) 121 private void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, int packetId)
121 { 122 {
  123 + Packets packetInfo = Packets.packets[e.getPacketId()];
  124 + IThreadListener threadListener = this.getPacketContextListener(packetInfo.getContext());
  125 + if (threadListener != null && !threadListener.isCallingFromMinecraftThread())
  126 + {
  127 + return;
  128 + }
  129 +
122 if (this.handlePacketEvent(e, netHandler, packetId) || this.packetHandlers[packetId] == null || e.isCancelled()) 130 if (this.handlePacketEvent(e, netHandler, packetId) || this.packetHandlers[packetId] == null || e.isCancelled())
123 { 131 {
124 return; 132 return;
@@ -133,6 +141,13 @@ public abstract class PacketEvents implements InterfaceProvider @@ -133,6 +141,13 @@ public abstract class PacketEvents implements InterfaceProvider
133 } 141 }
134 142
135 /** 143 /**
  144 + *
  145 + * @param context
  146 + * @return
  147 + */
  148 + protected abstract IThreadListener getPacketContextListener(Packets.Context context);
  149 +
  150 + /**
136 * @param e 151 * @param e
137 * @param netHandler 152 * @param netHandler
138 * @param packetId 153 * @param packetId
java/common/com/mumfrey/liteloader/core/runtime/Packets.java
@@ -11,119 +11,133 @@ import java.util.Map; @@ -11,119 +11,133 @@ import java.util.Map;
11 */ 11 */
12 public class Packets extends Obf 12 public class Packets extends Obf
13 { 13 {
  14 + /**
  15 + * Since we need to catch and deal with the fact that a packet is first marshalled across threads via PacketThreadUtil, we
  16 + * will need to know which owner object to check against the current thread in order to detect when the packet instance is being
  17 + * processed by the main message loop. The Context object describes in which context (client or server) that a particular packet
  18 + * will be processed in on the <em>receiving</em> end, and thus which object to check threading against.
  19 + *
  20 + * @author Adam Mummery-Smith
  21 + */
  22 + public enum Context
  23 + {
  24 + CLIENT,
  25 + SERVER
  26 + }
  27 +
14 private static Map<String, Packets> packetMap = new HashMap<String, Packets>(); 28 private static Map<String, Packets> packetMap = new HashMap<String, Packets>();
15 29
16 - public static Packets S08PacketPlayerPosLook = new Packets("net.minecraft.network.play.server.S08PacketPlayerPosLook", "ii");  
17 - public static Packets S0EPacketSpawnObject = new Packets("net.minecraft.network.play.server.S0EPacketSpawnObject", "il");  
18 - public static Packets S11PacketSpawnExperienceOrb = new Packets("net.minecraft.network.play.server.S11PacketSpawnExperienceOrb", "im");  
19 - public static Packets S2CPacketSpawnGlobalEntity = new Packets("net.minecraft.network.play.server.S2CPacketSpawnGlobalEntity", "in");  
20 - public static Packets S0FPacketSpawnMob = new Packets("net.minecraft.network.play.server.S0FPacketSpawnMob", "io");  
21 - public static Packets S10PacketSpawnPainting = new Packets("net.minecraft.network.play.server.S10PacketSpawnPainting", "ip");  
22 - public static Packets S0CPacketSpawnPlayer = new Packets("net.minecraft.network.play.server.S0CPacketSpawnPlayer", "iq");  
23 - public static Packets S0BPacketAnimation = new Packets("net.minecraft.network.play.server.S0BPacketAnimation", "ir");  
24 - public static Packets S37PacketStatistics = new Packets("net.minecraft.network.play.server.S37PacketStatistics", "is");  
25 - public static Packets S25PacketBlockBreakAnim = new Packets("net.minecraft.network.play.server.S25PacketBlockBreakAnim", "it");  
26 - public static Packets S35PacketUpdateTileEntity = new Packets("net.minecraft.network.play.server.S35PacketUpdateTileEntity", "iu");  
27 - public static Packets S24PacketBlockAction = new Packets("net.minecraft.network.play.server.S24PacketBlockAction", "iv");  
28 - public static Packets S23PacketBlockChange = new Packets("net.minecraft.network.play.server.S23PacketBlockChange", "iw");  
29 - public static Packets S41PacketServerDifficulty = new Packets("net.minecraft.network.play.server.S41PacketServerDifficulty", "ix");  
30 - public static Packets S3APacketTabComplete = new Packets("net.minecraft.network.play.server.S3APacketTabComplete", "iy");  
31 - public static Packets S02PacketChat = new Packets("net.minecraft.network.play.server.S02PacketChat", "iz");  
32 - public static Packets S22PacketMultiBlockChange = new Packets("net.minecraft.network.play.server.S22PacketMultiBlockChange", "ja");  
33 - public static Packets S32PacketConfirmTransaction = new Packets("net.minecraft.network.play.server.S32PacketConfirmTransaction", "jc");  
34 - public static Packets S2EPacketCloseWindow = new Packets("net.minecraft.network.play.server.S2EPacketCloseWindow", "jd");  
35 - public static Packets S2DPacketOpenWindow = new Packets("net.minecraft.network.play.server.S2DPacketOpenWindow", "je");  
36 - public static Packets S30PacketWindowItems = new Packets("net.minecraft.network.play.server.S30PacketWindowItems", "jf");  
37 - public static Packets S31PacketWindowProperty = new Packets("net.minecraft.network.play.server.S31PacketWindowProperty", "jg");  
38 - public static Packets S2FPacketSetSlot = new Packets("net.minecraft.network.play.server.S2FPacketSetSlot", "jh");  
39 - public static Packets S3FPacketCustomPayload = new Packets("net.minecraft.network.play.server.S3FPacketCustomPayload", "ji");  
40 - public static Packets S40PacketDisconnect = new Packets("net.minecraft.network.play.server.S40PacketDisconnect", "jj");  
41 - public static Packets S19PacketEntityStatus = new Packets("net.minecraft.network.play.server.S19PacketEntityStatus", "jk");  
42 - public static Packets S49PacketUpdateEntityNBT = new Packets("net.minecraft.network.play.server.S49PacketUpdateEntityNBT", "jl");  
43 - public static Packets S27PacketExplosion = new Packets("net.minecraft.network.play.server.S27PacketExplosion", "jm");  
44 - public static Packets S46PacketSetCompressionLevel = new Packets("net.minecraft.network.play.server.S46PacketSetCompressionLevel", "jn");  
45 - public static Packets S2BPacketChangeGameState = new Packets("net.minecraft.network.play.server.S2BPacketChangeGameState", "jo");  
46 - public static Packets S00PacketKeepAlive = new Packets("net.minecraft.network.play.server.S00PacketKeepAlive", "jp");  
47 - public static Packets S21PacketChunkData = new Packets("net.minecraft.network.play.server.S21PacketChunkData", "jq");  
48 - public static Packets S26PacketMapChunkBulk = new Packets("net.minecraft.network.play.server.S26PacketMapChunkBulk", "js");  
49 - public static Packets S28PacketEffect = new Packets("net.minecraft.network.play.server.S28PacketEffect", "jt");  
50 - public static Packets S2APacketParticles = new Packets("net.minecraft.network.play.server.S2APacketParticles", "ju");  
51 - public static Packets S29PacketSoundEffect = new Packets("net.minecraft.network.play.server.S29PacketSoundEffect", "jv");  
52 - public static Packets S01PacketJoinGame = new Packets("net.minecraft.network.play.server.S01PacketJoinGame", "jw");  
53 - public static Packets S34PacketMaps = new Packets("net.minecraft.network.play.server.S34PacketMaps", "jx");  
54 - public static Packets S14PacketEntity = new Packets("net.minecraft.network.play.server.S14PacketEntity", "jy");  
55 - public static Packets S15PacketEntityRelMove = new Packets("net.minecraft.network.play.server.S14PacketEntity$S15PacketEntityRelMove", "jz");  
56 - public static Packets S17PacketEntityLookMove = new Packets("net.minecraft.network.play.server.S14PacketEntity$S17PacketEntityLookMove", "ka");  
57 - public static Packets S16PacketEntityLook = new Packets("net.minecraft.network.play.server.S14PacketEntity$S16PacketEntityLook", "kb");  
58 - public static Packets S36PacketSignEditorOpen = new Packets("net.minecraft.network.play.server.S36PacketSignEditorOpen", "kc");  
59 - public static Packets S39PacketPlayerAbilities = new Packets("net.minecraft.network.play.server.S39PacketPlayerAbilities", "kd");  
60 - public static Packets S42PacketCombatEvent = new Packets("net.minecraft.network.play.server.S42PacketCombatEvent", "ke");  
61 - public static Packets S38PacketPlayerListItem = new Packets("net.minecraft.network.play.server.S38PacketPlayerListItem", "kh");  
62 - public static Packets S0APacketUseBed = new Packets("net.minecraft.network.play.server.S0APacketUseBed", "kl");  
63 - public static Packets S13PacketDestroyEntities = new Packets("net.minecraft.network.play.server.S13PacketDestroyEntities", "km");  
64 - public static Packets S1EPacketRemoveEntityEffect = new Packets("net.minecraft.network.play.server.S1EPacketRemoveEntityEffect", "kn");  
65 - public static Packets S48PacketResourcePackSend = new Packets("net.minecraft.network.play.server.S48PacketResourcePackSend", "ko");  
66 - public static Packets S07PacketRespawn = new Packets("net.minecraft.network.play.server.S07PacketRespawn", "kp");  
67 - public static Packets S19PacketEntityHeadLook = new Packets("net.minecraft.network.play.server.S19PacketEntityHeadLook", "kq");  
68 - public static Packets S44PacketWorldBorder = new Packets("net.minecraft.network.play.server.S44PacketWorldBorder", "kr");  
69 - public static Packets S43PacketCamera = new Packets("net.minecraft.network.play.server.S43PacketCamera", "ku");  
70 - public static Packets S09PacketHeldItemChange = new Packets("net.minecraft.network.play.server.S09PacketHeldItemChange", "kv");  
71 - public static Packets S3DPacketDisplayScoreboard = new Packets("net.minecraft.network.play.server.S3DPacketDisplayScoreboard", "kw");  
72 - public static Packets S1CPacketEntityMetadata = new Packets("net.minecraft.network.play.server.S1CPacketEntityMetadata", "kx");  
73 - public static Packets S1BPacketEntityAttach = new Packets("net.minecraft.network.play.server.S1BPacketEntityAttach", "ky");  
74 - public static Packets S12PacketEntityVelocity = new Packets("net.minecraft.network.play.server.S12PacketEntityVelocity", "kz");  
75 - public static Packets S04PacketEntityEquipment = new Packets("net.minecraft.network.play.server.S04PacketEntityEquipment", "la");  
76 - public static Packets S1FPacketSetExperience = new Packets("net.minecraft.network.play.server.S1FPacketSetExperience", "lb");  
77 - public static Packets S06PacketUpdateHealth = new Packets("net.minecraft.network.play.server.S06PacketUpdateHealth", "lc");  
78 - public static Packets S3BPacketScoreboardObjective = new Packets("net.minecraft.network.play.server.S3BPacketScoreboardObjective", "ld");  
79 - public static Packets S3EPacketTeams = new Packets("net.minecraft.network.play.server.S3EPacketTeams", "le");  
80 - public static Packets S3CPacketUpdateScore = new Packets("net.minecraft.network.play.server.S3CPacketUpdateScore", "lf");  
81 - public static Packets S05PacketSpawnPosition = new Packets("net.minecraft.network.play.server.S05PacketSpawnPosition", "lh");  
82 - public static Packets S03PacketTimeUpdate = new Packets("net.minecraft.network.play.server.S03PacketTimeUpdate", "li");  
83 - public static Packets S45PacketTitle = new Packets("net.minecraft.network.play.server.S45PacketTitle", "lj");  
84 - public static Packets S33PacketUpdateSign = new Packets("net.minecraft.network.play.server.S33PacketUpdateSign", "ll");  
85 - public static Packets S47PacketPlayerListHeaderFooter = new Packets("net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter", "lm");  
86 - public static Packets S0DPacketCollectItem = new Packets("net.minecraft.network.play.server.S0DPacketCollectItem", "ln");  
87 - public static Packets S18PacketEntityTeleport = new Packets("net.minecraft.network.play.server.S18PacketEntityTeleport", "lo");  
88 - public static Packets S20PacketEntityProperties = new Packets("net.minecraft.network.play.server.S20PacketEntityProperties", "lp");  
89 - public static Packets S1DPacketEntityEffect = new Packets("net.minecraft.network.play.server.S1DPacketEntityEffect", "lr");  
90 - public static Packets C14PacketTabComplete = new Packets("net.minecraft.network.play.client.C14PacketTabComplete", "lt");  
91 - public static Packets C01PacketChatMessage = new Packets("net.minecraft.network.play.client.C01PacketChatMessage", "lu");  
92 - public static Packets C16PacketClientStatus = new Packets("net.minecraft.network.play.client.C16PacketClientStatus", "lv");  
93 - public static Packets C15PacketClientSettings = new Packets("net.minecraft.network.play.client.C15PacketClientSettings", "lx");  
94 - public static Packets C0FPacketConfirmTransaction = new Packets("net.minecraft.network.play.client.C0FPacketConfirmTransaction", "ly");  
95 - public static Packets C11PacketEnchantItem = new Packets("net.minecraft.network.play.client.C11PacketEnchantItem", "lz");  
96 - public static Packets C0EPacketClickWindow = new Packets("net.minecraft.network.play.client.C0EPacketClickWindow", "ma");  
97 - public static Packets C0DPacketCloseWindow = new Packets("net.minecraft.network.play.client.C0DPacketCloseWindow", "mb");  
98 - public static Packets C17PacketCustomPayload = new Packets("net.minecraft.network.play.client.C17PacketCustomPayload", "mc");  
99 - public static Packets C02PacketUseEntity = new Packets("net.minecraft.network.play.client.C02PacketUseEntity", "md");  
100 - public static Packets C00PacketKeepAlive = new Packets("net.minecraft.network.play.client.C00PacketKeepAlive", "mf");  
101 - public static Packets C03PacketPlayer = new Packets("net.minecraft.network.play.client.C03PacketPlayer", "mg");  
102 - public static Packets C04PacketPlayerPosition = new Packets("net.minecraft.network.play.client.C03PacketPlayer$C04PacketPlayerPosition", "mh");  
103 - public static Packets C06PacketPlayerPosLook = new Packets("net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook", "mi");  
104 - public static Packets C05PacketPlayerLook = new Packets("net.minecraft.network.play.client.C03PacketPlayer$C05PacketPlayerLook", "mj");  
105 - public static Packets C13PacketPlayerAbilities = new Packets("net.minecraft.network.play.client.C13PacketPlayerAbilities", "mk");  
106 - public static Packets C07PacketPlayerDigging = new Packets("net.minecraft.network.play.client.C07PacketPlayerDigging", "ml");  
107 - public static Packets C0BPacketEntityAction = new Packets("net.minecraft.network.play.client.C0BPacketEntityAction", "mn");  
108 - public static Packets C0CPacketInput = new Packets("net.minecraft.network.play.client.C0CPacketInput", "mp");  
109 - public static Packets C19PacketResourcePackStatus = new Packets("net.minecraft.network.play.client.C19PacketResourcePackStatus", "mq");  
110 - public static Packets C09PacketHeldItemChange = new Packets("net.minecraft.network.play.client.C09PacketHeldItemChange", "ms");  
111 - public static Packets C10PacketCreativeInventoryAction = new Packets("net.minecraft.network.play.client.C10PacketCreativeInventoryAction", "mt");  
112 - public static Packets C12PacketUpdateSign = new Packets("net.minecraft.network.play.client.C12PacketUpdateSign", "mu");  
113 - public static Packets C0APacketAnimation = new Packets("net.minecraft.network.play.client.C0APacketAnimation", "mv");  
114 - public static Packets C18PacketSpectate = new Packets("net.minecraft.network.play.client.C18PacketSpectate", "mw");  
115 - public static Packets C08PacketPlayerBlockPlacement = new Packets("net.minecraft.network.play.client.C08PacketPlayerBlockPlacement", "mx");  
116 - public static Packets C00Handshake = new Packets("net.minecraft.network.handshake.client.C00Handshake", "mz");  
117 - public static Packets S02PacketLoginSuccess = new Packets("net.minecraft.network.login.server.S02PacketLoginSuccess", "nd");  
118 - public static Packets S01PacketEncryptionRequest = new Packets("net.minecraft.network.login.server.S01PacketEncryptionRequest", "ne");  
119 - public static Packets S03PacketEnableCompression = new Packets("net.minecraft.network.login.server.S03PacketEnableCompression", "nf");  
120 - public static Packets S00PacketDisconnect = new Packets("net.minecraft.network.login.server.S00PacketDisconnect", "ng");  
121 - public static Packets C00PacketLoginStart = new Packets("net.minecraft.network.login.client.C00PacketLoginStart", "ni");  
122 - public static Packets C01PacketEncryptionResponse = new Packets("net.minecraft.network.login.client.C01PacketEncryptionResponse", "nj");  
123 - public static Packets S01PacketPong = new Packets("net.minecraft.network.status.server.S01PacketPong", "nn");  
124 - public static Packets S00PacketServerInfo = new Packets("net.minecraft.network.status.server.S00PacketServerInfo", "no");  
125 - public static Packets C01PacketPing = new Packets("net.minecraft.network.status.client.C01PacketPing", "nw");  
126 - public static Packets C00PacketServerQuery = new Packets("net.minecraft.network.status.client.C00PacketServerQuery", "nx"); 30 + public static Packets S08PacketPlayerPosLook = new Packets("net.minecraft.network.play.server.S08PacketPlayerPosLook", "ii", Context.CLIENT);
  31 + public static Packets S0EPacketSpawnObject = new Packets("net.minecraft.network.play.server.S0EPacketSpawnObject", "il", Context.CLIENT);
  32 + public static Packets S11PacketSpawnExperienceOrb = new Packets("net.minecraft.network.play.server.S11PacketSpawnExperienceOrb", "im", Context.CLIENT);
  33 + public static Packets S2CPacketSpawnGlobalEntity = new Packets("net.minecraft.network.play.server.S2CPacketSpawnGlobalEntity", "in", Context.CLIENT);
  34 + public static Packets S0FPacketSpawnMob = new Packets("net.minecraft.network.play.server.S0FPacketSpawnMob", "io", Context.CLIENT);
  35 + public static Packets S10PacketSpawnPainting = new Packets("net.minecraft.network.play.server.S10PacketSpawnPainting", "ip", Context.CLIENT);
  36 + public static Packets S0CPacketSpawnPlayer = new Packets("net.minecraft.network.play.server.S0CPacketSpawnPlayer", "iq", Context.CLIENT);
  37 + public static Packets S0BPacketAnimation = new Packets("net.minecraft.network.play.server.S0BPacketAnimation", "ir", Context.CLIENT);
  38 + public static Packets S37PacketStatistics = new Packets("net.minecraft.network.play.server.S37PacketStatistics", "is", Context.CLIENT);
  39 + public static Packets S25PacketBlockBreakAnim = new Packets("net.minecraft.network.play.server.S25PacketBlockBreakAnim", "it", Context.CLIENT);
  40 + public static Packets S35PacketUpdateTileEntity = new Packets("net.minecraft.network.play.server.S35PacketUpdateTileEntity", "iu", Context.CLIENT);
  41 + public static Packets S24PacketBlockAction = new Packets("net.minecraft.network.play.server.S24PacketBlockAction", "iv", Context.CLIENT);
  42 + public static Packets S23PacketBlockChange = new Packets("net.minecraft.network.play.server.S23PacketBlockChange", "iw", Context.CLIENT);
  43 + public static Packets S41PacketServerDifficulty = new Packets("net.minecraft.network.play.server.S41PacketServerDifficulty", "ix", Context.CLIENT);
  44 + public static Packets S3APacketTabComplete = new Packets("net.minecraft.network.play.server.S3APacketTabComplete", "iy", Context.CLIENT);
  45 + public static Packets S02PacketChat = new Packets("net.minecraft.network.play.server.S02PacketChat", "iz", Context.CLIENT);
  46 + public static Packets S22PacketMultiBlockChange = new Packets("net.minecraft.network.play.server.S22PacketMultiBlockChange", "ja", Context.CLIENT);
  47 + public static Packets S32PacketConfirmTransaction = new Packets("net.minecraft.network.play.server.S32PacketConfirmTransaction", "jc", Context.CLIENT);
  48 + public static Packets S2EPacketCloseWindow = new Packets("net.minecraft.network.play.server.S2EPacketCloseWindow", "jd", Context.CLIENT);
  49 + public static Packets S2DPacketOpenWindow = new Packets("net.minecraft.network.play.server.S2DPacketOpenWindow", "je", Context.CLIENT);
  50 + public static Packets S30PacketWindowItems = new Packets("net.minecraft.network.play.server.S30PacketWindowItems", "jf", Context.CLIENT);
  51 + public static Packets S31PacketWindowProperty = new Packets("net.minecraft.network.play.server.S31PacketWindowProperty", "jg", Context.CLIENT);
  52 + public static Packets S2FPacketSetSlot = new Packets("net.minecraft.network.play.server.S2FPacketSetSlot", "jh", Context.CLIENT);
  53 + public static Packets S3FPacketCustomPayload = new Packets("net.minecraft.network.play.server.S3FPacketCustomPayload", "ji", Context.CLIENT);
  54 + public static Packets S40PacketDisconnect = new Packets("net.minecraft.network.play.server.S40PacketDisconnect", "jj", Context.CLIENT);
  55 + public static Packets S19PacketEntityStatus = new Packets("net.minecraft.network.play.server.S19PacketEntityStatus", "jk", Context.CLIENT);
  56 + public static Packets S49PacketUpdateEntityNBT = new Packets("net.minecraft.network.play.server.S49PacketUpdateEntityNBT", "jl", Context.CLIENT);
  57 + public static Packets S27PacketExplosion = new Packets("net.minecraft.network.play.server.S27PacketExplosion", "jm", Context.CLIENT);
  58 + public static Packets S46PacketSetCompressionLevel = new Packets("net.minecraft.network.play.server.S46PacketSetCompressionLevel", "jn", Context.CLIENT);
  59 + public static Packets S2BPacketChangeGameState = new Packets("net.minecraft.network.play.server.S2BPacketChangeGameState", "jo", Context.CLIENT);
  60 + public static Packets S00PacketKeepAlive = new Packets("net.minecraft.network.play.server.S00PacketKeepAlive", "jp", Context.CLIENT);
  61 + public static Packets S21PacketChunkData = new Packets("net.minecraft.network.play.server.S21PacketChunkData", "jq", Context.CLIENT);
  62 + public static Packets S26PacketMapChunkBulk = new Packets("net.minecraft.network.play.server.S26PacketMapChunkBulk", "js", Context.CLIENT);
  63 + public static Packets S28PacketEffect = new Packets("net.minecraft.network.play.server.S28PacketEffect", "jt", Context.CLIENT);
  64 + public static Packets S2APacketParticles = new Packets("net.minecraft.network.play.server.S2APacketParticles", "ju", Context.CLIENT);
  65 + public static Packets S29PacketSoundEffect = new Packets("net.minecraft.network.play.server.S29PacketSoundEffect", "jv", Context.CLIENT);
  66 + public static Packets S01PacketJoinGame = new Packets("net.minecraft.network.play.server.S01PacketJoinGame", "jw", Context.CLIENT);
  67 + public static Packets S34PacketMaps = new Packets("net.minecraft.network.play.server.S34PacketMaps", "jx", Context.CLIENT);
  68 + public static Packets S14PacketEntity = new Packets("net.minecraft.network.play.server.S14PacketEntity", "jy", Context.CLIENT);
  69 + public static Packets S15PacketEntityRelMove = new Packets("net.minecraft.network.play.server.S14PacketEntity$S15PacketEntityRelMove", "jz", Context.CLIENT);
  70 + public static Packets S17PacketEntityLookMove = new Packets("net.minecraft.network.play.server.S14PacketEntity$S17PacketEntityLookMove", "ka", Context.CLIENT);
  71 + public static Packets S16PacketEntityLook = new Packets("net.minecraft.network.play.server.S14PacketEntity$S16PacketEntityLook", "kb", Context.CLIENT);
  72 + public static Packets S36PacketSignEditorOpen = new Packets("net.minecraft.network.play.server.S36PacketSignEditorOpen", "kc", Context.CLIENT);
  73 + public static Packets S39PacketPlayerAbilities = new Packets("net.minecraft.network.play.server.S39PacketPlayerAbilities", "kd", Context.CLIENT);
  74 + public static Packets S42PacketCombatEvent = new Packets("net.minecraft.network.play.server.S42PacketCombatEvent", "ke", Context.CLIENT);
  75 + public static Packets S38PacketPlayerListItem = new Packets("net.minecraft.network.play.server.S38PacketPlayerListItem", "kh", Context.CLIENT);
  76 + public static Packets S0APacketUseBed = new Packets("net.minecraft.network.play.server.S0APacketUseBed", "kl", Context.CLIENT);
  77 + public static Packets S13PacketDestroyEntities = new Packets("net.minecraft.network.play.server.S13PacketDestroyEntities", "km", Context.CLIENT);
  78 + public static Packets S1EPacketRemoveEntityEffect = new Packets("net.minecraft.network.play.server.S1EPacketRemoveEntityEffect", "kn", Context.CLIENT);
  79 + public static Packets S48PacketResourcePackSend = new Packets("net.minecraft.network.play.server.S48PacketResourcePackSend", "ko", Context.CLIENT);
  80 + public static Packets S07PacketRespawn = new Packets("net.minecraft.network.play.server.S07PacketRespawn", "kp", Context.CLIENT);
  81 + public static Packets S19PacketEntityHeadLook = new Packets("net.minecraft.network.play.server.S19PacketEntityHeadLook", "kq", Context.CLIENT);
  82 + public static Packets S44PacketWorldBorder = new Packets("net.minecraft.network.play.server.S44PacketWorldBorder", "kr", Context.CLIENT);
  83 + public static Packets S43PacketCamera = new Packets("net.minecraft.network.play.server.S43PacketCamera", "ku", Context.CLIENT);
  84 + public static Packets S09PacketHeldItemChange = new Packets("net.minecraft.network.play.server.S09PacketHeldItemChange", "kv", Context.CLIENT);
  85 + public static Packets S3DPacketDisplayScoreboard = new Packets("net.minecraft.network.play.server.S3DPacketDisplayScoreboard", "kw", Context.CLIENT);
  86 + public static Packets S1CPacketEntityMetadata = new Packets("net.minecraft.network.play.server.S1CPacketEntityMetadata", "kx", Context.CLIENT);
  87 + public static Packets S1BPacketEntityAttach = new Packets("net.minecraft.network.play.server.S1BPacketEntityAttach", "ky", Context.CLIENT);
  88 + public static Packets S12PacketEntityVelocity = new Packets("net.minecraft.network.play.server.S12PacketEntityVelocity", "kz", Context.CLIENT);
  89 + public static Packets S04PacketEntityEquipment = new Packets("net.minecraft.network.play.server.S04PacketEntityEquipment", "la", Context.CLIENT);
  90 + public static Packets S1FPacketSetExperience = new Packets("net.minecraft.network.play.server.S1FPacketSetExperience", "lb", Context.CLIENT);
  91 + public static Packets S06PacketUpdateHealth = new Packets("net.minecraft.network.play.server.S06PacketUpdateHealth", "lc", Context.CLIENT);
  92 + public static Packets S3BPacketScoreboardObjective = new Packets("net.minecraft.network.play.server.S3BPacketScoreboardObjective", "ld", Context.CLIENT);
  93 + public static Packets S3EPacketTeams = new Packets("net.minecraft.network.play.server.S3EPacketTeams", "le", Context.CLIENT);
  94 + public static Packets S3CPacketUpdateScore = new Packets("net.minecraft.network.play.server.S3CPacketUpdateScore", "lf", Context.CLIENT);
  95 + public static Packets S05PacketSpawnPosition = new Packets("net.minecraft.network.play.server.S05PacketSpawnPosition", "lh", Context.CLIENT);
  96 + public static Packets S03PacketTimeUpdate = new Packets("net.minecraft.network.play.server.S03PacketTimeUpdate", "li", Context.CLIENT);
  97 + public static Packets S45PacketTitle = new Packets("net.minecraft.network.play.server.S45PacketTitle", "lj", Context.CLIENT);
  98 + public static Packets S33PacketUpdateSign = new Packets("net.minecraft.network.play.server.S33PacketUpdateSign", "ll", Context.CLIENT);
  99 + public static Packets S47PacketPlayerListHeaderFooter = new Packets("net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter", "lm", Context.CLIENT);
  100 + public static Packets S0DPacketCollectItem = new Packets("net.minecraft.network.play.server.S0DPacketCollectItem", "ln", Context.CLIENT);
  101 + public static Packets S18PacketEntityTeleport = new Packets("net.minecraft.network.play.server.S18PacketEntityTeleport", "lo", Context.CLIENT);
  102 + public static Packets S20PacketEntityProperties = new Packets("net.minecraft.network.play.server.S20PacketEntityProperties", "lp", Context.CLIENT);
  103 + public static Packets S1DPacketEntityEffect = new Packets("net.minecraft.network.play.server.S1DPacketEntityEffect", "lr", Context.CLIENT);
  104 + public static Packets C14PacketTabComplete = new Packets("net.minecraft.network.play.client.C14PacketTabComplete", "lt", Context.SERVER);
  105 + public static Packets C01PacketChatMessage = new Packets("net.minecraft.network.play.client.C01PacketChatMessage", "lu", Context.SERVER);
  106 + public static Packets C16PacketClientStatus = new Packets("net.minecraft.network.play.client.C16PacketClientStatus", "lv", Context.SERVER);
  107 + public static Packets C15PacketClientSettings = new Packets("net.minecraft.network.play.client.C15PacketClientSettings", "lx", Context.SERVER);
  108 + public static Packets C0FPacketConfirmTransaction = new Packets("net.minecraft.network.play.client.C0FPacketConfirmTransaction", "ly", Context.SERVER);
  109 + public static Packets C11PacketEnchantItem = new Packets("net.minecraft.network.play.client.C11PacketEnchantItem", "lz", Context.SERVER);
  110 + public static Packets C0EPacketClickWindow = new Packets("net.minecraft.network.play.client.C0EPacketClickWindow", "ma", Context.SERVER);
  111 + public static Packets C0DPacketCloseWindow = new Packets("net.minecraft.network.play.client.C0DPacketCloseWindow", "mb", Context.SERVER);
  112 + public static Packets C17PacketCustomPayload = new Packets("net.minecraft.network.play.client.C17PacketCustomPayload", "mc", Context.SERVER);
  113 + public static Packets C02PacketUseEntity = new Packets("net.minecraft.network.play.client.C02PacketUseEntity", "md", Context.SERVER);
  114 + public static Packets C00PacketKeepAlive = new Packets("net.minecraft.network.play.client.C00PacketKeepAlive", "mf", Context.SERVER);
  115 + public static Packets C03PacketPlayer = new Packets("net.minecraft.network.play.client.C03PacketPlayer", "mg", Context.SERVER);
  116 + public static Packets C04PacketPlayerPosition = new Packets("net.minecraft.network.play.client.C03PacketPlayer$C04PacketPlayerPosition", "mh", Context.SERVER);
  117 + public static Packets C06PacketPlayerPosLook = new Packets("net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook", "mi", Context.SERVER);
  118 + public static Packets C05PacketPlayerLook = new Packets("net.minecraft.network.play.client.C03PacketPlayer$C05PacketPlayerLook", "mj", Context.SERVER);
  119 + public static Packets C13PacketPlayerAbilities = new Packets("net.minecraft.network.play.client.C13PacketPlayerAbilities", "mk", Context.SERVER);
  120 + public static Packets C07PacketPlayerDigging = new Packets("net.minecraft.network.play.client.C07PacketPlayerDigging", "ml", Context.SERVER);
  121 + public static Packets C0BPacketEntityAction = new Packets("net.minecraft.network.play.client.C0BPacketEntityAction", "mn", Context.SERVER);
  122 + public static Packets C0CPacketInput = new Packets("net.minecraft.network.play.client.C0CPacketInput", "mp", Context.SERVER);
  123 + public static Packets C19PacketResourcePackStatus = new Packets("net.minecraft.network.play.client.C19PacketResourcePackStatus", "mq", Context.SERVER);
  124 + public static Packets C09PacketHeldItemChange = new Packets("net.minecraft.network.play.client.C09PacketHeldItemChange", "ms", Context.SERVER);
  125 + public static Packets C10PacketCreativeInventoryAction = new Packets("net.minecraft.network.play.client.C10PacketCreativeInventoryAction", "mt", Context.SERVER);
  126 + public static Packets C12PacketUpdateSign = new Packets("net.minecraft.network.play.client.C12PacketUpdateSign", "mu", Context.SERVER);
  127 + public static Packets C0APacketAnimation = new Packets("net.minecraft.network.play.client.C0APacketAnimation", "mv", Context.SERVER);
  128 + public static Packets C18PacketSpectate = new Packets("net.minecraft.network.play.client.C18PacketSpectate", "mw", Context.SERVER);
  129 + public static Packets C08PacketPlayerBlockPlacement = new Packets("net.minecraft.network.play.client.C08PacketPlayerBlockPlacement", "mx", Context.SERVER);
  130 + public static Packets C00Handshake = new Packets("net.minecraft.network.handshake.client.C00Handshake", "mz", Context.SERVER);
  131 + public static Packets S02PacketLoginSuccess = new Packets("net.minecraft.network.login.server.S02PacketLoginSuccess", "nd", Context.CLIENT);
  132 + public static Packets S01PacketEncryptionRequest = new Packets("net.minecraft.network.login.server.S01PacketEncryptionRequest", "ne", Context.CLIENT);
  133 + public static Packets S03PacketEnableCompression = new Packets("net.minecraft.network.login.server.S03PacketEnableCompression", "nf", Context.CLIENT);
  134 + public static Packets S00PacketDisconnect = new Packets("net.minecraft.network.login.server.S00PacketDisconnect", "ng", Context.CLIENT);
  135 + public static Packets C00PacketLoginStart = new Packets("net.minecraft.network.login.client.C00PacketLoginStart", "ni", Context.SERVER);
  136 + public static Packets C01PacketEncryptionResponse = new Packets("net.minecraft.network.login.client.C01PacketEncryptionResponse", "nj", Context.SERVER);
  137 + public static Packets S01PacketPong = new Packets("net.minecraft.network.status.server.S01PacketPong", "nn", Context.CLIENT);
  138 + public static Packets S00PacketServerInfo = new Packets("net.minecraft.network.status.server.S00PacketServerInfo", "no", Context.CLIENT);
  139 + public static Packets C01PacketPing = new Packets("net.minecraft.network.status.client.C01PacketPing", "nw", Context.SERVER);
  140 + public static Packets C00PacketServerQuery = new Packets("net.minecraft.network.status.client.C00PacketServerQuery", "nx", Context.SERVER);
127 141
128 public static final Packets[] packets = new Packets[] { 142 public static final Packets[] packets = new Packets[] {
129 S08PacketPlayerPosLook, 143 S08PacketPlayerPosLook,
@@ -245,13 +259,16 @@ public class Packets extends Obf @@ -245,13 +259,16 @@ public class Packets extends Obf
245 259
246 private final int index; 260 private final int index;
247 261
248 - private Packets(String seargeName, String obfName) 262 + private final Context context;
  263 +
  264 + private Packets(String seargeName, String obfName, Context context)
249 { 265 {
250 super(seargeName, obfName); 266 super(seargeName, obfName);
251 267
252 this.shortName = seargeName.substring(Math.max(seargeName.lastIndexOf('.'), seargeName.lastIndexOf('$')) + 1); 268 this.shortName = seargeName.substring(Math.max(seargeName.lastIndexOf('.'), seargeName.lastIndexOf('$')) + 1);
253 this.index = Packets.nextPacketIndex++; 269 this.index = Packets.nextPacketIndex++;
254 Packets.packetMap.put(this.shortName, this); 270 Packets.packetMap.put(this.shortName, this);
  271 + this.context = context;
255 } 272 }
256 273
257 public int getIndex() 274 public int getIndex()
@@ -263,6 +280,11 @@ public class Packets extends Obf @@ -263,6 +280,11 @@ public class Packets extends Obf
263 { 280 {
264 return this.shortName; 281 return this.shortName;
265 } 282 }
  283 +
  284 + public Context getContext()
  285 + {
  286 + return this.context;
  287 + }
266 288
267 public static int indexOf(String packetClassName) 289 public static int indexOf(String packetClassName)
268 { 290 {