-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Make every Vec3i use BetterBlockPos hash #4501
base: 1.19.4
Are you sure you want to change the base?
Conversation
This is a crazy big change, it could have tons of unintended side effects 😭 |
Better stop passing Alternatively if no |
I think the only other solution is to just not override the hashcode at all and figure out a different way to use the better hash function when using hashmaps but I don't think this could cause any problems anyways |
That different way of using the better hash would be a class equivalent to |
The different way could just be fastutil's OpenCustomHashMaps or a simple class that just extends BetterBlockPos and is explicitly only to be used as keys to a hashmap. Creating a completely separate class would be unnecessarily annoying and would inevitably create a ton of unnecessary conversions that would make performance worse. |
Please not a class only meant to be used for hash maps. That's doomed to end where we are already. |
I don't think overriding the hashCode should cause any issues in practice, nothing should actually rely on the hashCode being the same between game launches... anyway, the other way would be to extend HashMap/HashSet to overwrite what it querys for hashCode like babbaj said |
the map already grabs the hashcode manually: https://github.com/cabaletta/baritone/blob/1.19.4/src/main/java/baritone/pathing/calc/AbstractNodeCostSearch.java#L169 |
Is there any other reason to overwrite the hash code? (Other than general Minecraft performance, which I'd leave to optimization mods and mojang) |
BetterBlockPos returning a different hashCode than the superclasses is a massively stupid correctness problem and is currently causing my game to crash.
In theory this might also improve performance a bit if it allows the jvm to devirtualize calls to hashCode.