-
-
Notifications
You must be signed in to change notification settings - Fork 924
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
Fix gamemode test and implementation #3508
base: master
Are you sure you want to change the base?
Fix gamemode test and implementation #3508
Conversation
Tests are not working. Will fix. |
Add test function to kill the bot
@@ -25,10 +25,11 @@ function inject (bot, options) { | |||
function handleRespawnPacketData (packet) { | |||
bot.game.levelType = packet.levelType ?? (packet.isFlat ? 'flat' : 'default') | |||
bot.game.hardcore = packet.isHardcore ?? Boolean(packet.gameMode & 0b100) | |||
if (bot.registry.isOlderThan('1.10')) { // gamemode is used pre 1.10 and post 1.20 but in between it's gameMode |
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.
This should be a feature
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.
Gamemode in 1.20.6 is now of type "mapper" https://prismarinejs.github.io/minecraft-data/?d=protocol&v=1.20.6#toClient_undefined. What is that? @extremeheat
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.
Is that like a string then?
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.
Mapper is a enum. The enum values can be found in the protocol files inside minecraft-data for the relevant version.
The current Mcpc mcdata protocol doc gen doesn't support the mapper type. Can be fixed in future by swapping it with the protodef-yaml html gen that bedrock is currently using.
Related #3508 |
Do we wait for mc data to update, or can we merge with just the version check and add the feature later? |
What change to the protocol was made for this with 1.21? I don't see any changes. The last change was with 1.20.5 with the new world state field. It doesn't seem mineflayer is handling that in the linked PR. |
The login packet in 1.21 now has gamemode as string instead of a number. This means the mineflayer needs to use |
I mean where in the protocol the change happened with 1.21, specifically a link to the protocol spec changes.
|
Looks like the mc protocol did not change. But minecraft-protocol now maps the game mode from a number to a string by itself. Wiki.vg still has the gamemode value as a number https://wiki.vg/Protocol#Login_.28play.29. But there is a clear change in minecraft-protocol. minecraft-protocol 1.21.1 protocol.json https://github.com/PrismarineJS/minecraft-data/blob/9cfa6ea955af24d6f481484ebe5d8221a2265421/data/pc/1.21.1/protocol.json#L3713 |
Yes, as you can see in the mcdata link the data is encapsulated inside the world state (SpawnInfo) field. This is not handled in mineflayer and there is an existing feature for that change, |
The How does that match up with Wiki.vg login (play) packet? Or is login (play) at wiki.vg not the same as packet_login? https://wiki.vg/Protocol#Login_.28play.29 |
|
It might be a little off topic but shouldn’t parseGamemode function also fixed? packet with game mode -1 is valid but Minecraft client would go to survival mode if the number is out of range (not to spectator or any other) |
This fixes the broken gamemode test and also fixes the gamemode implementation for pre 1.10