]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/common/models/Coords.java
Tidy up
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / common / models / Coords.java
1 package com.irtimaled.bbor.common.models;
2
3 import com.irtimaled.bbor.common.MathHelper;
4 import com.irtimaled.bbor.common.TypeHelper;
5 import net.minecraft.util.math.Vec3d;
6 import net.minecraft.util.math.Vec3i;
7
8 public class Coords {
9     private final int x;
10     private final int y;
11     private final int z;
12
13     public Coords(int x, int y, int z) {
14         this.x = x;
15         this.y = y;
16         this.z = z;
17     }
18
19     public Coords(double x, double y, double z) {
20         this.x = MathHelper.floor(x);
21         this.y = MathHelper.floor(y);
22         this.z = MathHelper.floor(z);
23     }
24
25     public Coords(Vec3i pos) {
26         this(pos.getX(), pos.getY(), pos.getZ());
27     }
28
29     public Coords(Vec3d pos) {
30         this(pos.x, pos.y, pos.z);
31     }
32
33     public int getX() {
34         return x;
35     }
36
37     public int getY() {
38         return y;
39     }
40
41     public int getZ() {
42         return z;
43     }
44
45     @Override
46     public int hashCode() {
47         return TypeHelper.combineHashCodes(z, y, x);
48     }
49
50     @Override
51     public boolean equals(Object obj) {
52         if (this == obj) return true;
53         if (obj == null || getClass() != obj.getClass()) return false;
54         Coords other = (Coords) obj;
55         return getX() == other.getX() &&
56                 getY() == other.getY() &&
57                 getZ() == other.getZ();
58
59     }
60 }
61