hashCode and equals for BlockPosition

This commit is contained in:
jglrxavpok 2020-05-04 00:09:40 +02:00
parent 05acfdf59f
commit edf2def4e4

View File

@ -1,5 +1,7 @@
package net.minestom.server.utils; package net.minestom.server.utils;
import java.util.Objects;
// TODO: pool block positions? // TODO: pool block positions?
public class BlockPosition { public class BlockPosition {
@ -75,6 +77,21 @@ public class BlockPosition {
return new Position(x, y, z); return new Position(x, y, z);
} }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BlockPosition that = (BlockPosition) o;
return x == that.x &&
y == that.y &&
z == that.z;
}
@Override
public int hashCode() {
return Objects.hash(x, y, z);
}
@Override @Override
public String toString() { public String toString() {
return "BlockPosition[" + x + ":" + y + ":" + z + "]"; return "BlockPosition[" + x + ":" + y + ":" + z + "]";