package ca.recrown.islandsurvivalcraft.utilities.datatypes;

import java.util.Objects;

public class Point3 {
    public final int x, y, z;
    private final int hash;

    public Point3(int x, int y, int z) {
        this.x = x;
        this.y = y;
        this.z = z;
        this.hash = Objects.hash(x, y, z);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Point3) {
            Point3 p = (Point3) obj;
            return p.x == this.x && p.y == this.y && p.z == this.z;
        }
        return false;
    }

    public boolean fastEquals(Point3 point) {
        return point.hashCode() == this.hash && x == point.x && y == point.y && z == point.z;
    }

    @Override
    public int hashCode() {
        return hash;
    }

    @Override
    public String toString() {
        return String.format("(%d, %d, %d)", x, y, z);
    }
}