Skip to content

Commit

Permalink
Fix worldcoord upper corners being in another worldcoord (#7539)
Browse files Browse the repository at this point in the history
  • Loading branch information
Warriorrrr authored Aug 1, 2024
1 parent 3eaa72a commit 9be2062
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public Location getLowerMostCornerLocation() {
* @return Location of the upper-most corner of a WorldCoord.
*/
public Location getUpperMostCornerLocation() {
return getCorner().add(getCellSize(), getBukkitWorld().getMaxHeight(), getCellSize());
return getCorner().add(getCellSize() - 1, getBukkitWorld().getMaxHeight() - 1, getCellSize() - 1);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.palmergames.bukkit.towny.object;

import be.seeseemelk.mockbukkit.MockBukkit;
import be.seeseemelk.mockbukkit.ServerMock;
import com.google.common.collect.Iterables;
import com.palmergames.bukkit.towny.TownySettings;
import com.palmergames.util.Pair;
Expand All @@ -13,9 +14,11 @@
import static org.junit.jupiter.api.Assertions.*;

public class WorldCoordTests {
static ServerMock server;

@BeforeAll
static void init() {
MockBukkit.getOrCreateMock();
server = MockBukkit.getOrCreateMock();
TownySettings.loadDefaultConfig();
}

Expand Down Expand Up @@ -49,4 +52,18 @@ void testLargerCellSizeChunkPositions() {
void testSmallerCellSizes(RepetitionInfo info) {
assertEquals(1, new WorldCoord("a", 0, 0).getChunkPositions(info.getCurrentRepetition()).size());
}

@Test
void testCorners() {
int chunkX = -10;
int chunkZ = -10;

server.addSimpleWorld("world");
WorldCoord coord = new WorldCoord("world", chunkX, chunkZ);
assertEquals(chunkX, coord.getUpperMostCornerLocation().getChunk().getX());
assertEquals(chunkZ, coord.getUpperMostCornerLocation().getChunk().getZ());

assertEquals(chunkX, coord.getLowerMostCornerLocation().getChunk().getX());
assertEquals(chunkZ, coord.getLowerMostCornerLocation().getChunk().getZ());
}
}

0 comments on commit 9be2062

Please sign in to comment.