mineflayer icon indicating copy to clipboard operation
mineflayer copied to clipboard

Resourcepack receive error related to minecraft-data?

Open Emibergo02 opened this issue 1 year ago • 5 comments

Versions

  • mineflayer: 4.18.0
  • server: paper 1.20.4
  • bun: 1.1.8

Detailed description of a problem

43 |     }]
44 |   },
45 |   Write: {
46 |     varlong: ['native', minecraft.varlong[1]],
47 |     UUID: ['native', (value, buffer, offset) => {
48 |       const buf = value.length === 32 ? Buffer.from(value, 'hex') : UUID.parse(value)
                       ^
TypeError: Serialization error for play.toServer : Write error for undefined : undefined is not an object (evaluating 'value.length')
      at /home/unnm3d/buntest/node_modules/minecraft-protocol/src/datatypes/compiler-minecraft.js:48:19
      at packet_resource_pack_receive (:1206:16)
      at packet (:1419:9)
      at tryCatch (/home/unnm3d/buntest/node_modules/protodef/src/utils.js:50:16)
      at createPacketBuffer (/home/unnm3d/buntest/node_modules/protodef/src/compiler.js:102:5)
      at _transform (/home/unnm3d/buntest/node_modules/protodef/src/serializer.js:18:13)
      at /home/unnm3d/buntest/node_modules/protodef/node_modules/readable-stream/lib/_stream_transform.js:166:5
      at /home/unnm3d/buntest/node_modules/protodef/node_modules/readable-stream/lib/_stream_transform.js:155:78
      at doWrite (/home/unnm3d/buntest/node_modules/protodef/node_modules/readable-stream/lib/_stream_writable.js:390:132)
      at writeOrBuffer (/home/unnm3d/buntest/node_modules/protodef/node_modules/readable-stream/lib/_stream_writable.js:381:5)

seems to be related to the packet_resource_pack_receive and the method bot.acceptResourcePack(); AND I think this is the cause https://github.com/PrismarineJS/minecraft-data/blob/c658e8be5c2ce1b4e0478bbfc9f96c3b832fcbce/data/pc/1.20.3/protocol.json#L1951 The packet is not as it was supposed to be here https://wiki.vg/Protocol#Add_Resource_Pack_.28play.29

What did you try yet?

Check the client's protocol version on the server (it is correct 1.20.3 because 1.20.3 and 1.20.4 have the same protocol checking the bot version (1.20.4 as defined in createBot) I checked bot.supportFeature('resourcePackUsesUUID') It is false but it should be true I think

Your current code

            bot.on("resourcePack", (url, uuid, hash) => {
                bot.acceptResourcePack();
            });

Expected behavior

send a successfully loaded packet to the server

Emibergo02 avatar May 10 '24 15:05 Emibergo02

bot.supportFeature('resourcePackUsesUUID') was the problem it returns false but should be true actually . i fixed the issue by using minecraft-protocol instead of acceptResourcePack()

bot._client.write('resource_pack_receive', {
     uuid: uuid,
     result: 0
})

Emibergo02 avatar May 10 '24 16:05 Emibergo02

Can you open a PR to fix?

extremeheat avatar May 12 '24 21:05 extremeheat

Can you open a PR to fix it, please? I don't know how to fix that :( right now I'm using ViaBackwards with mineflayer 4.17.0 because 4.18.0+ acceptResourcepacks() doesn't work at all

Emibergo02 avatar May 13 '24 20:05 Emibergo02

The feature should be active for 1.20.3+ - https://github.com/PrismarineJS/minecraft-data/blob/master/data/pc/common/features.json#L361

Can you update your deps with npm update and check if the issue persists? We can't support old versions, you need to reproduce on latest of all deps.

extremeheat avatar May 26 '24 16:05 extremeheat

Still unusable until you pull https://github.com/PrismarineJS/node-minecraft-protocol/commit/ccab9fb39681f3ebe0d264e2a3f833aa3c5a1ac7 into mineflayer... Can't give you more information if I can't print disconnect messages...

Emibergo02 avatar May 27 '24 16:05 Emibergo02