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

Entities can be duplicated by tracking issues #122

Open
kasamikona opened this issue Jun 9, 2019 · 2 comments
Open

Entities can be duplicated by tracking issues #122

kasamikona opened this issue Jun 9, 2019 · 2 comments
Assignees
Labels

Comments

@kasamikona
Copy link

Entities that don't get tracked correctly can end up being saved more than once, with the same UUID. These duplicate entities will be kept by most servers including the singleplayer integrated server, but only the first loaded one will be visible and functional. Tracking issues will always occur so this case should be handled properly.

Suggested fix: if a newly tracked entity has a UUID already seen during the current download, or existing in nearby saved chunks (possibly configurable radius for performance), remove the older entity. Note: this won't fix cases where a world is downloaded multiple times and an entity has moved outside the checked area, but it will fix all cases within the same download and several cases in repeated downloads.

@Pokechu22 Pokechu22 added the bug label Jun 9, 2019
@Pokechu22 Pokechu22 self-assigned this Jun 9, 2019
@Pokechu22
Copy link
Owner

Thanks for the report. I thought I was already checking for entities with the same UUID when saving, though I'm not entirely sure how I've implemented that (and it's not something I've recently worked on, so the implementation may be incomplete or broken now). I do know that things like saving the world again will cause issues. One other case is if the entity moves -- if it was originally saved in one chunk, but then it moves to another chunk and that chunk is saved, that will cause duplicate entities; this could happen at arbitrary distances (think minecarts on a rail line used by multiple players) and I don't know of a perfect way to fix it other than creating a file that lists positions of all entities (but even that would be problematic since that file wouldn't be updated if entities move in singleplayer).

Pokechu22 added a commit that referenced this issue Jul 10, 2019
This isn't a perfect implementation, as it only avoids it for entities that are being kept in memory to eventually be written, not ones that have already been written fully to disk.  But it should stop at least one of these cases...
@Pokechu22
Copy link
Owner

I've added (dd5db96) something to avoid saving the same entity into multiple chunks, though this only works when the chunks haven't yet been written to disk. I haven't done any testing for it yet, but let me know if this helps. It's not a complete solution, since if the chunk has been written, it still can be duplicated (it won't reload old chunks to remove it). But hopefully it'll do something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants