Add Minecraft coordinate boundary mapper
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.livingworld.integration.minecraft;
|
||||
|
||||
import com.livingworld.regions.RegionCoordinate;
|
||||
|
||||
/**
|
||||
* Converts platform coordinate values into Living World coordinates.
|
||||
*/
|
||||
public final class MinecraftCoordinateMapper {
|
||||
|
||||
public RegionCoordinate fromBlockPos(
|
||||
String dimensionId,
|
||||
int blockX,
|
||||
int blockZ,
|
||||
int regionSizeChunks) {
|
||||
return RegionCoordinate.fromBlock(
|
||||
dimensionId,
|
||||
blockX,
|
||||
blockZ,
|
||||
regionSizeChunks);
|
||||
}
|
||||
|
||||
public RegionCoordinate fromChunkPos(
|
||||
String dimensionId,
|
||||
int chunkX,
|
||||
int chunkZ,
|
||||
int regionSizeChunks) {
|
||||
return RegionCoordinate.fromChunk(
|
||||
dimensionId,
|
||||
chunkX,
|
||||
chunkZ,
|
||||
regionSizeChunks);
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.livingworld.integration.minecraft;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import com.livingworld.regions.RegionCoordinate;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class MinecraftCoordinateMapperTest {
|
||||
|
||||
private final MinecraftCoordinateMapper mapper = new MinecraftCoordinateMapper();
|
||||
|
||||
@Test
|
||||
void mapsBlockCoordinatesThroughRegionCoordinate() {
|
||||
assertEquals(
|
||||
new RegionCoordinate("minecraft:overworld", -2, 1),
|
||||
mapper.fromBlockPos("minecraft:overworld", -129, 128, 8));
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapsChunkCoordinatesThroughRegionCoordinate() {
|
||||
assertEquals(
|
||||
new RegionCoordinate("minecraft:the_nether", -1, 1),
|
||||
mapper.fromChunkPos("minecraft:the_nether", -1, 8, 8));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user