Fixed perfect chunk coordinates in utilities.

Added respective tests to ensure this doesn't break.
This commit is contained in:
2020-04-27 13:44:49 -05:00
parent 39381f07f9
commit ec27a9bc10
2 changed files with 20 additions and 6 deletions

View File

@@ -53,13 +53,15 @@ public class Utilities {
public static Point2 worldToLocalChunkCoordinates(int x, int y) {
int xRes = 0;
if (x < 0) {
xRes = CHUNK_SIZE + (x % CHUNK_SIZE);
xRes = CHUNK_SIZE - 1 + (x % CHUNK_SIZE);
xRes %= CHUNK_SIZE - 1;
} else {
xRes = x % CHUNK_SIZE;
}
int yRes = 0;
if (y < 0) {
yRes = CHUNK_SIZE + (y % CHUNK_SIZE);
yRes = CHUNK_SIZE - 1 + (y % CHUNK_SIZE);
yRes %= CHUNK_SIZE - 1;
} else {
yRes = y % CHUNK_SIZE;
}