1 package com.irtimaled.bbor.common.models;
3 import com.irtimaled.bbor.common.MathHelper;
4 import com.irtimaled.bbor.common.TypeHelper;
5 import net.minecraft.util.math.Vec3d;
8 private final double x;
9 private final double y;
10 private final double z;
12 public Point(double x, double y, double z) {
18 public Point(Coords Coords) {
19 this.x = Coords.getX();
20 this.y = Coords.getY();
21 this.z = Coords.getZ();
24 public Point(Vec3d pos) {
30 public double getX() {
34 public double getY() {
38 public double getZ() {
42 public Point offset(double x, double y, double z) {
43 return new Point(this.x + x, this.y + y, this.z + z);
46 public Point snapXZ(double nearest) {
47 double x = MathHelper.snapToNearest(this.x, nearest);
48 double z = MathHelper.snapToNearest(this.z, nearest);
49 return new Point(x, this.y, z);
52 public double getDistance(Point point) {
53 double dx = this.x - point.x;
54 double dy = this.y - point.y;
55 double dz = this.z - point.z;
56 return Math.sqrt(dx * dx + dy * dy + dz * dz);
59 public Coords getCoords() {
60 return new Coords(x, y, z);
64 public int hashCode() {
65 return TypeHelper.combineHashCodes(Double.hashCode(z), Double.hashCode(y), Double.hashCode(x));
69 public boolean equals(Object obj) {
70 if (this == obj) return true;
71 if (obj == null || getClass() != obj.getClass()) return false;
72 Point point = (Point) obj;
73 return getX() == point.getX() && getY() == point.getY() && getZ() == point.getZ();