diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java index 4307b3fa2..5cb41981e 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java @@ -364,7 +364,7 @@ public class FullDataPointIdMap if (newMap.size() != entityCount) { // if the mappings are out of sync then the LODs will render incorrectly due to IDs being wrong - LodUtil.assertNotReach("ID maps failed to deserialize for pos: ["+DhSectionPos.toString(pos)+"], incorrect entity count. Expected count ["+entityCount+"], actual count ["+newMap.size()+"]"); + LodUtil.assertNotReach("ID maps failed to deserialize for pos: ["+ DhSectionPos.toString(pos)+"], incorrect entity count. Expected count ["+entityCount+"], actual count ["+newMap.size()+"]"); } return newMap; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java index 6828629a1..e95957c62 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java @@ -271,7 +271,7 @@ public class FullDataSourceV2 implements IDataSource // both data sources should have the same detail level if (DhSectionPos.getDetailLevel(inputDataSource.pos) != DhSectionPos.getDetailLevel(this.pos)) { - throw new IllegalArgumentException("Both data sources must have the same detail level. Expected ["+DhSectionPos.getDetailLevel(this.pos)+"], received ["+DhSectionPos.getDetailLevel(inputDataSource.pos)+"]."); + throw new IllegalArgumentException("Both data sources must have the same detail level. Expected ["+ DhSectionPos.getDetailLevel(this.pos)+"], received ["+ DhSectionPos.getDetailLevel(inputDataSource.pos)+"]."); } // copy over everything from the input data source into this one @@ -362,9 +362,9 @@ public class FullDataSourceV2 implements IDataSource // determine where in the input data source should be written to // since the input is one detail level below it will be one of this position's 4 children - int minChildXPos = DhSectionPos.getX(DhSectionPos.getChildByIndex(0, this.pos)); + int minChildXPos = DhSectionPos.getX(DhSectionPos.getChildByIndex(this.pos, 0)); int recipientOffsetX = (DhSectionPos.getX(inputDataSource.pos) == minChildXPos) ? 0 : (WIDTH / 2); - int minChildZPos = DhSectionPos.getZ(DhSectionPos.getChildByIndex(0, this.pos)); + int minChildZPos = DhSectionPos.getZ(DhSectionPos.getChildByIndex(this.pos, 0)); int recipientOffsetZ = (DhSectionPos.getZ(inputDataSource.pos) == minChildZPos) ? 0 : (WIDTH / 2); @@ -793,7 +793,7 @@ public class FullDataSourceV2 implements IDataSource if (firstBottomY < lastBottomY) { - throw new IllegalStateException("Incorrect data point order at pos: ["+DhSectionPos.toString(pos)+"], first datapoint bottom Y ["+firstBottomY+"], last datapoint bottom Y ["+lastBottomY+"]."); + throw new IllegalStateException("Incorrect data point order at pos: ["+ DhSectionPos.toString(pos)+"], first datapoint bottom Y ["+firstBottomY+"], last datapoint bottom Y ["+lastBottomY+"]."); } } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/FullDataToRenderDataTransformer.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/FullDataToRenderDataTransformer.java index 30d4d5a4c..3f0e29f52 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/FullDataToRenderDataTransformer.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/FullDataToRenderDataTransformer.java @@ -115,9 +115,9 @@ public class FullDataToRenderDataTransformer int baseX = DhSectionPos.getMinCornerBlockX(pos); int baseZ = DhSectionPos.getMinCornerBlockZ(pos); - for (int x = 0; x < DhSectionPos.getWidthCountForLowerDetailedSection(dataDetail, pos); x++) + for (int x = 0; x < DhSectionPos.getWidthCountForLowerDetailedSection(pos, dataDetail); x++) { - for (int z = 0; z < DhSectionPos.getWidthCountForLowerDetailedSection(dataDetail, pos); z++) + for (int z = 0; z < DhSectionPos.getWidthCountForLowerDetailedSection(pos, dataDetail); z++) { throwIfThreadInterrupted(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractDataSourceHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractDataSourceHandler.java index ab54b191e..ec6c50f85 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractDataSourceHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractDataSourceHandler.java @@ -177,7 +177,7 @@ public abstract class AbstractDataSourceHandler catch (InterruptedException ignore) { } catch (IOException e) { - LOGGER.warn("File read Error for pos ["+DhSectionPos.toString(pos)+"], error: "+e.getMessage(), e); + LOGGER.warn("File read Error for pos ["+ DhSectionPos.toString(pos)+"], error: "+e.getMessage(), e); } return dataSource; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/DataSourcePool.java b/core/src/main/java/com/seibel/distanthorizons/core/file/DataSourcePool.java index 226006a2d..cd8da6f4b 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/DataSourcePool.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/DataSourcePool.java @@ -1,7 +1,6 @@ package com.seibel.distanthorizons.core.file; import com.seibel.distanthorizons.core.level.IDhLevel; -import com.seibel.distanthorizons.core.pos.DhSectionPos; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/IDataSource.java b/core/src/main/java/com/seibel/distanthorizons/core/file/IDataSource.java index e662c79a8..3b855e729 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/IDataSource.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/IDataSource.java @@ -3,7 +3,6 @@ package com.seibel.distanthorizons.core.file; import com.seibel.distanthorizons.api.enums.EDhApiDetailLevel; import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.level.IDhLevel; -import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.sql.dto.IBaseDTO; /** diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/DelayedFullDataSourceSaveCache.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/DelayedFullDataSourceSaveCache.java index bf6a71b67..e2efce4c7 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/DelayedFullDataSourceSaveCache.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/DelayedFullDataSourceSaveCache.java @@ -2,7 +2,6 @@ package com.seibel.distanthorizons.core.file.fullDatafile; import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; -import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.util.TimerUtil; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV1.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV1.java index 86b95ac2b..4c1e443fe 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV1.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV1.java @@ -134,12 +134,12 @@ public class FullDataSourceProviderV1 { // stack trace not included since a lot of corrupt data would cause the log to get quite messy, // and it should be fairly easy to see what the problem was from the message - LOGGER.warn("Corrupted data found at pos ["+DhSectionPos.toString(pos)+"]. Data at position will be deleted so it can be re-generated and to prevent future issues. Error: "+e.getMessage()); + LOGGER.warn("Corrupted data found at pos ["+ DhSectionPos.toString(pos)+"]. Data at position will be deleted so it can be re-generated and to prevent future issues. Error: "+e.getMessage()); this.repo.deleteWithKey(pos); } catch (IOException e) { - LOGGER.warn("File read Error for pos ["+DhSectionPos.toString(pos)+"], error: "+e.getMessage(), e); + LOGGER.warn("File read Error for pos ["+ DhSectionPos.toString(pos)+"], error: "+e.getMessage(), e); } return dataSource; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java index 32d529e88..d2e61e34b 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java @@ -50,7 +50,6 @@ import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReentrantLock; -import java.util.function.Function; /** * Handles reading/writing {@link FullDataSourceV2} diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataSourceProvider.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataSourceProvider.java index 371f68b39..37c6ee221 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataSourceProvider.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataSourceProvider.java @@ -42,7 +42,6 @@ import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; -import java.util.function.Function; public class GeneratedFullDataSourceProvider extends FullDataSourceProviderV2 implements IDebugRenderable { @@ -280,7 +279,7 @@ public class GeneratedFullDataSourceProvider extends FullDataSourceProviderV2 im // TODO speed up this logic by only checking ungenerated columns LongArrayList generationList = new LongArrayList(); byte minGeneratorSectionDetailLevel = (byte) (worldGenQueue.highestDataDetail() + DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL); - DhSectionPos.forEachChildAtDetailLevel(minGeneratorSectionDetailLevel, (genPos) -> + DhSectionPos.forEachChildAtDetailLevel(pos, minGeneratorSectionDetailLevel, (genPos) -> { if (!this.repo.existsWithKey(genPos)) { @@ -331,7 +330,7 @@ public class GeneratedFullDataSourceProvider extends FullDataSourceProviderV2 im generationList.add(genPos); } - }, pos); + }); return generationList; } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/subDimMatching/SubDimensionLevelMatcher.java b/core/src/main/java/com/seibel/distanthorizons/core/file/subDimMatching/SubDimensionLevelMatcher.java index 6a30b948c..6089fb823 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/subDimMatching/SubDimensionLevelMatcher.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/subDimMatching/SubDimensionLevelMatcher.java @@ -224,8 +224,8 @@ public class SubDimensionLevelMatcher implements AutoCloseable // confirm both data sources have the same section pos - long newSectionChunkPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, newDataSource.getPos()); - long testSectionChunkPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, testFullDataSource.getPos()); + long newSectionChunkPos = DhSectionPos.convertToDetailLevel(newDataSource.getPos(), DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL); + long testSectionChunkPos = DhSectionPos.convertToDetailLevel(testFullDataSource.getPos(), DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL); LodUtil.assertTrue(newSectionChunkPos == testSectionChunkPos, "data source positions don't match"); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/IFullDataSourceRetrievalQueue.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/IFullDataSourceRetrievalQueue.java index d3ebde39d..9a398d25f 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/generation/IFullDataSourceRetrievalQueue.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/IFullDataSourceRetrievalQueue.java @@ -27,7 +27,6 @@ import com.seibel.distanthorizons.core.render.LodQuadTree; import java.io.Closeable; import java.util.concurrent.CompletableFuture; -import java.util.function.Function; /** * Used to track what full data sources the system currently diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java index 738e19858..95b712948 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java @@ -49,7 +49,6 @@ import java.awt.*; import java.util.*; import java.util.concurrent.*; import java.util.function.Consumer; -import java.util.function.Function; public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDebugRenderable { @@ -310,14 +309,14 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb LinkedList> childFutures = new LinkedList<>(); long sectionPos = closestTask.pos; WorldGenTask finalClosestTask = closestTask; - DhSectionPos.forEachChild((childDhSectionPos) -> + DhSectionPos.forEachChild(sectionPos, (childDhSectionPos) -> { CompletableFuture newFuture = new CompletableFuture<>(); childFutures.add(newFuture); WorldGenTask newGenTask = new WorldGenTask(childDhSectionPos, DhSectionPos.getDetailLevel(childDhSectionPos), finalClosestTask.taskTracker, newFuture); this.waitingTasks.put(newGenTask.pos, newGenTask); - }, sectionPos); + }); // send the child futures to the future recipient, to notify them of the new tasks closestTask.future.complete(WorldGenResult.CreateSplit(childFutures)); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/WorldGenResult.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/WorldGenResult.java index f5f1ed38c..6aa3e9298 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/WorldGenResult.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/WorldGenResult.java @@ -19,8 +19,6 @@ package com.seibel.distanthorizons.core.generation.tasks; -import com.seibel.distanthorizons.core.pos.DhSectionPos; - import java.util.Collection; import java.util.LinkedList; import java.util.concurrent.CompletableFuture; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/WorldGenTask.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/WorldGenTask.java index 69f70a32b..123e36167 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/WorldGenTask.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/WorldGenTask.java @@ -19,8 +19,6 @@ package com.seibel.distanthorizons.core.generation.tasks; -import com.seibel.distanthorizons.core.pos.DhSectionPos; - import java.util.concurrent.CompletableFuture; /** diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/WorldGenTaskGroup.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/WorldGenTaskGroup.java index aa7178deb..c8130b330 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/WorldGenTaskGroup.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/WorldGenTaskGroup.java @@ -20,7 +20,6 @@ package com.seibel.distanthorizons.core.generation.tasks; import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; -import com.seibel.distanthorizons.core.pos.DhSectionPos; import java.util.Iterator; import java.util.LinkedList; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/ClientLevelModule.java b/core/src/main/java/com/seibel/distanthorizons/core/level/ClientLevelModule.java index d9fd01de1..f474c15d3 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/ClientLevelModule.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/ClientLevelModule.java @@ -29,7 +29,6 @@ import com.seibel.distanthorizons.core.file.fullDatafile.FullDataSourceProviderV import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.logging.f3.F3Screen; import com.seibel.distanthorizons.core.pos.DhBlockPos2D; -import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.render.LodQuadTree; import com.seibel.distanthorizons.core.render.RenderBufferHandler; import com.seibel.distanthorizons.core.render.renderer.LodRenderer; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/DhClientServerLevel.java b/core/src/main/java/com/seibel/distanthorizons/core/level/DhClientServerLevel.java index 6ec5e6713..eadcc1ece 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/DhClientServerLevel.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/DhClientServerLevel.java @@ -28,7 +28,6 @@ import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.pos.DhBlockPos; import com.seibel.distanthorizons.core.pos.DhBlockPos2D; -import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/DhServerLevel.java b/core/src/main/java/com/seibel/distanthorizons/core/level/DhServerLevel.java index ef40c5e89..addb9416e 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/DhServerLevel.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/DhServerLevel.java @@ -23,7 +23,6 @@ import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSour import com.seibel.distanthorizons.core.file.fullDatafile.FullDataSourceProviderV2; import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure; import com.seibel.distanthorizons.core.pos.DhBlockPos2D; -import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/pos/DhSectionPos.java b/core/src/main/java/com/seibel/distanthorizons/core/pos/DhSectionPos.java index ea3044bae..c37fac961 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/pos/DhSectionPos.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/pos/DhSectionPos.java @@ -106,7 +106,7 @@ public class DhSectionPos public static long encodeBlockPos(int blockX, int blockZ) { long pos = encode(LodUtil.BLOCK_DETAIL_LEVEL, blockX, blockZ); - pos = convertToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, pos); + pos = convertToDetailLevel(pos, DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL); return pos; } @@ -114,7 +114,7 @@ public class DhSectionPos public static long encodeChunkPos(int chunkX, int chunkZ) { long pos = encode(LodUtil.CHUNK_DETAIL_LEVEL, chunkX, chunkZ); - pos = convertToDetailLevel(DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL, pos); + pos = convertToDetailLevel(pos, DhSectionPos.SECTION_CHUNK_DETAIL_LEVEL); return pos; } @@ -125,7 +125,7 @@ public class DhSectionPos //============// /** uses the absolute detail level aka detail levels like {@link LodUtil#CHUNK_DETAIL_LEVEL} instead of the dhSectionPos detailLevels. */ - public static long convertToDetailLevel(byte newDetailLevel, long pos) + public static long convertToDetailLevel(long pos, byte newDetailLevel) { byte detailLevel = getDetailLevel(pos); int x = getX(pos); @@ -199,7 +199,7 @@ public class DhSectionPos * * @return how many {@link DhSectionPos}'s at the given detail level it would take to span the width of this section. */ - public static int getWidthCountForLowerDetailedSection(byte returnDetailLevel, long pos) + public static int getWidthCountForLowerDetailedSection(long pos, byte returnDetailLevel) { byte detailLevel = getDetailLevel(pos); @@ -214,9 +214,9 @@ public class DhSectionPos public static DhBlockPos2D getCenterBlockPos(long pos) { return new DhBlockPos2D(getCenterBlockPosX(pos), getCenterBlockPosZ(pos)); } - public static int getCenterBlockPosX(long pos) { return getCenterBlockPosXOrZ(true, pos); } - public static int getCenterBlockPosZ(long pos) { return getCenterBlockPosXOrZ(false, pos); } - private static int getCenterBlockPosXOrZ(boolean returnX, long pos) + public static int getCenterBlockPosX(long pos) { return getCenterBlockPosXOrZ(pos, true); } + public static int getCenterBlockPosZ(long pos) { return getCenterBlockPosXOrZ(pos, false); } + private static int getCenterBlockPosXOrZ(long pos, boolean returnX) { byte detailLevel = getDetailLevel(pos); int x = getX(pos); @@ -241,7 +241,7 @@ public class DhSectionPos return (centerBlockPos * BitShiftUtil.powerOfTwo(detailLevel)) + positionOffset; } - public static int getManhattanBlockDistance(DhBlockPos2D blockPos, long pos) + public static int getManhattanBlockDistance(long pos, DhBlockPos2D blockPos) { return Math.abs(getCenterBlockPosX(pos) - blockPos.x) + Math.abs(getCenterBlockPosZ(pos) - blockPos.z); @@ -264,7 +264,7 @@ public class DhSectionPos * * @param child0to3 must be an int between 0 and 3 */ - public static long getChildByIndex(int child0to3, long pos) throws IllegalArgumentException, IllegalStateException + public static long getChildByIndex(long pos, int child0to3) throws IllegalArgumentException, IllegalStateException { byte detailLevel = getDetailLevel(pos); int x = getX(pos); @@ -290,7 +290,7 @@ public class DhSectionPos - public static long getAdjacentPos(EDhDirection dir, long pos) throws IllegalArgumentException + public static long getAdjacentPos(long pos, EDhDirection dir) throws IllegalArgumentException { if (dir == EDhDirection.UP || dir == EDhDirection.DOWN) { @@ -334,16 +334,16 @@ public class DhSectionPos //===========// /** Applies the given consumer to all 4 of this position's children. */ - public static void forEachChild(LongConsumer callback, long pos) throws IllegalArgumentException, IllegalStateException + public static void forEachChild(long pos, LongConsumer callback) throws IllegalArgumentException, IllegalStateException { for (int i = 0; i < 4; i++) { - callback.accept(getChildByIndex(i, pos)); + callback.accept(getChildByIndex(pos, i)); } } /** Applies the given consumer to all children of the position at the given section detail level. */ - public static void forEachChildDownToDetailLevel(byte minSectionDetailLevel, ICancelablePrimitiveLongConsumer callback, long pos) throws IllegalArgumentException, IllegalStateException + public static void forEachChildDownToDetailLevel(long pos, byte minSectionDetailLevel, ICancelablePrimitiveLongConsumer callback) throws IllegalArgumentException, IllegalStateException { boolean stop = callback.accept(pos); if (stop || minSectionDetailLevel == getDetailLevel(pos)) @@ -353,12 +353,12 @@ public class DhSectionPos for (int i = 0; i < 4; i++) { - forEachChildDownToDetailLevel(minSectionDetailLevel, callback, getChildByIndex(i, pos)); + forEachChildDownToDetailLevel(getChildByIndex(pos, i), minSectionDetailLevel, callback); } } /** Applies the given consumer to all children of the position at the given section detail level. */ - public static void forEachChildAtDetailLevel(byte sectionDetailLevel, LongConsumer callback, long pos) throws IllegalArgumentException, IllegalStateException + public static void forEachChildAtDetailLevel(long pos, byte sectionDetailLevel, LongConsumer callback) throws IllegalArgumentException, IllegalStateException { if (sectionDetailLevel == getDetailLevel(pos)) { @@ -368,12 +368,12 @@ public class DhSectionPos for (int i = 0; i < 4; i++) { - forEachChildAtDetailLevel(sectionDetailLevel, callback, getChildByIndex(i, pos)); + forEachChildAtDetailLevel(getChildByIndex(pos, i), sectionDetailLevel, callback); } } /** Applies the given consumer to all children of the position at the given section detail level. */ - public static void forEachPosUpToDetailLevel(byte maxSectionDetailLevel, LongConsumer callback, long pos) + public static void forEachPosUpToDetailLevel(long pos, byte maxSectionDetailLevel, LongConsumer callback) { callback.accept(pos); if (maxSectionDetailLevel == getDetailLevel(pos)) @@ -381,7 +381,7 @@ public class DhSectionPos return; } - forEachPosUpToDetailLevel(maxSectionDetailLevel, callback, getParentPos(pos)); + forEachPosUpToDetailLevel(getParentPos(pos), maxSectionDetailLevel, callback); } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/LodQuadTree.java b/core/src/main/java/com/seibel/distanthorizons/core/render/LodQuadTree.java index 2da0f1168..731cba4d7 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/LodQuadTree.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/LodQuadTree.java @@ -38,7 +38,6 @@ import com.seibel.distanthorizons.core.util.objects.quadTree.QuadTree; import com.seibel.distanthorizons.coreapi.util.MathUtil; import it.unimi.dsi.fastutil.longs.LongIterator; import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.NotNull; import javax.annotation.WillNotClose; import java.awt.*; @@ -233,8 +232,8 @@ public class LodQuadTree extends QuadTree implements IDebugRen nodesNeedingLoading.sort((a, b) -> { - int aDist = DhSectionPos.getManhattanBlockDistance(playerPos, a.pos); - int bDist = DhSectionPos.getManhattanBlockDistance(playerPos, b.pos); + int aDist = DhSectionPos.getManhattanBlockDistance(a.pos, playerPos); + int bDist = DhSectionPos.getManhattanBlockDistance(b.pos, playerPos); return Integer.compare(aDist, bDist); }); @@ -547,7 +546,7 @@ public class LodQuadTree extends QuadTree implements IDebugRen // and lights may not show up over LOD borders for (EDhDirection direction : EDhDirection.ADJ_DIRECTIONS) { - this.sectionsToReload.add(DhSectionPos.getAdjacentPos(direction, pos)); + this.sectionsToReload.add(DhSectionPos.getAdjacentPos(pos, direction)); } } @@ -567,8 +566,8 @@ public class LodQuadTree extends QuadTree implements IDebugRen // sort the nodes from nearest to farthest nodesNeedingRetrieval.sort((a, b) -> { - int aDist = DhSectionPos.getManhattanBlockDistance(playerPos, a.pos); - int bDist = DhSectionPos.getManhattanBlockDistance(playerPos, b.pos); + int aDist = DhSectionPos.getManhattanBlockDistance(a.pos, playerPos); + int bDist = DhSectionPos.getManhattanBlockDistance(b.pos, playerPos); return Integer.compare(aDist, bDist); }); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/LodRenderSection.java b/core/src/main/java/com/seibel/distanthorizons/core/render/LodRenderSection.java index a95de0e83..fbfd9a2ed 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/LodRenderSection.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/LodRenderSection.java @@ -237,7 +237,7 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable EDhDirection direction = EDhDirection.ADJ_DIRECTIONS[i]; int arrayIndex = direction.ordinal() - 2; - long adjPos = DhSectionPos.getAdjacentPos(direction, this.pos); + long adjPos = DhSectionPos.getAdjacentPos(this.pos, direction); try { LodRenderSection adjRenderSection = this.quadTree.getValue(adjPos); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/FullDataSourceV1DTO.java b/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/FullDataSourceV1DTO.java index 9a8f4f37f..5aaf93546 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/FullDataSourceV1DTO.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/FullDataSourceV1DTO.java @@ -22,7 +22,6 @@ package com.seibel.distanthorizons.core.sql.dto; import com.seibel.distanthorizons.api.enums.config.EDhApiDataCompressionMode; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep; import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV1; -import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataInputStream; import java.io.ByteArrayInputStream; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/FullDataSourceV2DTO.java b/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/FullDataSourceV2DTO.java index 1d8813d1f..62d622fc5 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/FullDataSourceV2DTO.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/FullDataSourceV2DTO.java @@ -24,7 +24,6 @@ import com.seibel.distanthorizons.api.enums.config.EDhApiWorldCompressionMode; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep; import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap; import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; -import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.util.FullDataPointUtil; import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.objects.DataCorruptedException; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/FullDataSourceV1Repo.java b/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/FullDataSourceV1Repo.java index d02cc9a39..0c7c444b7 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/FullDataSourceV1Repo.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/FullDataSourceV1Repo.java @@ -21,7 +21,6 @@ package com.seibel.distanthorizons.core.sql.repo; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep; import com.seibel.distanthorizons.core.pos.DhSectionPos; -import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.sql.dto.FullDataSourceV1DTO; import com.seibel.distanthorizons.coreapi.util.StringUtil; import it.unimi.dsi.fastutil.longs.LongArrayList; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/FullDataSourceV2Repo.java b/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/FullDataSourceV2Repo.java index 2833a6c8d..148db0bcb 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/FullDataSourceV2Repo.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/FullDataSourceV2Repo.java @@ -32,7 +32,6 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.sql.PreparedStatement; import java.sql.SQLException; -import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -64,7 +63,7 @@ public class FullDataSourceV2Repo extends AbstractDhRepo if (!DhSectionPos.contains(this.sectionPos, inputSectionPos)) { LOGGER.error((replaceValue ? "set " : "get ") + inputSectionPos + " center block: " + DhSectionPos.getCenterBlockPos(inputSectionPos) + ", this pos: " + this.sectionPos + " this center block: " + DhSectionPos.getCenterBlockPos(this.sectionPos)); - throw new IllegalArgumentException("Input section pos " + inputSectionPos + " outside of this quadNode's pos: " + this.sectionPos + ", this node's blockPos: " + DhSectionPos.convertToDetailLevel(LodUtil.BLOCK_DETAIL_LEVEL, this.sectionPos) + " block width: " + DhSectionPos.getBlockWidth(this.sectionPos) + " input detail level: " + DhSectionPos.convertToDetailLevel(LodUtil.BLOCK_DETAIL_LEVEL, inputSectionPos) + " width: " + DhSectionPos.getBlockWidth(inputSectionPos)); + throw new IllegalArgumentException("Input section pos " + inputSectionPos + " outside of this quadNode's pos: " + this.sectionPos + ", this node's blockPos: " + DhSectionPos.convertToDetailLevel(this.sectionPos, LodUtil.BLOCK_DETAIL_LEVEL) + " block width: " + DhSectionPos.getBlockWidth(this.sectionPos) + " input detail level: " + DhSectionPos.convertToDetailLevel(inputSectionPos, LodUtil.BLOCK_DETAIL_LEVEL) + " width: " + DhSectionPos.getBlockWidth(inputSectionPos)); } if (DhSectionPos.getDetailLevel(inputSectionPos) > DhSectionPos.getDetailLevel(this.sectionPos)) @@ -218,10 +218,10 @@ public class QuadNode // LOGGER.info((replaceValue ? "set " : "get ")+inputSectionPos+" center block: "+inputSectionPos.getCenter().getCornerBlockPos()+", this pos: "+this.sectionPos+" this center block: "+this.sectionPos.getCenter().getCornerBlockPos()); - long nwPos = DhSectionPos.getChildByIndex(0, this.sectionPos); - long swPos = DhSectionPos.getChildByIndex(1, this.sectionPos); - long nePos = DhSectionPos.getChildByIndex(2, this.sectionPos); - long sePos = DhSectionPos.getChildByIndex(3, this.sectionPos); + long nwPos = DhSectionPos.getChildByIndex(this.sectionPos, 0); + long swPos = DhSectionPos.getChildByIndex(this.sectionPos, 1); + long nePos = DhSectionPos.getChildByIndex(this.sectionPos, 2); + long sePos = DhSectionPos.getChildByIndex(this.sectionPos, 3); // look for the child that contains the input position (there may be a faster way to do this, but this works for now) QuadNode childNode; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/QuadTree.java b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/QuadTree.java index da4723362..8bd84e060 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/QuadTree.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/QuadTree.java @@ -124,12 +124,12 @@ public class QuadTree int radius = this.diameterInBlocks() / 2; DhBlockPos2D minPos = this.getCenterBlockPos().add(new DhBlockPos2D(-radius, -radius)); DhBlockPos2D maxPos = this.getCenterBlockPos().add(new DhBlockPos2D(radius, radius)); - throw new IndexOutOfBoundsException("QuadTree GetOrSet failed. Position out of bounds, min pos: " + minPos + ", max pos: " + maxPos + ", min detail level: " + this.treeMaxDetailLevel + ", max detail level: " + this.treeMinDetailLevel + ". Given Position: [" + DhSectionPos.toString(pos) + "] = block pos: " + DhSectionPos.convertToDetailLevel(LodUtil.BLOCK_DETAIL_LEVEL, pos)); + throw new IndexOutOfBoundsException("QuadTree GetOrSet failed. Position out of bounds, min pos: " + minPos + ", max pos: " + maxPos + ", min detail level: " + this.treeMaxDetailLevel + ", max detail level: " + this.treeMinDetailLevel + ". Given Position: [" + DhSectionPos.toString(pos) + "] = block pos: " + DhSectionPos.convertToDetailLevel(pos, LodUtil.BLOCK_DETAIL_LEVEL)); } - long rootPos = DhSectionPos.convertToDetailLevel(this.treeMinDetailLevel, pos); + long rootPos = DhSectionPos.convertToDetailLevel(pos, this.treeMinDetailLevel); int ringListPosX = DhSectionPos.getX(rootPos); int ringListPosZ = DhSectionPos.getZ(rootPos); @@ -177,7 +177,7 @@ public class QuadTree DhBlockPos2D treeBlockCorner = this.centerBlockPos.add(new DhBlockPos2D(-this.diameterInBlocks / 2, -this.diameterInBlocks / 2)); DhLodPos treeCornerPos = new DhLodPos((byte) 0, treeBlockCorner.x, treeBlockCorner.z); - long inputSectionCorner = DhSectionPos.convertToDetailLevel((byte) 0, testPos); + long inputSectionCorner = DhSectionPos.convertToDetailLevel(testPos, (byte) 0); DhLodPos inputCornerPos = new DhLodPos((byte) 0, DhSectionPos.getX(inputSectionCorner), DhSectionPos.getZ(inputSectionCorner)); int inputBlockWidth = BitShiftUtil.powerOfTwo(DhSectionPos.getDetailLevel(testPos)); @@ -211,7 +211,7 @@ public class QuadTree int childCount = 0; for (int i = 0; i < 4; i++) { - long childPos = DhSectionPos.getChildByIndex(i, pos); + long childPos = DhSectionPos.getChildByIndex(pos, i); if (this.isSectionPosInBounds(childPos)) { T value = this.getValue(childPos); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/iterators/QuadNodeDirectChildPosIterator.java b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/iterators/QuadNodeDirectChildPosIterator.java index 85535846f..f304c0937 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/iterators/QuadNodeDirectChildPosIterator.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/objects/quadTree/iterators/QuadNodeDirectChildPosIterator.java @@ -23,9 +23,7 @@ import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.util.objects.quadTree.QuadNode; import it.unimi.dsi.fastutil.longs.LongIterator; -import java.util.Iterator; import java.util.NoSuchElementException; -import java.util.function.Consumer; import java.util.function.LongConsumer; public class QuadNodeDirectChildPosIterator implements LongIterator @@ -55,7 +53,7 @@ public class QuadNodeDirectChildPosIterator implements LongIterator int childIndex = this.childIndexIterator.next(); - long sectionPos = DhSectionPos.getChildByIndex(childIndex, this.parentNode.sectionPos); + long sectionPos = DhSectionPos.getChildByIndex(this.parentNode.sectionPos, childIndex); return sectionPos; } diff --git a/core/src/test/java/tests/CompressionTest.java b/core/src/test/java/tests/CompressionTest.java index 98b531d3e..d871b58ac 100644 --- a/core/src/test/java/tests/CompressionTest.java +++ b/core/src/test/java/tests/CompressionTest.java @@ -21,7 +21,6 @@ package tests; import com.seibel.distanthorizons.api.enums.config.EDhApiDataCompressionMode; import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; -import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.sql.dto.FullDataSourceV2DTO; import com.seibel.distanthorizons.core.sql.repo.FullDataSourceV2Repo; import it.unimi.dsi.fastutil.longs.LongArrayList; @@ -30,7 +29,6 @@ import org.junit.Assert; import java.io.*; import java.text.CharacterIterator; import java.text.StringCharacterIterator; -import java.util.ArrayList; /** * Note: diff --git a/core/src/test/java/tests/DhSectionPosTest.java b/core/src/test/java/tests/DhSectionPosTest.java index 4bbfdf803..c0585a60e 100644 --- a/core/src/test/java/tests/DhSectionPosTest.java +++ b/core/src/test/java/tests/DhSectionPosTest.java @@ -127,23 +127,23 @@ public class DhSectionPosTest public void parentPosTest() { long leaf = DhSectionPos.encode((byte) 0, 0, 0); - long convert = DhSectionPos.convertToDetailLevel((byte) 1, leaf); + long convert = DhSectionPos.convertToDetailLevel(leaf, (byte) 1); long parent = DhSectionPos.getParentPos(leaf); assertSectionPosEqual("get parent at 0,0 fail", convert, parent); leaf = DhSectionPos.encode((byte) 0, 1, 1); - convert = DhSectionPos.convertToDetailLevel((byte) 1, leaf); + convert = DhSectionPos.convertToDetailLevel(leaf, (byte) 1); parent = DhSectionPos.getParentPos(leaf); assertSectionPosEqual("get parent at 1,1 fail", convert, parent); leaf = DhSectionPos.encode((byte) 1, 2, 2); - convert = DhSectionPos.convertToDetailLevel((byte) 2, leaf); + convert = DhSectionPos.convertToDetailLevel(leaf, (byte) 2); parent = DhSectionPos.getParentPos(leaf); assertSectionPosEqual("parent upscale fail", convert, parent); - convert = DhSectionPos.convertToDetailLevel((byte) 0, leaf); - long childIndex = DhSectionPos.getChildByIndex(0, leaf); + convert = DhSectionPos.convertToDetailLevel(leaf, (byte) 0); + long childIndex = DhSectionPos.getChildByIndex(leaf, 0); assertSectionPosEqual("child detail fail", convert, childIndex); } @@ -152,10 +152,10 @@ public class DhSectionPosTest public void childPosTest() { long node = DhSectionPos.encode((byte) 1, 2302, 0); - long nw = DhSectionPos.getChildByIndex(0, node); - long sw = DhSectionPos.getChildByIndex(1, node); - long ne = DhSectionPos.getChildByIndex(2, node); - long se = DhSectionPos.getChildByIndex(3, node); + long nw = DhSectionPos.getChildByIndex(node, 0); + long sw = DhSectionPos.getChildByIndex(node, 1); + long ne = DhSectionPos.getChildByIndex(node, 2); + long se = DhSectionPos.getChildByIndex(node, 3); // confirm no children have the same values Assert.assertNotEquals(nw, sw); @@ -259,13 +259,13 @@ public class DhSectionPosTest long originSectionPos = DhSectionPos.encode((byte) 0,0,0); - originSectionPos = DhSectionPos.convertToDetailLevel((byte) 1, originSectionPos); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, (byte) 1); assertSectionPosEqual(DhSectionPos.encode((byte) 1, 0, 0), originSectionPos); - originSectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, originSectionPos); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL); assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, 0, 0), originSectionPos); - originSectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, originSectionPos); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, DhSectionPos.SECTION_REGION_DETAIL_LEVEL); assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, 0, 0), originSectionPos); @@ -273,13 +273,13 @@ public class DhSectionPosTest long offsetSectionPos = DhSectionPos.encode((byte) 0,-10000,5000); - offsetSectionPos = DhSectionPos.convertToDetailLevel((byte) 1, offsetSectionPos); + offsetSectionPos = DhSectionPos.convertToDetailLevel(offsetSectionPos, (byte) 1); assertSectionPosEqual(DhSectionPos.encode((byte) 1, -5000, 2500), offsetSectionPos); - offsetSectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, offsetSectionPos); + offsetSectionPos = DhSectionPos.convertToDetailLevel(offsetSectionPos, DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL); assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, -157, 78), offsetSectionPos); - offsetSectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, offsetSectionPos); + offsetSectionPos = DhSectionPos.convertToDetailLevel(offsetSectionPos, DhSectionPos.SECTION_REGION_DETAIL_LEVEL); assertSectionPosEqual(DhSectionPos.encode(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, -1, 0), offsetSectionPos); } @@ -294,38 +294,38 @@ public class DhSectionPosTest // 1 -> 0 byte returnDetailLevel = 0; - originSectionPos = DhSectionPos.convertToDetailLevel((byte) 1, originSectionPos); - assertSectionPosEqual(2, DhSectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel, originSectionPos)); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, (byte) 1); + assertSectionPosEqual(2, DhSectionPos.getWidthCountForLowerDetailedSection(originSectionPos, returnDetailLevel)); - sectionPos = DhSectionPos.convertToDetailLevel((byte) 1, sectionPos); - assertSectionPosEqual(2, DhSectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel, sectionPos)); + sectionPos = DhSectionPos.convertToDetailLevel(sectionPos, (byte) 1); + assertSectionPosEqual(2, DhSectionPos.getWidthCountForLowerDetailedSection(sectionPos, returnDetailLevel)); // 2 -> 1 returnDetailLevel = 1; - originSectionPos = DhSectionPos.convertToDetailLevel((byte) 2, originSectionPos); - assertSectionPosEqual(2, DhSectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel, originSectionPos)); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, (byte) 2); + assertSectionPosEqual(2, DhSectionPos.getWidthCountForLowerDetailedSection(originSectionPos, returnDetailLevel)); - sectionPos = DhSectionPos.convertToDetailLevel((byte) 2, sectionPos); - assertSectionPosEqual(2, DhSectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel, sectionPos)); + sectionPos = DhSectionPos.convertToDetailLevel(sectionPos, (byte) 2); + assertSectionPosEqual(2, DhSectionPos.getWidthCountForLowerDetailedSection(sectionPos, returnDetailLevel)); // Block -> 0 returnDetailLevel = 0; - originSectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, originSectionPos); - assertSectionPosEqual(64, DhSectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel, originSectionPos)); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL); + assertSectionPosEqual(64, DhSectionPos.getWidthCountForLowerDetailedSection(originSectionPos, returnDetailLevel)); - sectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, sectionPos); - assertSectionPosEqual(64, DhSectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel, sectionPos)); + sectionPos = DhSectionPos.convertToDetailLevel(sectionPos, DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL); + assertSectionPosEqual(64, DhSectionPos.getWidthCountForLowerDetailedSection(sectionPos, returnDetailLevel)); // Region -> 3 returnDetailLevel = 3; - originSectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, originSectionPos); - assertSectionPosEqual(4096, DhSectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel, originSectionPos)); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, DhSectionPos.SECTION_REGION_DETAIL_LEVEL); + assertSectionPosEqual(4096, DhSectionPos.getWidthCountForLowerDetailedSection(originSectionPos, returnDetailLevel)); - sectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, sectionPos); - assertSectionPosEqual(4096, DhSectionPos.getWidthCountForLowerDetailedSection(returnDetailLevel, sectionPos)); + sectionPos = DhSectionPos.convertToDetailLevel(sectionPos, DhSectionPos.SECTION_REGION_DETAIL_LEVEL); + assertSectionPosEqual(4096, DhSectionPos.getWidthCountForLowerDetailedSection(sectionPos, returnDetailLevel)); } @@ -339,19 +339,19 @@ public class DhSectionPosTest assertSectionPosEqual(1, DhSectionPos.getBlockWidth(originSectionPos)); assertSectionPosEqual(1, DhSectionPos.getBlockWidth(sectionPos)); - originSectionPos = DhSectionPos.convertToDetailLevel((byte) 1, originSectionPos); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, (byte) 1); assertSectionPosEqual(2, DhSectionPos.getBlockWidth(originSectionPos)); - sectionPos = DhSectionPos.convertToDetailLevel((byte) 1, sectionPos); + sectionPos = DhSectionPos.convertToDetailLevel(sectionPos, (byte) 1); assertSectionPosEqual(2, DhSectionPos.getBlockWidth(sectionPos)); - originSectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, originSectionPos); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL); assertSectionPosEqual(64, DhSectionPos.getBlockWidth(originSectionPos)); - sectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, sectionPos); + sectionPos = DhSectionPos.convertToDetailLevel(sectionPos, DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL); assertSectionPosEqual(64, DhSectionPos.getBlockWidth(sectionPos)); - originSectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, originSectionPos); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, DhSectionPos.SECTION_REGION_DETAIL_LEVEL); assertSectionPosEqual(32768, DhSectionPos.getBlockWidth(originSectionPos)); - sectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, sectionPos); + sectionPos = DhSectionPos.convertToDetailLevel(sectionPos, DhSectionPos.SECTION_REGION_DETAIL_LEVEL); assertSectionPosEqual(32768, DhSectionPos.getBlockWidth(sectionPos)); } @@ -370,32 +370,32 @@ public class DhSectionPosTest // 2x2 blocks - originSectionPos = DhSectionPos.convertToDetailLevel((byte) 1, originSectionPos); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, (byte) 1); Assert.assertEquals(new DhBlockPos2D(0, 0), DhSectionPos.getCenterBlockPos(originSectionPos)); - sectionPos = DhSectionPos.convertToDetailLevel((byte) 1, sectionPos); + sectionPos = DhSectionPos.convertToDetailLevel(sectionPos, (byte) 1); Assert.assertEquals(new DhBlockPos2D(-10000, 5000), DhSectionPos.getCenterBlockPos(sectionPos)); //sectionPos = DhSectionPos.encode((byte) 1, 2303, 0); //Assert.assertEquals(new DhBlockPos2D(4606, 0), DhSectionPos.getCenterBlockPos(sectionPos)); // 4x4 blocks - originSectionPos = DhSectionPos.convertToDetailLevel((byte) 2, originSectionPos); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, (byte) 2); Assert.assertEquals(new DhBlockPos2D(2, 2), DhSectionPos.getCenterBlockPos(originSectionPos)); - sectionPos = DhSectionPos.convertToDetailLevel((byte) 2, sectionPos); + sectionPos = DhSectionPos.convertToDetailLevel(sectionPos, (byte) 2); Assert.assertEquals(new DhBlockPos2D(-9998, 5002), DhSectionPos.getCenterBlockPos(sectionPos)); // 64x64 blocks - originSectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, originSectionPos); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL); Assert.assertEquals(new DhBlockPos2D(32, 32), DhSectionPos.getCenterBlockPos(originSectionPos)); - sectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, sectionPos); + sectionPos = DhSectionPos.convertToDetailLevel(sectionPos, DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL); Assert.assertEquals(new DhBlockPos2D(-10016, 5024), DhSectionPos.getCenterBlockPos(sectionPos)); // 32,768 x 32,768 blocks - originSectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, originSectionPos); + originSectionPos = DhSectionPos.convertToDetailLevel(originSectionPos, DhSectionPos.SECTION_REGION_DETAIL_LEVEL); Assert.assertEquals(new DhBlockPos2D(16384, 16384), DhSectionPos.getCenterBlockPos(originSectionPos)); - sectionPos = DhSectionPos.convertToDetailLevel(DhSectionPos.SECTION_REGION_DETAIL_LEVEL, sectionPos); + sectionPos = DhSectionPos.convertToDetailLevel(sectionPos, DhSectionPos.SECTION_REGION_DETAIL_LEVEL); Assert.assertEquals(new DhBlockPos2D(-16384, 16384), DhSectionPos.getCenterBlockPos(sectionPos)); } @@ -439,15 +439,15 @@ public class DhSectionPosTest { long pos = DhSectionPos.encode((byte) 0, 0, 0); - assertSectionPosEqual(DhSectionPos.encode((byte) 0, 0, -1), DhSectionPos.getAdjacentPos(EDhDirection.NORTH, pos)); - assertSectionPosEqual(DhSectionPos.encode((byte) 0, 0, 1), DhSectionPos.getAdjacentPos(EDhDirection.SOUTH, pos)); + assertSectionPosEqual(DhSectionPos.encode((byte) 0, 0, -1), DhSectionPos.getAdjacentPos(pos, EDhDirection.NORTH)); + assertSectionPosEqual(DhSectionPos.encode((byte) 0, 0, 1), DhSectionPos.getAdjacentPos(pos, EDhDirection.SOUTH)); - assertSectionPosEqual(DhSectionPos.encode((byte) 0, 1, 0), DhSectionPos.getAdjacentPos(EDhDirection.EAST, pos)); - assertSectionPosEqual(DhSectionPos.encode((byte) 0, -1, 0), DhSectionPos.getAdjacentPos(EDhDirection.WEST, pos)); + assertSectionPosEqual(DhSectionPos.encode((byte) 0, 1, 0), DhSectionPos.getAdjacentPos(pos, EDhDirection.EAST)); + assertSectionPosEqual(DhSectionPos.encode((byte) 0, -1, 0), DhSectionPos.getAdjacentPos(pos, EDhDirection.WEST)); // getting the adjacent position in the up and down position don't make sense - Assert.assertThrows(IllegalArgumentException.class, () -> { DhSectionPos.getAdjacentPos(EDhDirection.UP, pos); }); - Assert.assertThrows(IllegalArgumentException.class, () -> { DhSectionPos.getAdjacentPos(EDhDirection.DOWN, pos); }); + Assert.assertThrows(IllegalArgumentException.class, () -> { DhSectionPos.getAdjacentPos(pos, EDhDirection.UP); }); + Assert.assertThrows(IllegalArgumentException.class, () -> { DhSectionPos.getAdjacentPos(pos, EDhDirection.DOWN); }); } @Test @@ -457,11 +457,11 @@ public class DhSectionPosTest ArrayList childPosList = new ArrayList<>(); AtomicInteger childCount = new AtomicInteger(0); - DhSectionPos.forEachChild((childPos) -> + DhSectionPos.forEachChild(pos, (childPos) -> { childCount.incrementAndGet(); childPosList.add(childPos); - }, pos); + }); Assert.assertTrue(childPosList.contains(DhSectionPos.encode((byte) 0, 0, 0))); Assert.assertTrue(childPosList.contains(DhSectionPos.encode((byte) 0, 1, 0))); diff --git a/core/src/test/java/tests/QuadTreeTest.java b/core/src/test/java/tests/QuadTreeTest.java index e731cca49..28cbfabb0 100644 --- a/core/src/test/java/tests/QuadTreeTest.java +++ b/core/src/test/java/tests/QuadTreeTest.java @@ -692,7 +692,7 @@ public class QuadTreeTest for (int i = 0; i < 4; i++) { - long childPos = DhSectionPos.getChildByIndex(i, rootNode.sectionPos); + long childPos = DhSectionPos.getChildByIndex(rootNode.sectionPos, i); QuadNode childNode = rootNode.getChildByIndex(i); Assert.assertEquals("child position not the same as " + long.class.getSimpleName() + "'s getChildByIndex()", childPos, childNode.sectionPos); }