-
-
Notifications
You must be signed in to change notification settings - Fork 239
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
Cross version #234
Comments
About dynamic support: And the default versions might be just ["1.8"] in nmp 0.15.0 . In 0.16.0 it might become ["1.9"] and the nmp user would anyway would have to manually update to 0.16.0 so we wouldn't "pull the rug under the user's feets". Or we could just say that "versions" is not optional. Dynamic just mean multiple versions support at the same time, we don't force the user to support everything if he doesn't care to. (the same thing goes for createServer) |
We need to be able to convert the protocolVersion (https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/src/createServer.js#L143) (=version.version) to the corresponding majorVersion/mcDataVersion. node-minecraft-data should be able to do that in https://github.com/PrismarineJS/node-minecraft-data/blob/master/index.js#L18 (just check if one of the mcData submodule is that version) Then we basically just need to do the other states than play are the same between 1.8 and 1.9, so that would work. 1.7 would be something else though (among other problems related to 1.7) |
@rom1504 it would work for anything >= 1.7. For < 1.6, there would only be one state (LEGACY, or whatever we end up calling it). I think we should keep the require('minecraft-data')('version'). It's easier and more flexible. |
Ah yeah sure, I forgot the version. I meant putting require ('minecraft-data')(protocolVersion) when the client (or server) sends us the protocol version |
Places that should use a dynamically stored version :
createClient and createServer should also have a new option "versions" to prevent client connecting to a server with a version the user doesn't want to support, and client connecting to a server version the user doesn't want to support. That "versions" info should be used in createClient.js and createServer.js to restrict the supported versions (a bit like #213 ) |
I think I'll start by implementing static cross version (the API proposed in #65) before dynamic, it's easier. |
* put parsePacketData in deserializer and createPacketBuffer in serializer * remove packets from the index and expose readPacket instead * load packets when needed in various files * make tests test every supported version static cross version of PrismarineJS#234, fix PrismarineJS#65, fix PrismarineJS#240
* put parsePacketData in deserializer and createPacketBuffer in serializer * remove packets from the index and expose readPacket instead * load packets when needed in various files * make tests test every supported version static cross version of PrismarineJS#234, fix PrismarineJS#65, fix PrismarineJS#240
Once #257 is merged, adding dynamic cross version will mainly be about changing the serializer and deserializer dynamically in client.js when we know the version we want. |
hmm hmm, so it seems the server never send the version to the client, so it doesn't seem possible to implement dynamic cross version for the client. |
Once dynamic cross version is implemented, I think a good API for createClient and createServer would be:
Then NMP would refuse to connect to any version not in enabledVersions. That way:
|
Implemented exactly this in #327 / https://github.com/deathcap/node-minecraft-protocol-auto:). It works pretty well in my testing, though as @roblabla mentions the ping exchange adds additional latency to the connection time and incompatibility with servers that do not allow ping, so it is probably a good idea to make it optional. The client also has to wait for the ping response from the server before it creates the client and sets a version, so the current synchronous How about keeping createClient() as is — only accepting one version — but add a wrapper for dynamic cross protocol support? (this is what I'm doing in node-minecraft-protocol-auto). This way, existing clients won't break nor get the ping overhead, and the API signature can change (createClient is sync, but this new ?createClientAsync? API could be async, accepting a callback function to return the client object once it is created). Maybe FML/Forge (#326) could also be considered as "version" for the cross-version support? Not in the same enabledVersions list, but a separate boolean option. idk if we actually need enabledVersions, if the current API remains for specifying exactly one version, and there is another API for automatically getting and using the appropriate version, unless filtering the supported versions is desired for some reason. |
In #331 (ready to pull/review), left the default This works alright but there are some larger worthwhile improvements imho. These may require changes to multiple projects. Naming consistency: the term Major version / dataset dichotomy: minecraft-data is built around one set of data per major version. Not necessarily an unreasonable assumption, but it breaks down when considering protocols. The 1.7 major version encompasses both protocol version 4 (1.7.1 to 1.7.5) and 5 (1.7.6 to 1.7.10) for example, and 1.9 (prerelease) just had a recent major protocol change making 15w40b (76) in minecraft-data/1.9 incompatible with newer 1.9 prereleases (renumbering the packets). I think we can tackle this problem by abstracting out the "dataset" from the "version", so for example, you would ask minecraft-data "give me the protocol for version X" (where X = 76, or '15w40b', etc.,), and it would return the appropriate set of data, if available. The data could be stored in 1.8/, 1.7/ directories internally, but not exposed to users of the module. Major versioning in createClient/client object: the constructor takes a majorVersion as the second argument, should be changed to use the release version, and let minecraft-data handle getting the right data. This might already be possible in minecraft-data 0.16.0 since it supports Remove version in constructors?: I suppose it makes sense for the Server object, but for Client, we want to be able to create the object and return it without immediately knowing its version. Currently, the version is set, and then overridden after the object is created. Version validation: src/createClient.js validates the supported version, but it is not validated when set afterwards ( |
Client cross-version is now implemented (thanks @deathcap) |
Found this protocol recognizer in Cuberite, might be useful for reference: https://github.com/cuberite/cuberite/blob/master/src/Protocol/ProtocolRecognizer.cpp#L948 |
@kobiluvesmemes is interested by dynamic cross version in the server. I might do it. |
How long until this is on npm? |
@kobiluvesmemes released as 1.4.0 |
There are 2 kinds of cross version support:
Currently we almost got static support (see #212 about that).
You'd think dynamic support would be much harder but actually all it would be about is getting the protocol information from the server/client you are connecting to, and using the correct protocol.json to parse and serialize the packets for that server/client.
Of course, that wouldn't solve the multi-version support for users of nmp which would still have to deal with the packets difference between version, one way to deal with that might be #231
Dynamic support would allow createClient and createServer to work for both 1.8 and 1.9 without change to the api, nmp would just need to expose the version of the server/client it connected to.
This idea might be extendable to multi-platform support (with mcpe) but that would be a bit harder (the protocol architecture of mcpe is different from mcpc)
Related with #65
The text was updated successfully, but these errors were encountered: