-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Refactor EffPlaySound to be more readable and resistant to versioning issues. #7022
Refactor EffPlaySound to be more readable and resistant to versioning issues. #7022
Conversation
Co-authored-by: Asleepp <119438940+Asleeepp@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still find kiip's FunctionalInterface usage here easier to read.
Performance was the same for execution. Initialization of the EffPlaySound class was 50-90ms better than existing.
Description
The current state of EffPlaySound relies on a lot of nested FunctionalInterfaces with static methods that makes it quite hard to follow, read, and debug. Issues with differing version support has resulted in two bugs so far, one that has caused an inability to use entity emitters on 1.18 despite the API existing, since the current impl isn't flexible enough to allow it.
This PR re-introduces that feature by refactoring EffPlaySound to use an adapter pattern to unify Player and World playSound methods. It also moves sound validation, among other things, outside of the player loop which should both improve performance and fix an issue where the sound expression was being evaluated once for each player.
I have done manual testing on 1.17, 1.18, and 1.21, though I think junit tests should be implemented via mocking, if feasible. I have not yet looked into that. I would also appreciate any users with existing sound-heavy code to test this PR's nightly out if they can (click Checks -> Java 21 CI -> download from Artifacts).
Target Minecraft Versions: any
Requirements: none
Related Issues: #7016, #6907, #6910