Skip to content

Commit

Permalink
Implement equals and hashcode for time types
Browse files Browse the repository at this point in the history
  • Loading branch information
StartsMercury committed Feb 1, 2025
1 parent efd68c3 commit c16b03c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,20 @@ public int asHours() {
public int compareTo(final RebuildInterval rhs) {
return Integer.compareUnsigned(this.ticks, rhs.ticks);
}

@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
} else if (obj instanceof final RebuildInterval other) {
return this.ticks == other.ticks;
} else {
return false;
}
}

@Override
public int hashCode() {
return Integer.hashCode(this.ticks);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.SharedConstants;

import java.time.Duration;
import java.util.Objects;

import static io.github.startsmercury.visual_snowy_leaves.impl.client.VslConstants.Duration.ONE_TICK;

Expand Down Expand Up @@ -102,4 +103,20 @@ public int asHours() {
public int compareTo(final TransitionDuration rhs) {
return Integer.compareUnsigned(this.ticks, rhs.ticks);
}

@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
} else if (obj instanceof final TransitionDuration other) {
return this.ticks == other.ticks;
} else {
return false;
}
}

@Override
public int hashCode() {
return Integer.hashCode(this.ticks);
}
}

0 comments on commit c16b03c

Please sign in to comment.