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