From e1427c8db6ab3763a30727b9bb1f2c242fb725b8 Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Mon, 17 Dec 2018 11:34:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=82=D0=B5=D1=81=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit убраны заигноренные, упрощены для чтения действующие --- .../test/java/mc/world/anvil/RegionTest.java | 50 ++++--------------- 1 file changed, 10 insertions(+), 40 deletions(-) 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 f9f83f9..ed1e0f5 100644 --- a/anvil-loader/src/test/java/mc/world/anvil/RegionTest.java +++ b/anvil-loader/src/test/java/mc/world/anvil/RegionTest.java @@ -1,62 +1,25 @@ package mc.world.anvil; -import com.google.common.collect.Lists; import mc.core.world.block.Block; 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; import java.net.URISyntaxException; import java.nio.file.Paths; -import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; class RegionTest { private static Region region; - private static List layersBlock; @BeforeAll static void before() throws URISyntaxException, IOException { 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 @@ -66,7 +29,15 @@ class RegionTest { ChunkSection chunkSection = chunk.getChunkSection(0); 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 x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { @@ -89,10 +60,9 @@ class RegionTest { } } } + } - chunkSection = chunk.getChunkSection(1); - assertNotNull(chunkSection); - + private void checkSection2(ChunkSection chunkSection) { for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) {