#is it possible to read/write pixels to a filled map item?

17 messages · Page 1 of 1 (latest)

loud iris
#

i'm trying to add some map editing features, but i'm not really sure where to start looking for how to do that

quiet dockBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

fringe topaz
#

I would look into how vanilla does their map stuff first, if they store the map data in the NBT, or if they store it in the world folder.
I also feel like there are vanilla ways of modifying a map, so it may be worth looking into how to make vanilla custom maps.

loud iris
#

so it'd be for letting the player edit maps while the game's running

#

how would i see how vanilla does their map stuff though? is there somewhere with all the functions?

#

and map data is in the world folder

fringe topaz
#

This is the source code for how Map Item's save data

#

It's a screenshot of the code in intellij, but apparently the image is so large Discord doesn't want to preview it lol

#

I am also sending the MapItem source code as well, and going to dig to see if I can find out they render the Map to find if it's possible to figure out an easy way of creating this data artificaially.

#

Oh that's why it's so large, there is a line that is absolutely massive

#

That seems to be previewable from browser now at least

#

Judging from the source code, I'd guess that you'd have to use MapItem's getSavedData(ItemStack map, Level dimension) method to retrieve an instance of MapItemSavedData from an ItemStack of MapItems and the dimension the map was created in.
Then using that, you'd have to modify the color at a location with the MapItemSaveData.updateColor(int xOffset, int zOffset, byte colorCode) method. And in theory, it should update the map at the given pixel.
Judging by the source code the size of the map will be 128 x 128, so xOffset and zOffset need to be numbers between 0-127 in order to not throw an error.

loud iris
#

woah, thanks!