jason-green-io / papyri

Minecraft map item data mapping tool using Leaflet
MIT License
62 stars 10 forks source link

Help with older MC (v1.5.2) maps #44

Closed LannyRipple closed 1 year ago

LannyRipple commented 1 year ago

I've got maps from a MC server running 1.5.2 (needed for Better Than Wolves mod). Papryi can draw the maps but doesn't seem to construct the tiles correctly.

Screen Shot 2022-12-12 at 1 39 11 PM
jason-green-io commented 1 year ago

Good chance those maps were created before Mojang started snapping the centres of maps to a grid.

Rendering those properly would require some extra checks to includ..... I'm getting a headache just thinking about it.

On Mon, Dec 12, 2022 at 14:43 Lanny Ripple @.***> wrote:

I've got maps from a MC server running 1.5.2 (needed for Better Than Wolves mod). Papryi can draw the maps but doesn't seem to construct the tiles correctly. (See attached image.) I realize maps that old probably aren't supported but I'm wondering if you could suggest what I could do to the program to support it locally.

[image: Screen Shot 2022-12-12 at 1 39 11 PM] https://user-images.githubusercontent.com/132310/207138746-e79de257-1e5c-4204-8593-a3357dbd7543.png

— Reply to this email directly, view it on GitHub https://github.com/jason-green-io/papyri/issues/44, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVYU4MFASFNYBKAMKGR7CTWM556LANCNFSM6AAAAAAS4KVFWM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

LannyRipple commented 1 year ago

Oh right! Ok. BTW supports the grid but I'm guessing the map data doesn't have it. Gives me something to work with.

Will close this. Thanks for the clue.

LannyRipple commented 1 year ago

(Sorry to re-open. Need a bit more info.)

Seems I have zCenter and xCenter. The maps are drawn correctly. Then merged-maps seem to draw the upper-left map quadrant in the lower-right position with upper-left, upper-right, lower-left being left empty.

Looking at the code it seems all maps get translated into a scala 4 coordinate system and drawn on the merged-maps. I only have scale 4 maps so would expect to see the same images as in maps but instead seeing the shift mentioned above.

LannyRipple commented 1 year ago

A picture being worth 1000 words I've added screen shots.

Screen Shot 2022-12-12 at 3 51 31 PM Screen Shot 2022-12-12 at 3 51 44 PM

I've highlighted map_0 (center 0,0) in maps and merged-maps. Oddly merged-maps thinks the coordinates (I believe upper-left point) are -2048,2048. That would end up drawing only the upper-left quadrant of a 0,0 map in the lower-right quadrant of merged-maps.

jason-green-io commented 1 year ago

I'd love to see the map_*.dat files so I can see the nbt in them.

LannyRipple commented 1 year ago

Sure. I'm going to pull out colors since as you can see from the maps directory the data is in there.

map_0: {data: {zCenter: 0, width: 128s, scale: 4b, dimension: 0b, xCenter: 0, colors: [], height: 128s}} map_1: {data: {zCenter: -2048, width: 128s, scale: 4b, dimension: 0b, xCenter: 0, colors: [], height: 128s}} map_2: {data: {zCenter: 0, width: 128s, scale: 4b, dimension: 0b, xCenter: 2048, colors: [], height: 128s}} map_3: {data: {zCenter: 0, width: 128s, scale: 4b, dimension: 0b, xCenter: -2048, colors: [], height: 128s}} map_4: {data: {zCenter: 0, width: 128s, scale: 4b, dimension: 0b, xCenter: -4096, colors: [], height: 128s}} map_5: {data: {zCenter: 2048, width: 128s, scale: 4b, dimension: 0b, xCenter: 0, colors: [], height: 128s}} map_6: {data: {zCenter: 4096, width: 128s, scale: 4b, dimension: 0b, xCenter: 0, colors: [], height: 128s}} map_7: {data: {zCenter: 4096, width: 128s, scale: 4b, dimension: 0b, xCenter: 0, colors: [], height: 128s}}

The maps 6 and 7 have the same coords. Map 6 was lost while not paying attention to creepers.

I'm wondering if Minecraft versions that use a grid are not centered at 0,0 but maybe another reference point? That is maybe my map_0 should have center 1024,1024.

LannyRipple commented 1 year ago

Hmm. I tried to shift all coords by 1024 in papyri.py to test above. The maps are now fully drawn but not in their correct locations. :/

Screen Shot 2022-12-12 at 4 56 13 PM
jason-green-io commented 1 year ago

Yup, so starting in 1.8, the centre of the map depends on where the level 0 map was created and zoom level, explained here: https://minecraft.fandom.com/wiki/Map#Zoom_details

Pretty sure the maps you have there are impossible to create in versions past 1.8. I take advantage of the >=1.8 method as as shortcut. Since I know all maps at lower levels will tile evenly without trimming in a "level 4" map.

LannyRipple commented 1 year ago

Ah.

At zoom level 0, a map created on the point (0,0) has (0,0) at the center of the map. At higher zoom levels of the same map, the coordinate (0,0) is in the top left square of the map.

So I can probably just rewrite my xCenter, zCenter and it will work.

LannyRipple commented 1 year ago

Nope. Seems the center gets used in some way I'm not figuring out yet.

Thanks for all the help! I think I've got enough info to play around and eventually tease it out.

LannyRipple commented 1 year ago

In the end it was just adjusting the map's center when read in. Trick was to use an adjustment of 1024 - 64.