mineflayer
mineflayer copied to clipboard
Image from filled map
Hello.
How get image from filled map?
bot._client.on('map', console.log)
Mineflayer currently has no support for non vanilla map formats.
Some useful resources regarding the vanilla map format:
https://prismarinejs.github.io/minecraft-data/?d=protocol#toClient_map http://wiki.vg/Protocol#Map https://minecraft.gamepedia.com/Map_item_format
Okay, I get buffer from map, but how convert it to png?


you can use https://github.com/PrismarineJS/prismarine-nbt to decode packet.data
On Fri, Aug 25, 2017 at 11:50 AM enly1337 [email protected] wrote:
Okay, I get buffer from map, but how convert it to png?
[image: image] https://user-images.githubusercontent.com/29000881/29709134-f5d3374e-8993-11e7-9f63-d918ca424fb1.png
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/583#issuecomment-324873500, or mute the thread https://github.com/notifications/unsubscribe-auth/ACPN_iJzg2mgWAHYwCyay_dFiAbudgEJks5sbpjngaJpZM4PBsgu .
Ughm. It does not work.


hmm nevermind, it's not nbt at all. you need to read it manually. It's "Optional Array of Unsigned Byte"
Hmm, how this "Optional Array of Unsigned Byte" convert to nbt? :)
It doesn't, it's not nbt. I guess it's a yx indexed array. just loop through the bytes to get the colors
See this gist for a quick example on how to extract map colors.
shouldn't this be size instead of 128?
https://gist.github.com/lluiscab/5eeda7e37b7d5d75f53f4c66e61b6537#file-map-js-L27-L28
I've fixed that and tested the code with a level 4 map, seems like the size is always 128.
@lluiscab can you share some test data i can use to test this out?
Not really sure what do you want, best way to test this is to connect to some server, get a map and throwing it to the bot.
just the output of console.log(JSON.stringify(data))
Pastebin seems to be down, I've uploaded the json here
This JSON corresponds to this map (ingame)

And produces this output

https://gist.github.com/plexigras/753007b7638a47162b6246e2b754414b
require('./map.js')(data).writeImage('map.png')
pngjs-image is too old now and not passes npm audit. Has anyone rewritten it?
Huh this issue is still open? @ulcuber use this https://github.com/IceTank/mineflayer-item-map-downloader