From d32973cae4e6af1b5b83edf2f070dfa19ffd1703 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Tue, 21 Mar 2023 00:42:09 -0700 Subject: [PATCH] equals and hashcode for navigable surface tree attachment --- .../java/baritone/builder/NavigableSurface.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/baritone/builder/NavigableSurface.java b/src/main/java/baritone/builder/NavigableSurface.java index baa04b9db..273ff9161 100644 --- a/src/main/java/baritone/builder/NavigableSurface.java +++ b/src/main/java/baritone/builder/NavigableSurface.java @@ -54,6 +54,23 @@ public class NavigableSurface { public Attachment() { this.surfaceSize = 1; } + + @Override + public boolean equals(Object o) { // used as performance optimization in RedBlackNode to avoid augmenting unchanged attachments + if (this == o) { + return true; + } + if (!(o instanceof Attachment)) { + return false; + } + Attachment that = (Attachment) o; + return surfaceSize == that.surfaceSize; + } + + @Override + public int hashCode() { + return surfaceSize; + } } public OptionalInt surfaceSize(BetterBlockPos pos) { // how big is the navigable surface from here? how many distinct coordinates can i walk to (in the future, the augmentation will probably have a list of those coordinates or something?)