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

Fix #5417 #6929

Merged

Conversation

EliteTK
Copy link
Contributor

@EliteTK EliteTK commented Sep 10, 2024

I don't do Minecraft mods, but I believe based on my understanding of the code and Java that this should address a race which would cause #5417. I have tested this in 1.18.2, and 1.20.1 on both this Forge version and the Fabric port and the issue which I could reproduce around once every 2 tries could no longer be reproduced in about 40 total tries (I'm pretty confident that logically this is the correct code but I am happy to discuss it if someone disagrees).

This issue is most obvious in elevators with multiple doors. When the
collider gets invalidated multiple times in quick succession, multiple
futures are created. If a future which was started before all door state
updates were finalized completed after all other futures, the final
simplifiedEntityColliders would be outdated and invalid (containing
ghost doors, or in the case of an elevator in motion, missing door
collisions).

This commit addresses this issue in two ways:

First by cancelling any existing future to ensure that any future which
completes was started after the most recent invalidation.

Second by removing the null assignment of
simplifiedEntityColliderProvider from the future. This prevents the
future from becoming null after a null check and before a cancellation
(the only time where the null value matters). Cancelling a future twice
is not an issue so there's no need to track if the future is null other
than to avoid a null dereference.
@IThundxr IThundxr added pr type: fix PR fixes a bug pr flag: simple PR has minimal changes labels Sep 10, 2024
@simibubi simibubi merged commit 7c2a40e into Creators-of-Create:mc1.18/dev Oct 8, 2024
2 checks passed
@simibubi
Copy link
Collaborator

simibubi commented Oct 8, 2024

Thanks!

@EliteTK EliteTK deleted the fix-invisible-elevator-doors branch October 8, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr flag: simple PR has minimal changes pr type: fix PR fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants