Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Deleting pre-loaded chunks server-side #8

Closed
AhptIO opened this issue Nov 15, 2022 · 2 comments
Closed

Deleting pre-loaded chunks server-side #8

AhptIO opened this issue Nov 15, 2022 · 2 comments
Labels
Completed The issue has been resolved (does not mean the resolution has been published yet tho).

Comments

@AhptIO
Copy link

AhptIO commented Nov 15, 2022

Hello, I can't seem to figure out how to perform the "optimization" on preloaded chunks server-side. Is there a command that I'm missing? I only see two options in the configuration file, as well. Thanks for the help on this.

@TheCSDev
Copy link
Member

TheCSDev commented Nov 15, 2022

Hello.
Unfortunately the deleing already exising chunks featrue is only available on the Minecraft client, and I'll explain why. As for the server, the best thing the mod can do is discard unused chunks as they are being generated. I know this is likely inconvenient, having to move the world to the client and optimizing the world from there, but it appears to be the only way.

There are actually two big reasons for why it can not be done server-side:

  1. The world optimization feature is only available on the client.
    Minecraft itself does not offer a way to optimize worlds server-side (see reason 2.). Now technically if you look at Minecraft's source code, you will see the WorldUpdater (the module that optimizes and updates worlds) is available server-side as well, but this is so the server can load worlds from older Minecraft versions (aka update worlds to the current version). That's all the module does server-side, and it does this before ever loading the world (because when you run a server, you obviously also load the world). And speaking of worlds being loaded, which is the opposite of what we need, the second reason is...
  2. The world files must all be unloaded when performing this operation.
    And by running a server, you are loading the world. This feature was built on top of the WorldUpdater module (the one you see when going to the "Optimize world" menu on the client). This module goes through all chunks in all region files of a given (unloaded) world, and then modifies the chunk data however it needs to. This mod adds on top of that by checking if a given chunk is uninhabited, and then tells the WorldUpdater to simply discard the chunk if it is, thus making the WorldUpdater remove unused chunks. Now of course, pulling this off while the world is loaded would require accounting for loaded chunks as well, which would complicate things a bit. And the thing is, when certain chunks are loaded, the region files of those chunks are loaded as well (meaning you can't modify them). To be honest, if it somehow was possible to pull it off while the world is loaded, I don't even know how that would be done.

So yeah, I wanted to mention those two things so you can hopefully get to see how the feature works and why it can not do what you want it to do (ngl I want that feature as well). Sorry again for the inconvenience, and have a great day.

Also did you mean "Deleting pre-loaded" in the issue title? If so, I could pin this issue for other to see in case anyone else ever wants to ask this question.

Edit: corrected some punctuation marks.

@AhptIO AhptIO changed the title Deleting pre-modded chunks server-side Deleting pre-loaded chunks server-side Nov 15, 2022
@AhptIO
Copy link
Author

AhptIO commented Nov 15, 2022

Thanks for that detailed response! I updated the title and feel free to pin it!

@AhptIO AhptIO closed this as completed Nov 15, 2022
@TheCSDev TheCSDev pinned this issue Nov 15, 2022
@TheCSDev TheCSDev added the Completed The issue has been resolved (does not mean the resolution has been published yet tho). label Nov 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Completed The issue has been resolved (does not mean the resolution has been published yet tho).
Projects
None yet
Development

No branches or pull requests

2 participants