]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/common/models/Coords.java
Simplify commands to use Coords & Pos objects
[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) { this(pos.x, pos.y, pos.z); }
30
31     public int getX() {
32         return x;
33     }
34
35     public int getY() {
36         return y;
37     }
38
39     public int getZ() {
40         return z;
41     }
42
43     @Override
44     public int hashCode() {
45         return TypeHelper.combineHashCodes(z, y, x);
46     }
47
48     @Override
49     public boolean equals(Object obj) {
50         if (this == obj) return true;
51         if (obj == null || getClass() != obj.getClass()) return false;
52         Coords other = (Coords) obj;
53         return getX() == other.getX() &&
54                 getY() == other.getY() &&
55                 getZ() == other.getZ();
56
57     }
58 }
59