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

Added entity support #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added entity support #167

wants to merge 1 commit into from

Conversation

Ery4z
Copy link

@Ery4z Ery4z 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

@Ery4z
Copy link
Author

Ery4z 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.

2 participants