Archived
0

обновление теста anvil chunk

В качестве тестового региона взят искусственно созданный (mcedit). В него добавлен один полный (16х16х16) фрагмент чанка. Для отслеживания корректного порядка чтения блоков, по углам чанка расставлены блоки-маркеры.
This commit is contained in:
2018-10-27 15:30:10 +03:00
parent 5cca630dfd
commit 24298cb2ef
3 changed files with 40 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import mc.core.world.block.BlockType;
import mc.core.world.chunk.Chunk; import mc.core.world.chunk.Chunk;
import mc.core.world.chunk.ChunkSection; import mc.core.world.chunk.ChunkSection;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.IOException; import java.io.IOException;
@@ -33,6 +34,7 @@ class RegionTest {
} }
@Test @Test
@Disabled
void getChunk() { void getChunk() {
for (int cZ = 0; cZ < 32; cZ++) { for (int cZ = 0; cZ < 32; cZ++) {
for (int cX = 0; cX < 32; cX++) { 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));
}
}
}
}
}
} }

View File

@@ -1,7 +1,3 @@
/*
* DmitriyMX <dimon550@gmail.com>
* 2018-04-15
*/
package mc.core.world.chunk; package mc.core.world.chunk;
import mc.core.world.Biome; import mc.core.world.Biome;
@@ -14,6 +10,14 @@ public interface ChunkSection {
int getZ(); int getZ();
void setBlock(Block block); 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); Block getBlock(int x, int y, int z);
int getSkyLight(int x, int y, int z); int getSkyLight(int x, int y, int z);