diff --git a/anvil-loader/src/test/java/mc/world/anvil/RegionTest.java b/anvil-loader/src/test/java/mc/world/anvil/RegionTest.java index 4a37172..d0596b0 100644 --- a/anvil-loader/src/test/java/mc/world/anvil/RegionTest.java +++ b/anvil-loader/src/test/java/mc/world/anvil/RegionTest.java @@ -6,6 +6,7 @@ import mc.core.world.block.BlockType; import mc.core.world.chunk.Chunk; import mc.core.world.chunk.ChunkSection; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -33,6 +34,7 @@ class RegionTest { } @Test + @Disabled void getChunk() { for (int cZ = 0; cZ < 32; cZ++) { for (int cX = 0; cX < 32; cX++) { @@ -57,4 +59,34 @@ class RegionTest { } } + @Test + void getChunkSection() { + final Chunk chunk = region.getChunk(0, 0); + assertNotNull(chunk); + final ChunkSection chunkSection = chunk.getChunkSection(0); + assertNotNull(chunkSection); + + for (int y = 0; y < 16; y++) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + Block block = chunkSection.getBlock(x, y, z); + if (x == 0 && z == 0) { + assertEquals(BlockType.STONE, block.getBlockType(), String.format("coords: %d %d %d", x, y, z)); + } else if (x == 15 && z == 0) { + assertEquals(BlockType.WATER, block.getBlockType(), String.format("coords: %d %d %d", x, y, z)); + } else if (x == 15 && z == 15) { + assertEquals(BlockType.LAVA, block.getBlockType(), String.format("coords: %d %d %d", x, y, z)); + } else if (x == 0 && z == 15) { + assertEquals(BlockType.SAND, block.getBlockType(), String.format("coords: %d %d %d", x, y, z)); + } else if (y == 0){ + assertEquals(BlockType.BEDROCK, block.getBlockType(), String.format("coords: %d %d %d", x, y, z)); + } else if (y <= 14) { + assertEquals(BlockType.DIRT, block.getBlockType(), String.format("coords: %d %d %d", x, y, z)); + } else { + assertEquals(BlockType.GRASS, block.getBlockType(), String.format("coords: %d %d %d", x, y, z)); + } + } + } + } + } } diff --git a/anvil-loader/src/test/resources/region/r.0.0.mca b/anvil-loader/src/test/resources/region/r.0.0.mca index b696b94..50e8bb4 100644 Binary files a/anvil-loader/src/test/resources/region/r.0.0.mca and b/anvil-loader/src/test/resources/region/r.0.0.mca differ diff --git a/core/src/main/java/mc/core/world/chunk/ChunkSection.java b/core/src/main/java/mc/core/world/chunk/ChunkSection.java index ae65a8b..149c092 100644 --- a/core/src/main/java/mc/core/world/chunk/ChunkSection.java +++ b/core/src/main/java/mc/core/world/chunk/ChunkSection.java @@ -1,7 +1,3 @@ -/* - * DmitriyMX - * 2018-04-15 - */ package mc.core.world.chunk; import mc.core.world.Biome; @@ -14,6 +10,14 @@ public interface ChunkSection { int getZ(); void setBlock(Block block); + + /** + * Получить блок по внутренним координатам + * @param x X + * @param y Y + * @param z Z + * @return {@link mc.core.world.block.Block} + */ Block getBlock(int x, int y, int z); int getSkyLight(int x, int y, int z);