Convert BedrockPacketType from enum to extensible class to support custom packet types#322
Conversation
|
These methods aren't only for convenience, since they are directly called by packets, it provides essentially zero overhead to find which handler to jump to (except the vtable lookup to find overrides). Changing how they are handled will add a measurable overhead to packet handling. I see that you are trying to add custom packet support so the protocol library can be extended but we should do it another way that doesn't break existing code. To make BedrockPacketType extendable we could make it non-enum and store each type as a statically constructed constant object. So custom packet types can be created and registered in a registry. For the handling part I think it can stay the same, since handlePacket(BedrockPacket) already exists, for custom packets that can be overridden and handled (or even cast to a custom extension handler to provide functions that are called directly). TL;DR something like this maybe |
Done, thanks for the review |
Resolves #321