PrismarineJS / mineflayer

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

Image from filled map #583

Open enlyow opened 7 years ago

enlyow commented 7 years ago

Hello.

How get image from filled map?

plexigras commented 7 years ago

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

enlyow commented 7 years ago

Okay, I get buffer from map, but how convert it to png?

image

image

rom1504 commented 7 years ago

you can use https://github.com/PrismarineJS/prismarine-nbt to decode packet.data

On Fri, Aug 25, 2017 at 11:50 AM enly1337 notifications@github.com 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 .

enlyow commented 7 years ago

Ughm. It does not work.

image

image

rom1504 commented 7 years ago

hmm nevermind, it's not nbt at all. you need to read it manually. It's "Optional Array of Unsigned Byte"

enlyow commented 7 years ago

Hmm, how this "Optional Array of Unsigned Byte" convert to nbt? :)

rom1504 commented 7 years ago

It doesn't, it's not nbt. I guess it's a yx indexed array. just loop through the bytes to get the colors

lluiscab commented 6 years ago

See this gist for a quick example on how to extract map colors.

plexigras commented 6 years ago

shouldn't this be size instead of 128?

https://gist.github.com/lluiscab/5eeda7e37b7d5d75f53f4c66e61b6537#file-map-js-L27-L28

lluiscab commented 6 years ago

I've fixed that and tested the code with a level 4 map, seems like the size is always 128.

plexigras commented 6 years ago

@lluiscab can you share some test data i can use to test this out?

lluiscab commented 6 years ago

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.

plexigras commented 6 years ago

just the output of console.log(JSON.stringify(data))

lluiscab commented 6 years ago

Pastebin seems to be down, I've uploaded the json here

This JSON corresponds to this map (ingame) Map

And produces this output Map

plexigras commented 6 years ago

https://gist.github.com/plexigras/753007b7638a47162b6246e2b754414b

require('./map.js')(data).writeImage('map.png')
ulcuber commented 2 years ago

pngjs-image is too old now and not passes npm audit. Has anyone rewritten it?

IceTank commented 2 years ago

Huh this issue is still open? @ulcuber use this https://github.com/IceTank/mineflayer-item-map-downloader

rom1504 commented 1 week ago

https://github.com/IceTank/mineflayer-item-map-downloader/issues/8

Let's upstream this in mineflayer