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

Bugfix Discussion: Resolve bedrock featureflags conflicts #245

Open
TobiasGrether opened this issue Nov 21, 2022 · 1 comment
Open

Bugfix Discussion: Resolve bedrock featureflags conflicts #245

TobiasGrether opened this issue Nov 21, 2022 · 1 comment
Labels
bug Something isn't working enhancement New feature or request priority/high High priority issues protocol Issue related to bedrock protocol
Milestone

Comments

@TobiasGrether
Copy link
Member

TobiasGrether commented Nov 21, 2022

Problem

The Bedrock Edition Protocol is constantly changing. To test new features while still allowing old features to be used, the StartGamePacket contains flags for certain features, for example ServerAuthoritiveInventories or ServerAuthoritiveBlockBreaking.
The issue is that the StartGamePacket can only be sent exactly once, in the beginning of the session lifecycle.
When a player joins a server through WDPE, the feature flags of the first server that a player joins are used. This also means that every other server that player joins has to use this feature set. The protocol doesn't allow us to communicate with either the client or the server that we want to change the feature set thats already provided.

This causes issues where having BDS and Nukkit servers in the same proxy is simply impossible, since they use different features and just transferring over works, but will break many mechanics like Block placement or chunk sending.

Proposed Solution

The proposed solution is to use the PlayerTransferPacket. This packet, when sent to the client, initiates a complete disconnect from the current server and a completely new connect to the target server that is specified.

When a player tries to transfer from one server to another, and that server has a different feature set enabled in the StartGamePacket, then we can detect that. We can then close the connection to the server again.
We then need to save in an ExpiringMap<String, String>, which is <playerXuid, targetServerName>, the server the player wanted to connect to and the player that wanted to connect.

We can then transfer the player to the proxy again (essentially letting him rejoin the server forcefully), just this time we skip all JoinHandlers and directly return the server that the player wanted to connect to. Now the player has the correct feature sets enabled and can play.

Questions to be solved

  • The TransferPacket requires an IP address. We cannot use the IP address from the ExtraData of the player, which is used for the resolution of DirectServers, since rotating DNS updates might conflict with that and let the player join a different IP address. It would be considerable to add an environmental variable or config option (or both) to control the IP address for the resend.
  • Should there be a config option for toggling this behaviour?

Impact

  • When a player transfers to a server with different feature sets toggled than known to the client, a hard transfer is initiated. This will look slower to the player, but is necessary.
  • This will allow BDS and Non-BDS servers to be used in the same proxy network (fixes #49)
@TobiasGrether TobiasGrether added this to the bds milestone Nov 21, 2022
@TobiasGrether TobiasGrether added enhancement New feature or request protocol Issue related to bedrock protocol bug Something isn't working priority/high High priority issues labels Nov 21, 2022
@irrld
Copy link
Contributor

irrld commented Nov 23, 2022

I was thinking about something like that to be able to update custom blocks/items without needing to force players to leave the server completely. Adding this feature into WDPE itself with a toggle sounds like a decent idea to me.

We can have both config option and environmental variable which will be useful for people who run instances in Docker.

But what if someone else joins to that server and fills it up, what will happen in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request priority/high High priority issues protocol Issue related to bedrock protocol
Projects
None yet
Development

No branches or pull requests

2 participants