]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/common/models/Coords.java
0768652d4ab6842d257a32216a9a4fb22f20675e
[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.BlockPos;
6
7 public class Coords {
8     private final int x;
9     private final int y;
10     private final int z;
11
12     public Coords(int x, int y, int z) {
13         this.x = x;
14         this.y = y;
15         this.z = z;
16     }
17
18     public Coords(double x, double y, double z) {
19         this.x = MathHelper.floor(x);
20         this.y = MathHelper.floor(y);
21         this.z = MathHelper.floor(z);
22     }
23
24     public Coords(BlockPos blockPos) {
25         this(blockPos.getX(), blockPos.getY(), blockPos.getZ());
26     }
27
28     public int getX() {
29         return x;
30     }
31
32     public int getY() {
33         return y;
34     }
35
36     public int getZ() {
37         return z;
38     }
39
40     @Override
41     public int hashCode() {
42         return TypeHelper.combineHashCodes(z, y, x);
43     }
44
45     @Override
46     public boolean equals(Object obj) {
47         if (this == obj) return true;
48         if (obj == null || getClass() != obj.getClass()) return false;
49         Coords other = (Coords) obj;
50         return getX() == other.getX() &&
51                 getY() == other.getY() &&
52                 getZ() == other.getZ();
53
54     }
55 }
56