Skip to content

Conversation

@B33low
Copy link

@B33low B33low commented Nov 20, 2022

Hello,
After working on a script for copying chunk between worlds while preserving entities, I found myself writing lot of boilerplate code. But in fact as the region file are the same format for entities and regular region, it is possible to load the entities region files in the WorldFolder class.
I added an option to select if the user want to load the entities files or the regular region.
Then he can access the entity data with the regular get_region function.

What are you thinking of this ?

@twoolie
Copy link
Owner

twoolie commented Dec 27, 2022

Hi @Ery4z, thanks for the contribution.

I think it's a very good idea to add entity support, but i have a few suggestions for the implementation.

With your implementation, somebody wanting to edit both regions and entities within a world would need to create two WorldFolder objects, and editing entities would still require calling the get_regionfiles and set_regionfiles methods which could be unintuitive for new users.

I think it would be useful to create new functions specific to entity handling that mirror the region handling code.

Please let me know if you are happy and have time to amend this PR

@B33low
Copy link
Author

B33low commented Dec 27, 2022

Hi @twoolie, thanks for your review.
I would be happy to work on this feature, but before doing that I would need your review on some point.

I implemented the entities support feature the way you described it above on a fork a year ago while working on a map editor project. And I found out multiple problematic points that need to be taken care of.

The most problematic one is that every entities (block entity such as shulker, chest,... & regular mob entity) has their absolute world position in the nbt tag. This mean that the simple action of copying a chunk is not straight forward.

To solve this problem, I implemented such a mechanism

Load the region & entity file (Single WorldFolder object) -> Select the chunk to be copied and export a normalised version of it (normalising the entities coordinate relatively to the origin of this specific chunk) -> Denormalize the chunk relatively to the paste location in the output WorldFolder object and paste them into it.

This would also allow for future feature to select if we want to do the automatic blend nearby the pasted chunk (see this ) But this feature is out of the scope of this PR but would be easily implemented.

What do you think about me implementing function for normalising entities data, exporting the chunk bundling blocks and entities & importing theses chunks ?

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

Successfully merging this pull request may close these issues.

3 participants