Fixed perfect chunk coordinates in utilities.
Added respective tests to ensure this doesn't break.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user