Archived
0

обновлен RegionTest

добавлен чанк с более 16 типами блоков
This commit is contained in:
2018-12-30 15:43:59 +03:00
parent 56888c63a1
commit 6210a9bede
2 changed files with 56 additions and 3 deletions

View File

@@ -10,11 +10,14 @@ 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.DisplayName;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -110,14 +113,64 @@ class RegionTest {
} }
}; };
ChunkChecker chunkChecker01 = new ChunkChecker() {
@Override
public void check(Chunk chunk) {
ChunkSection section = chunk.getChunkSection(0);
assertNotNull(section);
final List<BlockType> exceptedTypes = Arrays.asList(
BlockType.CLAY,
BlockType.ORE_REDSTONE,
BlockType.ORE_DIAMOND,
BlockType.OBSIDIAN,
BlockType.MOSS_STONE,
BlockType.SANDSTONE,
BlockType.ORE_LAPIS,
BlockType.WOOD_JUNGLE,
BlockType.WOOD_BIRCH,
BlockType.WOOD_SPRUCE,
BlockType.WOOD_OAK,
BlockType.ORE_COAL,
BlockType.ORE_IRON,
BlockType.ORE_GOLD,
BlockType.GRAVEL,
BlockType.SAND
);
for (int y = 0; y < 2; y++) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
Block block = section.getBlock(x, y, z);
String msg = String.format("coords: %d %d %d", x, y, z);
if (y == 0) {
// @formatter:off
if (x == 0 && z == 0) assertEquals(BlockType.STONE, block.getType(), msg);
else if (x == 15 && z == 0) assertEquals(BlockType.GRANITE, block.getType(), msg);
else if (x == 0 && z == 15) assertEquals(BlockType.POLISHED_GRANITE, block.getType(), msg);
else if (x == 15 && z == 15) assertEquals(BlockType.DIORITE, block.getType(), msg);
else assertEquals(BlockType.BEDROCK, block.getType(), msg);
// @formatter:on
} else {
assertEquals(exceptedTypes.get(x), block.getType(), msg);
}
}
}
}
}
};
return Stream.of( return Stream.of(
Arguments.of(0, 0, chunkChecker00) Arguments.of(0, 0, chunkChecker00),
Arguments.of(0, 1, chunkChecker01)
); );
} }
@ParameterizedTest @DisplayName("testGetChunk")
@ParameterizedTest(name = "[{index}] chunk {0},{1}")
@MethodSource("streamArguments") @MethodSource("streamArguments")
void getChunkSection(int chunkX, int chunkZ, ChunkChecker chunkChecker) { void testGetChunk(int chunkX, int chunkZ, ChunkChecker chunkChecker) {
final Chunk chunk = region.getChunk(chunkX, chunkZ); final Chunk chunk = region.getChunk(chunkX, chunkZ);
assertNotNull(chunk); assertNotNull(chunk);