Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staticify all serialization helpers #878

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlexProgrammerDE
Copy link
Contributor

@AlexProgrammerDE AlexProgrammerDE commented Jan 18, 2025

First of all, why am I changing the whole API so that MinecraftCodecHelper is now static instead of an instance? The reason is that these methods are better used statically. Right now the biggest issue with MCPL I see is its reliance on "serialization instances" that are being passed around everywhere. Why were those even made in the first place? Because there was a belief a few years ago that MCPL could somehow ever support multiple versions of Minecraft. The idea is good however it is unrealistic. Packets change heavily between versions and rarely do serialization types. Serialization instances were made with the idea somehow you could implement multiple codechelpers for each version and "downgrade" packets and bind them together using UnsupportedOperationException. In my opinion this is not a route MCPL should be taking. Instead my plan is to add a module that allows ViaVersion to be used with MCPL to allow the desired multi-version support. Without having to pass serialization instances around, the API becomes a lot simpler. Especially with the removal of the parent class of ItemCodecHelper. (Which previously extended MinecraftCodecHelper for some reason) Now it is clear what you're calling and there are way more lambda/inlining opportunities around the codebase. This makes the API more similar to the approach Velocity and ViaVersion are also taking with their static serialization methods.

Classes renamed:

  • MinecraftCodecHelper -> MinecraftTypes
  • ItemCodecHelper -> ItemTypes

Classes removed:

  • PacketCodecHelper interface (not needed anymore)
  • BasePacketCodec (merged into MinecraftTypes)

Why was BasePacketCodec not renamed to BaseTypes? Because this library is slowly going to more and more specialize on only minecraft, not needing to retain a special implementation for developers who use it just for PacketLib.

First of all, why am I changing the whole API so that MinecraftCodecHelper is now static instead of an instance? The reason is that these methods are better used statically. Right now the biggest issue with MCPL I see is its reliance on "serialization instances" that are being passed around everywhere. Why were those even made in the first place? Because there was a belief a few years ago that MCPL could somehow ever support multiple versions of Minecraft. The idea is good however it is unrealistic. Packets change heavily between versions and rarely do serialization types. Serialization instances were made with the idea somehow you could implement multiple codechelpers for each version and "downgrade" packets and bind them together using UnsupportedOperationException. In my opinion this is not a route MCPL should be taking. Instead my plan is to add a module that allows ViaVersion to be used with MCPL to allow the desired multi-version support.
Without having to pass serialization instances around, the API becomes a lot simpler. Especially with the removal of the parent class of ItemCodecHelper. (Which previously extended MinecraftCodecHelper for some reason)
Now it is clear what you're calling and there are way more lambda/inlining opportunities around the codebase.
This makes the API more similar to the approach Velocity and ViaVersion are also taking with their static serialization methods.
Classes renamed:
- MinecraftCodecHelper -> MinecraftTypes
- ItemCodecHelper -> ItemTypes
Classes removed:
- PacketCodecHelper interface (not needed anymore)
- BasePacketCodec (merged into MinecraftTypes)

Why was BasePacketCodec not renamed to BaseTypes? Because this library is slowly going to more and more specialize on only minecraft, not needing to retain a special implementation for developers who use it just for PacketLib.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant