1 package com.irtimaled.bbor.client.models;
3 import com.irtimaled.bbor.common.MathHelper;
4 import com.irtimaled.bbor.common.TypeHelper;
5 import com.irtimaled.bbor.common.models.Coords;
6 import net.minecraft.util.math.Vec3d;
9 private final double x;
10 private final double y;
11 private final double z;
13 public Point(double x, double y, double z) {
19 public Point(Coords Coords) {
20 this.x = Coords.getX();
21 this.y = Coords.getY();
22 this.z = Coords.getZ();
25 public Point(Vec3d pos) {
31 public double getX() {
35 public double getY() {
39 public double getZ() {
43 public Point offset(double x, double y, double z) {
44 return new Point(this.x + x, this.y + y, this.z + z);
47 public Point snapXZ(double nearest) {
48 double x = MathHelper.snapToNearest(this.x, nearest);
49 double z = MathHelper.snapToNearest(this.z, nearest);
50 return new Point(x, this.y, z);
53 public double getDistance(Point point) {
54 double dx = this.x - point.x;
55 double dy = this.y - point.y;
56 double dz = this.z - point.z;
57 return Math.sqrt(dx * dx + dy * dy + dz * dz);
60 public Coords getCoords() {
61 return new Coords(x, y, z);
65 public int hashCode() {
66 return TypeHelper.combineHashCodes(Double.hashCode(z), Double.hashCode(y), Double.hashCode(x));
70 public boolean equals(Object obj) {
71 if (this == obj) return true;
72 if (obj == null || getClass() != obj.getClass()) return false;
73 Point point = (Point) obj;
74 return getX() == point.getX() && getY() == point.getY() && getZ() == point.getZ();