Closed Plazmaz closed 10 years ago
public delegate void PacketHandler(MinecraftClient client, IPacket packet);
public void RegisterPacketHandler(Type packetType, PacketHandler handler)
You're given the client receiving the packet, and the packet itself.
You specify the packet type you want to handle when you call RegisterPacketHandler.
Right, but where can I specify the callback? Would I just create a new delegate void and then reference that? (sorry, I'm fairly new to C#)
You pass in the name of a method that has the same signature as the PacketHandler delegate. Or you use a lambda. Or a delegate object. Research delegates in C#.
Looking into client-side packet handlers, it becomes extremely unclear as to how this is executed. In you examples you appear to access raw streams or use existing packet handlers, how is MinecraftClient.PacketHandler instantiated to point to a function?