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

Proposal: Multi-version? #686

Open
perfectOfFantasy opened this issue Feb 9, 2022 · 10 comments
Open

Proposal: Multi-version? #686

perfectOfFantasy opened this issue Feb 9, 2022 · 10 comments

Comments

@perfectOfFantasy
Copy link

Hi! It would be nice if your library supported multi-version (for example ViaVersion 1.8-1.18.1), I don't know if it's difficult to implement, but I hope you will add it. You can also make this mutiversion optional (i.e. activated by flags for a specific session or server in general)

@NathanKassab
Copy link

they're probably not going to do that, you're better off running VIAaaS or implementing via version yourself
https://github.com/ViaVersion/VIAaaS

@cxzlw
Copy link
Contributor

cxzlw commented Feb 15, 2022

I don't know if it's hard to do. However, I found a python project called pycraft in GitHub, which can achieve multiple versions. Specifically, you can use the latest version to connect to the lower version server without switching version.

@perfectOfFantasy
Copy link
Author

This isn't hard to do, on my other system which is on netty only with no other libraries I did ViaVersion implementations within 1 hour with fixing single bugs. However, they have recently introduced an interesting packet system which allows them to enter multiple versions manually, but it is a bit time consuming so the option is to use some packet generator (I've seen one that generated packages from wiki.vg) and just put them into the library. possibly implement packets that are used very often and remove the rest of packets and enter into the PacketLib library support for an unknown packet (i.e. if a disconnect packet is not implemented, it will read id and data anyway and forward it). In my opinion it would be better to enter all packages manually, but if you don't want to mess with data translation then it would be better to use ViaVersion.

@cxzlw
Copy link
Contributor

cxzlw commented Feb 15, 2022

This isn't hard to do, on my other system which is on netty only with no other libraries I did ViaVersion implementations within 1 hour with fixing single bugs. However, they have recently introduced an interesting packet system which allows them to enter multiple versions manually, but it is a bit time consuming so the option is to use some packet generator (I've seen one that generated packages from wiki.vg) and just put them into the library. possibly implement packets that are used very often and remove the rest of packets and enter into the PacketLib library support for an unknown packet (i.e. if a disconnect packet is not implemented, it will read id and data anyway and forward it). In my opinion it would be better to enter all packages manually, but if you don't want to mess with data translation then it would be better to use ViaVersion.

Can you teach me how to use the packet system which allows them to enter multiple versions manually? Thank you.

@MrZomka

This comment was marked as off-topic.

@cxzlw

This comment was marked as off-topic.

@cxzlw

This comment was marked as off-topic.

@perfectOfFantasy
Copy link
Author

perfectOfFantasy commented Feb 21, 2022

This isn't hard to do, on my other system which is on netty only with no other libraries I did ViaVersion implementations within 1 hour with fixing single bugs. However, they have recently introduced an interesting packet system which allows them to enter multiple versions manually, but it is a bit time consuming so the option is to use some packet generator (I've seen one that generated packages from wiki.vg) and just put them into the library. possibly implement packets that are used very often and remove the rest of packets and enter into the PacketLib library support for an unknown packet (i.e. if a disconnect packet is not implemented, it will read id and data anyway and forward it). In my opinion it would be better to enter all packages manually, but if you don't want to mess with data translation then it would be better to use ViaVersion.

Can you teach me how to use the packet system which allows them to enter multiple versions manually? Thank you.

There will be quite a few classes on the current packet system if you would like to implement more versions. However, if this does not bother you then you need to get rid of reading & writing packets from the packet classes and make them abstract classes implementing Packet. Then for each such packet you need to create an implementation for a given version, for example LoginSuccessPacketCodecV1_18, and instead of recreating the constructor, you only need to implement only reading and writing methods. And when it comes to registering such a packet, you need to modify the MinecraftCodec class (package com.github.steveice10.mc.protocol.codec) and there either make a list and add PacketCodec there or just add additional variables in the form of CODEC1_18, CODEC1_16_5 and so further, it is only important not to do it this way when registering:

.registerPacket(packet id, packet.class, packet::new)

just like this:
.registerPacket(packet id, packet.class, packet implementation::new).

//edit
I forgot to add, remember that when creating a client / server you need to add the appropriate PacketCodec from the MinecraftCodec class in the MinecraftProtocol constructor.
//

I explained it to you as much as I could, if I was wrong so sorry, good luck with implementation :)

@cxzlw
Copy link
Contributor

cxzlw commented Feb 21, 2022

This isn't hard to do, on my other system which is on netty only with no other libraries I did ViaVersion implementations within 1 hour with fixing single bugs. However, they have recently introduced an interesting packet system which allows them to enter multiple versions manually, but it is a bit time consuming so the option is to use some packet generator (I've seen one that generated packages from wiki.vg) and just put them into the library. possibly implement packets that are used very often and remove the rest of packets and enter into the PacketLib library support for an unknown packet (i.e. if a disconnect packet is not implemented, it will read id and data anyway and forward it). In my opinion it would be better to enter all packages manually, but if you don't want to mess with data translation then it would be better to use ViaVersion.

Can you teach me how to use the packet system which allows them to enter multiple versions manually? Thank you.

There will be quite a few classes on the current packet system if you would like to implement more versions. However, if this does not bother you then you need to get rid of reading & writing packets from the packet classes and make them abstract classes implementing Packet. Then for each such packet you need to create an implementation for a given version, for example LoginSuccessPacketCodecV1_18, and instead of recreating the constructor, you only need to implement only reading and writing methods. And when it comes to registering such a packet, you need to modify the MinecraftCodec class (package com.github.steveice10.mc.protocol.codec) and there either make a list and add PacketCodec there or just add additional variables in the form of CODEC1_18, CODEC1_16_5 and so further, it is only important not to do it this way when registering:

.registerPacket(packet id, packet.class, packet::new)

just like this: .registerPacket(packet id, packet.class, packet implementation::new).

//edit I forgot to add, remember that when creating a client / server you need to add the appropriate PacketCodec from the MinecraftCodec class in the MinecraftProtocol constructor. //

I explained it to you as much as I could, if I was wrong so sorry, good luck with implementation :)

Thank you very much. I will try to learn it. And have a try. Thank you.

@Redned235
Copy link
Member

This is something we've been looking in to as a long-term plan of MCProtocolLib. As mentioned the groundwork for such a system already exists but will require some digging into the codebase and messing around with packet codecs if you want to achieve multi version capability today. Ultimately we've not settled on a final decision yet but I'll keep this open to see what others think of more polished multi version support within the library

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

No branches or pull requests

5 participants