From 6ba5f64db6ce994bc5b590e2e8567f3896329e61 Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 11 Aug 2021 15:08:54 +0200 Subject: [PATCH] Cleared up `Section#toChunkCoordinate` --- .../java/net/minestom/server/instance/Section.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/minestom/server/instance/Section.java b/src/main/java/net/minestom/server/instance/Section.java index d96545efb..4ac9dc5c0 100644 --- a/src/main/java/net/minestom/server/instance/Section.java +++ b/src/main/java/net/minestom/server/instance/Section.java @@ -20,14 +20,14 @@ public class Section implements PublicCloneable
{ } 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
{ } /** - * 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;