Fixed conversion from world to chunk coords.
Added test that catches this case.
This commit is contained in:
parent
26ebf7af33
commit
49f26f7901
@ -38,7 +38,7 @@ public class Utilities {
|
||||
xRes = x / CHUNK_SIZE;
|
||||
}
|
||||
int yRes = 0;
|
||||
if (x < 0) {
|
||||
if (y < 0) {
|
||||
yRes = (int) Math.floor((float) y / CHUNK_SIZE);
|
||||
} else {
|
||||
yRes = y / CHUNK_SIZE;
|
||||
|
@ -61,6 +61,11 @@ public class UtilitiesTest {
|
||||
assertEquals(new Point2(-4, -3), Utilities.worldToChunkCoordinates(-55, -33));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWorldToChunkCoordinatesNegativeOffClose() {
|
||||
assertEquals(new Point2(15, -15), Utilities.worldToChunkCoordinates(255, -227));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWorldToChunkCoordinatesPositivePerfect() {
|
||||
assertEquals(new Point2(4, 5), Utilities.worldToChunkCoordinates(64, 80));
|
||||
|
Loading…
Reference in New Issue
Block a user