Skip to content

Fix resource pack UUID serialization causing server kick on 1.21+#3842

Open
Copilot wants to merge 6 commits intomasterfrom
copilot/fix-resource-pack-kick-issue
Open

Fix resource pack UUID serialization causing server kick on 1.21+#3842
Copilot wants to merge 6 commits intomasterfrom
copilot/fix-resource-pack-kick-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 27, 2026

  • Fix latestUUID storage: store raw bytes (data.uuid) not UUID object, in both add_resource_pack and resource_pack_send handlers
  • Fix denyResourcePack double-write bug
  • Remove all feature branching from acceptResourcePack and denyResourcePack — protodef ignores extraneous fields so version checks are unnecessary
  • Move latestUUID and latestHash assignments outside the if/else in resource_pack_send so both are always stored
  • Lint passes, CodeQL: 0 alerts
Original prompt

This section details on the original issue you should resolve

<issue_title>Kicks from the server when receiving a resource pack.</issue_title>
<issue_description>- [ ] The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.33.0
  • server: BungeeCord 1.21-R0.4 - Paper
  • node: 24.1.0

Detailed description of a problem

There are no problems when logging into the hub, but when connecting to a subserver on version 1.21, the server offers a resource pack, but the problem is I can't accept or decline it. Either way, I get kicked from the server for no reason.

Your current code

import mineflayer from "mineflayer";

const bot = mineflayer.createBot({
    host: 'neo.funtime.sh',
    port: 25565,
    username: '6055_42',
    version: '1.21.8'
});

bot.on('spawn', () => {
    console.log('Join to anarchy')
    bot.chat("/an11") // Joining a server with version 1.21 from the lobby (BungeeCord)
})
bot.on('resourcePack', () => {
    console.log('Resource pack received');
    bot.acceptResourcePack();
    console.log('Resource pack accepted');
})
bot.on('message', (message) => {
    console.log(`${message.toString()}`)
})
bot.on('kicked', (reason) => {
    console.log('Kicked:', reason);
})
bot.on('error', (error) => {
    console.error(`Error: ${error}`);
})
bot.on('end', (reason) => {
    console.log(`End: ${reason}`);
})

Expected behavior

Successful connection to the server without kicking; resource pack is not important.
</issue_description>

<agent_instructions>Add the code posted by MayorLeon20 to our acceptResourcePack handling</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@extremeheat acceptResourcePack needs to be fixed and simplify

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Fix kick issue when receiving resource pack from server Fix resource pack UUID serialization causing server kick on 1.21+ Feb 27, 2026
@MayorLeon20
Copy link
Copy Markdown

everything is cool

@extremeheat extremeheat marked this pull request as ready for review February 27, 2026 12:14
Comment thread lib/plugins/resource_pack.js Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch is unnecessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the branch — denyResourcePack now unconditionally writes a single packet with uuid included. Done in 708fd6f.

}
})

function acceptResourcePack () {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These branches are also unnecessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all feature branching from acceptResourcePack — it now always writes both packets with uuid and hash fields unconditionally (protodef drops fields not in the version's schema). Done in 708fd6f.

@extremeheat
Copy link
Copy Markdown
Member

@copilot since protodef will ignore extraneous fields for versions that don't have them, the feature branching is unnecessary. Feature branching is only needed for fields that have different non-null data types between different versions; using different field names removes this need. You can remove them where applicable for cleanliness (sometimes it's helpful to have comments aside fields to notate what version the field applies to)

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 27, 2026

@copilot since protodef will ignore extraneous fields for versions that don't have them, the feature branching is unnecessary. Feature branching is only needed for fields that have different non-null ...

Done in 708fd6f. Removed all feature branching from acceptResourcePack and denyResourcePack. Also moved the latestUUID and latestHash assignments in resource_pack_send outside the if/else so both are always stored regardless of version.

@kaduvert
Copy link
Copy Markdown
Contributor

merge this immediately!

Copilot AI and others added 4 commits April 1, 2026 15:02
Co-authored-by: extremeheat <13713600+extremeheat@users.noreply.github.com>
…branching

Co-authored-by: extremeheat <13713600+extremeheat@users.noreply.github.com>
…it, add tests

Move latestUUID and latestHash assignments before bot.emit('resourcePack') in
the resource_pack_send handler so they are available when acceptResourcePack or
denyResourcePack is called synchronously from the event. Also add hash field to
denyResourcePack for versions that require it, and add comprehensive tests for
both accept and deny across all supported versions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rom1504 rom1504 force-pushed the copilot/fix-resource-pack-kick-issue branch from 708fd6f to 99e2279 Compare April 1, 2026 15:41
claude and others added 2 commits April 1, 2026 19:49
Verifies that acceptResourcePack() and denyResourcePack() send the UUID
as a raw string (not a UUID object) in the resource_pack_receive packet,
preventing server kicks on 1.21+.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

Kicks from the server when receiving a resource pack.

5 participants