Skip to content

Commit ae1eb74

Browse files
committed
update
1 parent 55e3c0d commit ae1eb74

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

voxels-common/src/main/java/common/world/Location.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,30 @@ public void setPosition(double x, double y, double z) {
6969
this.y = y;
7070
this.z = z;
7171
}
72+
73+
public int getChunkX() {
74+
return WorldMath.worldToChunk(x, ChunkData.WIDTH);
75+
}
76+
77+
public int getChunkZ() {
78+
return WorldMath.worldToChunk(z, ChunkData.DEPTH);
79+
}
80+
81+
public int getBlockX() {
82+
return fastFloor(x);
83+
}
84+
85+
public int getBlockY() {
86+
return fastFloor(y);
87+
}
88+
89+
public int getBlockZ() {
90+
return fastFloor(z);
91+
}
92+
93+
private int fastFloor(double x) {
94+
// int i = (int) x;
95+
// return x < i ? i - 1 : i;
96+
return (int) Math.floor(x);
97+
}
7298
}

0 commit comments

Comments
 (0)