PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.95k stars 904 forks source link

bot.updateSign isn't working as expected #688

Open piousdeer opened 6 years ago

piousdeer commented 6 years ago

mineflayer v2.7.2 (using 1.12.2, also can be reproduced with 1.8) playing on mc.randomcraft.ru (Spigot server, supports 1.8 to 1.13)

bot.updateSign(sign, 'Text') throws an error: NodeError: Serialization error for play.toServer.update_sign.text2 : SizeOf error for params.update_sign.text2 : The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type undefined

bot.updateSign(sign, 'Line\nLine\nLine\nLine') updates the sign, but adds unwanted quotes around the lines: image

plexigras commented 6 years ago

have you tried it on vanilla?

you can also try this as a workaround

bot._client.write('update_sign', {
      location: block.position,
      text1: "Line",
      text2: "Line",
      text3: "Line",
      text4: "Line",
})

https://github.com/PrismarineJS/mineflayer/blob/master/lib/plugins/blocks.js#L289-L295

rom1504 commented 6 years ago

vanilla requires text to be json indeed

piousdeer commented 6 years ago

I just tested that in vanilla 1.12.2 and got exactly the same behavior. The workaround works fine, though

plexigras commented 6 years ago

good catch, 15w35a is when this changed

rom1504 commented 6 years ago

ok we can just send string for version >= 1.9 then