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

Fixed #29 Lithium breaks stray cat behavior. #31

Merged

Conversation

2No2Name
Copy link
Member

The cause of the bug is that the entity tracker is not checking whether the predicate returns true when evaluating which entity is the closest. The predicate is usually responsible for filtering out certain entities (spectators, or sometimes entities that cannot be seen using raycast, entities on the same team). Not testing the predicate leads to incorrect behavior, as for example, cats usually can't flee from spectators or creative mode players.

The fix adds checking the predicate and the given box (tracking distance of most things is only +-3 on the y axis) after the minimal distance criterion.

Of course this fix will cost some performance, but I don't see a way to get around evaluating the predicate more often than absolutely necessary without sorting the entities by distance first. Also caching the result does not seem viable, because keeping track when the cached value becomes outdated would be required.

@jellysquid3 jellysquid3 added the F-good-pr Flag: This is an example of a good pull request label Apr 12, 2020
@jellysquid3 jellysquid3 merged commit 2d6104b into CaffeineMC:1.16.x/fabric Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-good-pr Flag: This is an example of a good pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants