-
Notifications
You must be signed in to change notification settings - Fork 427
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
[1.20.2] Support common registration packets. Add configuration task API #3244
[1.20.2] Support common registration packets. Add configuration task API #3244
Conversation
...main/java/net/fabricmc/fabric/api/networking/v1/FabricServerConfigurationNetworkHandler.java
Show resolved
Hide resolved
...c/main/java/net/fabricmc/fabric/mixin/networking/ServerConfigurationNetworkHandlerMixin.java
Outdated
Show resolved
Hide resolved
Split ServerConfigurationConnectionEvents into two.
...src/main/java/net/fabricmc/fabric/api/networking/v1/ServerConfigurationConnectionEvents.java
Outdated
Show resolved
Hide resolved
@@ -30,10 +30,21 @@ | |||
@ApiStatus.Experimental | |||
public class ServerConfigurationConnectionEvents { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these events fire on the main or network thread? I guess network thread, but it would be good to clarify that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Network, I do need to improve the docs. 👍 I think adding an example will be helpful as well. Its quite easy to get wrong and stall the login, so a good example will be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a test mod and expanded the docs to cover this. Please do let me know if you think they need expanding a bit more.
I'm not sure to understand the usage of |
We use We cannot use |
Mmh, and I guess sending the channels during the actual play phase isn't an option? |
It technically would be if we delayed the play packet untill the 2 way handshake has completed. It still supports the minecraft:register / unregister packets during play. However configuration is the ideal time for this as we need to know the channels before we fire the |
Mmh, ok, I guess. My only last question is why include the New question: are the registry synchronization channels also registered through the same Also, I have to voice some grievances over this spec having been built in Discord spaces, this is awful for discoverability of said discussions, and make it hard to understand the reasons behind the spec itself, this should have been discussed somewhere publicly like GitHub. |
I think its still worth having in the packet, even if its just to validate it. This could maybe be removed as it is kinda redunant.
I do understand the problems with doing this in a private space as everyone likes to be involved. Its not the first time things have been decided in private and wont be the last. It was in a space that I am guest of so did not have any control over who has access to it. However I believe having a small group of people who understand the problem space well leads to a very productive discussion. What is shown in this PR is not final and very much still open for discussion and change. Either in this PR, or in future PRs on this proejct or other projects. Quite a lot of this design was initally created in a public channel. |
Registry sync and any other configuration channels will be in the inital |
While the discussion may be productive, it makes accessing the rationale behind each choices much harder to understand when a PR such like this appears. I also think discussing such subjects on spaces like GitHub can yield similar levels of productivity as talks on GitHub has a tendency to be more fleshed out and discourage unproductive talks. I'm hoping future decisive discussions of this spec will be held mainly on GitHub for the sake of the general modding community and future modders and maintainers. |
I would change specification a bit.
|
Does Mojang already use
Given what was said earlier, about those packets being advertised through the initial
I feel like the current spec doesn't prevent that, it just doesn't define the order of that. |
Nope, |
Oh, after a quick look it indeed changed quite a lot, there was many more custom pay load packets before... This is definitely puzzling because it means a vanilla would log not understanding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realise the configuration changes are the main focus of this PR, but felt it was worth commenting on the FabricPacket
changes as I requested them. ❤️ for those!
Are FabricPacketPayload
s actually handled anywhere right now - I couldn't see any obvious changes in ClientCommonNetworkHandler
/ServerCommonNetworkHandler
. It's a bit of a shame that the Map<Identifier, PacketByteBuf.Reader>
maps in the custom packet classes are immutable. Ideally registering a new packet would just extend those maps with the PacketType
's reader.
fabric-networking-api-v1/src/main/java/net/fabricmc/fabric/impl/networking/NetworkingImpl.java
Outdated
Show resolved
Hide resolved
This isnt really an issue, right now we hook into readPayload and return a the copied PBB payload as we need to handle the PBB on the network thread. The FabricPacket API is currently implemented ontop of this. I think in a future PR I will look into removing this abstraction and using That should all be impl detail, and not affect mods. As this PR has grown quite large I think it makes sense to do that later. I hope this makes sense :D |
Ahhh, gotcha. The lack of symmetry confused me, but that makes sense. Thanks! |
Continuing to use the legacy packets to dermine the current phases channels seems fine to me, the main reason we need a custom packet is to allow sending the play packets while not being in the play phase. If either the client or server doesnt understand the custom stuff, but does handle the old packets chances are things will mostly work out of the box. At least to the current status-quo.
Yes, thats exactally what this allows for. The inital minecraft:register will contain the supported channels, thus allowing the server to decide how to handle reg sync. Or skip it if the client doesnt support it.
Exactally, the rest of this PR adds an API for mods to do just this, see the new testmod. The server can decide to proceeded or disconnect if the client cannot recieve on a given channel.
Yep, this PR handles all of that that by having a I hope that answers your questions, I did miss the mark a little on how I worded how this spec was agreed upon (I updated the PR), it was very much the other parties saying this is a good/intresting idea and not commiting to using it. The worst case is we have something that behavaes the same as it does in previous versions (not great, not terrible). I should have also explined in detail what problem was being solved, its a low level system that I expect 99% of mod developers dont even know exists let alone have a good understanding of what it does. I certainly didnt untill I was forced into this last week 😆 A lot of it was discussed/designed in public before I asked for input elsewhere. The main addion was the version packet. Its still very much open for changes (even past this PR being merged), if anyone did feel left out of the converstation I'm sorry it wasnt my intent. I think its good that this discussion did happen as it shows what can possible if we all work togeather, just need to figure out a good (and fun!) way to go about this next time. I do plan to merge this tomorrow and release alongside the next snapshot (assuming there is going to be one). |
...c-networking-api-v1/src/main/java/net/fabricmc/fabric/impl/networking/CommonPacketsImpl.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
public void onPong(int parameter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should check the 0xFAB71C
parameter for extra safeguard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did orignally do this, but decided against it in the case that another platfrom decides to use this. Maybe I should pick something more generic.
* @param packet the fabric packet | ||
* @return a new packet | ||
*/ | ||
public static <T extends FabricPacket> Packet<ClientCommonPacketListener> createS2CPacket(T packet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static <T extends FabricPacket> Packet<ClientCommonPacketListener> createS2CPacket(T packet) { | |
public static <T extends FabricPacket> Packet<ClientConfigurationPacketListener> createS2CPacket(T packet) { |
a better signature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CustomPayloadS2CPacket
extends Packet<ClientCommonPacketListener>
so this is correct.
...pi-v1/src/main/java/net/fabricmc/fabric/api/networking/v1/ServerConfigurationNetworking.java
Outdated
Show resolved
Hide resolved
assert tasks.isEmpty(); | ||
|
||
// Run the vanilla tasks. | ||
this.addon.configuration(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The events seems to be missing on the in-play reconfiguration code path, which never calls sendConfigurations
(used by login to configuration only)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ill check this, im fairly sure it does work when reconfiguring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, you are correct. I tottaly missed that queueJoinWorldTask
method 👍 As its only called from the debug command right now I think its ok to leave/handle at a later date. Its a little unclear to me how this is intended to be used.
I peeked through the new configuration state logic in enigma and this PR and have a few remarks:
|
Yes, we are discussing if we can get rid of the login related APIs, it seems like we can. Wont be done as part of this PR though.
Yes, this is the API that we have exposed, in theory it would be possible for Fabric to change the behaviour of how the tasks are ran to support running them in parallel. I think for now keeping it as close to vanilla is fine.
Yeah... I think it should handle this case ok, we check to make sure that the inital registry/ping packets were sent before doing anything about their response. Do you have a better solution? |
Merging before porting to the new snapshot, please open an issue for further changes. (I will likely have a follow up PR as well) |
There is more! The original port was very rough, this is hopefully a better longer term solution!
Common channel registration packets
Previously we sent the play packet channels in a custom packet called
fabric-networking-api-v1:early_registration
this worked OK, but had a few issues.After some discussion in the fabric discord about a solution to this problem I raised our ideas to the folk over at @neoforged , @PaperMC and @SpongePowered after a quick chat we came up with the idea of also sending a version packet to allow for future expansion. This is still very much open for public discussion and improvments, and still will be after this PR has been merged. The end goal of this is to allow mod/plugin loaders to negotiate with each other allowing mod developers greater flexibility when developing cross platform mods.
The above diagram details the current packet format, and the expected behaviour of the packets during the new configuration phase added in 23w31a. This is still very open for input and change, I look forward to seeing what everyone can do with this! Thanks to @Patbox for the great suggestion of using the ping packet to contiune to support vanilla clients!
Configuration task APIs
FabricServerConfigurationNetworkHandler
is now interface injected ontoServerConfigurationNetworkHandler
exposing the vanilla configuration task API.ServerConfigurationConnectionEvents
now has aPRE_CONFIGURE
that allows tasks to be ran before any vanilla configuration takes place.Registry sync and custom ingredients have been moved over to use this API.
Fabric Packets
Fabric packets are now written to the PacketByteBuf on the network thread by default in production. In development the previous behaviour is retained to help modders test their packets. The system property-Dfabric-api.networking.write-fabric-packet-calling-thread=false
has been added to allow overriding this behaviour.Disabled for now, as its causing issues in single player. I will resolve this in its own PR as its a larger than I expected.