aternosorg / thanos

PHP library to automatically detect and remove unused chunks from Minecraft worlds.
https://packagist.org/packages/aternos/thanos
MIT License
222 stars 20 forks source link

chunk whitelist/blacklist #21

Open thvless opened 4 months ago

thvless commented 4 months ago

Hello, i own a self-hosted server where i often purge unused chunks manually using mca selector, and was looking at thanos as an appealing solution, except i have one question/suggestion.

For context: i am running a modded server that includes the mod valkyrien skies: https://github.com/ValkyrienSkies in brief this mod simulates physics in minecraft by storing the "ships" which are the interactable buildable blocks in what they call a shipyard which everything that spans from -28672000 to 28672000 on the x axis and from 12288000 to 28672000 on the z axis any blocks created here are only there for simulation purposes and what the player sees is a projection of them rendered on the client, eg the player themself is not affecting ChunkInhabitedTime of the chunks in the shipyard

Proposed solution: would it be possible to implement a modifiable black list for the iterator so it skips those coordinates/chunks/mca regions even if their ChunkInhabitedTime is null, i have seen that this has already been done for chunks that are force loaded but since shipyard chunks are only loaded if their projection is loaded it would only cause lag to force load them at all times.

KurtThiemann commented 4 months ago

Storing these ships as regular blocks in the overworld instead of using some custom file format to save them or at least put them in a dedicated dimension seems like a pretty odd choice...

I added an option to the Thanos class to set a list of chunks that should always be saved. Note that these are chunk coordinates, not block coordinates, so you'd have to divide your block coordinates by 16 to get the correct chunk coordinates. setSaveChunks accepts an array of int arrays, so to save chunks 1,2, 3,4, and 5,6, you'd pass [[1,2], [3,4], [5,6]].

I have not added an option to use this to the thanos cli yet, which is also why I have not created a new release yet. I might look into that next week if I have time.

thvless commented 4 months ago

Hi, thanks for the quick reply, I see your implementation was through arrays. would it be possible to instead use a range function?

I've determined that in my specific use case the coords of chunks i need protected are X -1792000 to 1792000 and Z 768000 to 1792000. perhaps specifying the range [(1792000,-17920000),(768000,1792000)] or any other for different use cases would be better

KurtThiemann commented 4 months ago

Okay, Thanos now has a setCustomPatterns method that accepts an array of ChunkPatternInterface. You can pass an instance of RangePattern to save a Range of chunks (the constructor uses chunk coordinates, not block coordinates). You can also create custom patterns by implementing ChunkPatternInterface yourself.

Still not available in the CLI, as I'd need to think about how that could be represented in command line options. You can, of course, write your own script based on the thanos CLI creates the correct pattern object.

Merith-TK commented 2 months ago

Storing these ships as regular blocks in the overworld instead of using some custom file format to save them or at least put them in a dedicated dimension seems like a pretty odd choice... to give some insight into this

Valkyrian Skies has direct compatibility with create, an mechanical automation mod. It uses the "shipyard" to have a physical in world space for the actual blocks to tick,