Merge pull request #405 from BitCrack/change-to-chunk-coordinate

Cleared up `Section#toChunkCoordinate`.
This commit is contained in:
TheMode 2021-08-11 15:24:33 +02:00 committed by GitHub
commit 03c22e591a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,14 +20,14 @@ public class Section implements PublicCloneable<Section> {
}
public short getBlockAt(int x, int y, int z) {
x = toChunkCoordinate(x);
z = toChunkCoordinate(z);
x = toChunkRelativeCoordinate(x);
z = toChunkRelativeCoordinate(z);
return palette.getBlockAt(x, y, z);
}
public void setBlockAt(int x, int y, int z, short blockId) {
x = toChunkCoordinate(x);
z = toChunkCoordinate(z);
x = toChunkRelativeCoordinate(x);
z = toChunkRelativeCoordinate(z);
palette.setBlockAt(x, y, z, blockId);
}
@ -65,12 +65,12 @@ public class Section implements PublicCloneable<Section> {
}
/**
* Converts a world coordinate to a chunk one.
* Returns a coordinate that is relative to a chunk the provided coordinate is in.
*
* @param xz the world coordinate
* @return the chunk coordinate of {@code xz}
* @return a coordinate relative to the closest chunk
*/
private static int toChunkCoordinate(int xz) {
private static int toChunkRelativeCoordinate(int xz) {
xz %= 16;
if (xz < 0) {
xz += Chunk.CHUNK_SECTION_SIZE;