Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Chunk ownership #257

Open
gentlegiantJGC opened this issue May 19, 2022 · 1 comment
Open

[Feature Request] Chunk ownership #257

gentlegiantJGC opened this issue May 19, 2022 · 1 comment

Comments

@gentlegiantJGC
Copy link
Member

gentlegiantJGC commented May 19, 2022

Feature Request

The Problem

Currently chunks are intended to be independent of the world however I think we should change this behaviour.
There is an issue when adding chunks to a world that the same chunk object may already be in a different world.
Should editing this chunk object change the chunk in both worlds?
Should marking the chunk as changed do so for both worlds?
Which block and biome palette should the chunk reference?

I think it would make it a lot easier if each chunk was associated with at most one level.
Putting the chunk in a different level would copy the chunk and put the copy in the new level leaving the original in the old one.

This would also make it possible to reach back into the world that owns the chunk. Amulet-Team/Amulet-Map-Editor#685

Feature Description

Add a weak reference to the chunk that stores the level that owns the chunk.
This may be None if the chunk is an orphan chunk.

Here is a prototype including this
https://gist.github.com/gentlegiantJGC/d0f0b6d34db696b5e5d41d166a0033e0

@gentlegiantJGC
Copy link
Member Author

After some thought I think we should make the level manage if the chunk has changed and switch to a get set system that deep copies the chunks.
It makes threading simpler because only one thread can modify a chunk at the same time

There are benefits to be able to go from the chunk to the level that owns it.
I would need to think through what effects this would have on deep copying and serialising the data.

@gentlegiantJGC gentlegiantJGC transferred this issue from Amulet-Team/Amulet-Map-Editor Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant