comp500 / tinymap

A lightweight server-side stateless web map
MIT License
28 stars 6 forks source link

Upgrade to 1.18 #21

Open skerit opened 2 years ago

skerit commented 2 years ago

I needed to get unloaded chunk data for something, and I thought I'd use your BlockDigger and UnloadedChunkView classes for that. (The idea is to implement them in a separate library, FYI)

But I had to get it working in 1.18 first, of course :) So here's that! Everything (rendering loaded & unload chunks) works fine:

image

I think worlds that have not fully upgraded to 1.18 might cause a problem. Tinymap will try to load those unloaded chunks in, expecting the 1.18 format but finding something different. I'll see if I can add those workarounds easily.

Funny story: most of my time went into getting the Javelin dependencies working + cleaning up the commit history. I accidentally upgraded a fork of a fork of your repository, which was missing a few commits. Including the Javelin ones. (Why the switch to Javelin, btw?)

I added all the Javelin dependencies to the gradle build file, and now it seems to work correctly.

comp500 commented 2 years ago

Thank you for the PR! I'll have a more thorough read through it later, but it looks decent from what I've seen. I do want to bring most of the fixes to the 1.16 version though, so I'll probably get the main branch working on 1.16 first.

I think worlds that have not fully upgraded to 1.18 might cause a problem. Tinymap will try to load those unloaded chunks in, expecting the 1.18 format but finding something different. I'll see if I can add those workarounds easily.

I think DataFixerUpper can handle upgrading the chunk NBT for you? Though it is rather slow, so direct support for reading older chunk formats would be nice.

Regarding Javalin, the main reason I changed to use it was that the Netty code required the java.activation module on newer versions, but the code was also painfully low-level and complicated; Javalin is much simpler. I hadn't set up distributing it as part of the mod yet, as I want to make it a separate mod, so that other mods can depend on it and not duplicate the code (since the JARs are quite large), and be able to share the same port for different mod-provided pages.

skerit commented 2 years ago

I think DataFixerUpper can handle upgrading the chunk NBT for you? Though it is rather slow, so direct support for reading older chunk formats would be nice.

Oh my, I was testing some strange things with manually creating blockstate & biome palettes, which never worked, before thinking about just using the DFUs.

But TACS already has that, so instead of just calling getNbt I call getUpdatedChunkNbt and now the map renders pre v1.18 chunks perfectly.

There's one strange bit I'm not too sure of: after applying the DFU, the chunk status is set to EMPTY. So instead of just refusing chunks that aren't FULL, it'll now also allow chunks that are EMPTY because I don't think any truly empty chunk will get saved to disk like that. (At least not in my tests. After this change, there were no white or gray chunks visible on the map)

I hadn't set up distributing it as part of the mod yet, as I want to make it a separate mod, so that other mods can depend on it and not duplicate the code (since the JARs are quite large), and be able to share the same port for different mod-provided pages.

Yeah, after including it and all the dependencies the jar is 5.9 megabytes 😅

*Edit: Just saw there are some height checks in the TileGenerator too, which will make any terrain under level 1 be rendered as bedrock. That needs updating.

comp500 commented 2 years ago

Is this PR still being worked on? (no worries if you forgot about it, I did too :P) I'm happy to review this and/or finish it myself, just looks like there's some more changes you intended on making.