Skip to content

(1.16) Cleanup and optimise AI #4470

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

Merged
merged 41 commits into from
May 6, 2022

Conversation

PaintNinja
Copy link
Contributor

@PaintNinja PaintNinja commented May 2, 2022

  • Add missing @Overrides
  • Improved style consistency
  • Implemented a cache for lists that call the expensive AABB to improve performance
    • This exploits the likelihood that players won't move far within 0.05s (1 tick), instead caching and reusing the calculated list for up-to 4 ticks
    • The cache is updated every 4th tick and cleared when no longer in use to prevent stale data.
  • Optimised maths code, marked primitives as final where appropriate
  • Reduced unnecessary calculations and checks, commented out dead code
  • Replaced new Random() with ThreadLocalRandom.current()
  • Changed size checks from slotlist.size() >= 1 to the faster and clearer slotlist.isEmpty()

@TheBv TheBv requested review from TheBv and removed request for TheBv May 3, 2022 12:54
@TheBv
Copy link
Collaborator

TheBv commented May 3, 2022

Looks good :)
Thanks for your work!

@TheBv TheBv merged commit b765412 into AlexModGuy:1.16.3 May 6, 2022
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