поправлены тесты
убраны заигноренные, упрощены для чтения действующие
This commit is contained in:
@@ -1,62 +1,25 @@
|
|||||||
package mc.world.anvil;
|
package mc.world.anvil;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import mc.core.world.block.Block;
|
import mc.core.world.block.Block;
|
||||||
import mc.core.world.block.BlockType;
|
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;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
class RegionTest {
|
class RegionTest {
|
||||||
private static Region region;
|
private static Region region;
|
||||||
private static List<BlockType> layersBlock;
|
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
static void before() throws URISyntaxException, IOException {
|
static void before() throws URISyntaxException, IOException {
|
||||||
region = new Region(Paths.get(RegionTest.class.getResource("/region/r.0.0.mca").toURI()).toFile());
|
region = new Region(Paths.get(RegionTest.class.getResource("/region/r.0.0.mca").toURI()).toFile());
|
||||||
|
|
||||||
layersBlock = Lists.newArrayList(
|
|
||||||
BlockType.BEDROCK,
|
|
||||||
BlockType.DIRT,
|
|
||||||
BlockType.DIRT,
|
|
||||||
BlockType.GRASS
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Disabled
|
|
||||||
void getChunk() {
|
|
||||||
for (int cZ = 0; cZ < 32; cZ++) {
|
|
||||||
for (int cX = 0; cX < 32; cX++) {
|
|
||||||
Chunk chunk = region.getChunk(cX, cZ);
|
|
||||||
assertNotNull(chunk);
|
|
||||||
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 (y > layersBlock.size()-1) {
|
|
||||||
assertEquals(BlockType.AIR, block.getBlockType(), String.format("coords: %d %d %d", x+(cX*16), y, z+(cZ*16)));
|
|
||||||
} else {
|
|
||||||
assertEquals(layersBlock.get(y), block.getBlockType(), String.format("coords: %d %d %d", x+(cX*16), y, z+(cZ*16)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -66,7 +29,15 @@ class RegionTest {
|
|||||||
|
|
||||||
ChunkSection chunkSection = chunk.getChunkSection(0);
|
ChunkSection chunkSection = chunk.getChunkSection(0);
|
||||||
assertNotNull(chunkSection);
|
assertNotNull(chunkSection);
|
||||||
|
checkSection1(chunkSection);
|
||||||
|
|
||||||
|
|
||||||
|
chunkSection = chunk.getChunkSection(1);
|
||||||
|
assertNotNull(chunkSection);
|
||||||
|
checkSection2(chunkSection);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkSection1(ChunkSection chunkSection) {
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
@@ -89,10 +60,9 @@ class RegionTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
chunkSection = chunk.getChunkSection(1);
|
private void checkSection2(ChunkSection chunkSection) {
|
||||||
assertNotNull(chunkSection);
|
|
||||||
|
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user