From e5e502b4f8fe3161c06c690390335275214e237c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 15 Nov 2025 19:09:16 -0600 Subject: [PATCH] Remove unused/broken FullData LevelMinY --- .../events/IDhApiEventInjector.java | 1 + .../api/objects/data/DhApiChunk.java | 23 ++-------- .../objects/data/DhApiTerrainDataPoint.java | 42 +++++-------------- .../methods/data/DhApiTerrainDataRepo.java | 27 ++++++++---- .../core/api/internal/ClientApi.java | 1 + .../fullData/sources/FullDataSourceV2.java | 15 +++---- .../core/pos/DhSectionPos.java | 2 + .../core/sql/dto/FullDataSourceV2DTO.java | 6 --- .../core/sql/repo/FullDataSourceV2Repo.java | 27 ++++-------- .../core/util/DhApiTerrainDataPointUtil.java | 2 - 10 files changed, 52 insertions(+), 94 deletions(-) diff --git a/api/src/main/java/com/seibel/distanthorizons/api/interfaces/events/IDhApiEventInjector.java b/api/src/main/java/com/seibel/distanthorizons/api/interfaces/events/IDhApiEventInjector.java index 0f2a4d062..ba9bdb336 100644 --- a/api/src/main/java/com/seibel/distanthorizons/api/interfaces/events/IDhApiEventInjector.java +++ b/api/src/main/java/com/seibel/distanthorizons/api/interfaces/events/IDhApiEventInjector.java @@ -41,6 +41,7 @@ public interface IDhApiEventInjector extends IDependencyInjector * @throws IllegalArgumentException if the implementation object doesn't implement the interface */ // Note to self: Don't try adding a generic type to IDhApiEvent, the constructor won't accept it + // TODO why are we removing the class instead of an instance? boolean unbind(Class dependencyInterface, Class dependencyClassToRemove) throws IllegalArgumentException; diff --git a/api/src/main/java/com/seibel/distanthorizons/api/objects/data/DhApiChunk.java b/api/src/main/java/com/seibel/distanthorizons/api/objects/data/DhApiChunk.java index ce901d7f8..080cb6691 100644 --- a/api/src/main/java/com/seibel/distanthorizons/api/objects/data/DhApiChunk.java +++ b/api/src/main/java/com/seibel/distanthorizons/api/objects/data/DhApiChunk.java @@ -54,27 +54,12 @@ public class DhApiChunk // constructors // //==============// - /** - * Deprecated due to the topYBlockPos and bottomYBlockPos variables being put in the wrong order. - * They should have been in bottom -> top order. - * - * @see DhApiChunk#create(int, int, int, int) - */ - @Deprecated - public DhApiChunk(int chunkPosX, int chunkPosZ, int topYBlockPos, int bottomYBlockPos) - { this(chunkPosX, chunkPosZ, bottomYBlockPos, topYBlockPos, false); } - - /** - * @since API 3.0.0 - */ + /** @since API 3.0.0 */ public static DhApiChunk create(int chunkPosX, int chunkPosZ, int bottomYBlockPos, int topYBlockPos) - { return new DhApiChunk(chunkPosX, chunkPosZ, bottomYBlockPos, topYBlockPos, false); } + { return new DhApiChunk(chunkPosX, chunkPosZ, bottomYBlockPos, topYBlockPos); } - /** - * Only visible to internal DH methods - * @param ignoredParameter is only present to differentiate the two constructors and isn't actually used - */ - private DhApiChunk(int chunkPosX, int chunkPosZ, int bottomYBlockPos, int topYBlockPos, boolean ignoredParameter) + /** Only visible to internal DH methods */ + private DhApiChunk(int chunkPosX, int chunkPosZ, int bottomYBlockPos, int topYBlockPos) { this.chunkPosX = chunkPosX; this.chunkPosZ = chunkPosZ; diff --git a/api/src/main/java/com/seibel/distanthorizons/api/objects/data/DhApiTerrainDataPoint.java b/api/src/main/java/com/seibel/distanthorizons/api/objects/data/DhApiTerrainDataPoint.java index 85e42be95..341fe3e7c 100644 --- a/api/src/main/java/com/seibel/distanthorizons/api/objects/data/DhApiTerrainDataPoint.java +++ b/api/src/main/java/com/seibel/distanthorizons/api/objects/data/DhApiTerrainDataPoint.java @@ -29,7 +29,7 @@ import java.util.ArrayList; * Holds a single datapoint of terrain data. * * @author James Seibel - * @version 2024-7-20 + * @version 2025-11-15 * @since API 1.0.0 */ public class DhApiTerrainDataPoint @@ -47,6 +47,10 @@ public class DhApiTerrainDataPoint public final int blockLightLevel; public final int skyLightLevel; + /** + * An unsigned block position of the bottom vertex for this LOD relative to the level's minimum height. + * Should be greater than or equal to 0. + */ public final int bottomYBlockPos; public final int topYBlockPos; @@ -59,28 +63,7 @@ public class DhApiTerrainDataPoint // constructors // //==============// - /** - * Deprecated due to the topYBlockPos and bottomYBlockPos variables being put in the wrong order. - * They should have been in bottom -> top order. - * - * @see DhApiTerrainDataPoint#create(byte, int, int, int, int, IDhApiBlockStateWrapper, IDhApiBiomeWrapper) - */ - @Deprecated - public DhApiTerrainDataPoint( - byte detailLevel, - int blockLightLevel, int skyLightLevel, - int topYBlockPos, int bottomYBlockPos, - IDhApiBlockStateWrapper blockStateWrapper, IDhApiBiomeWrapper biomeWrapper) - { - this(detailLevel, blockLightLevel, skyLightLevel, - bottomYBlockPos, topYBlockPos, - blockStateWrapper, biomeWrapper, - false); - } - - /** - * @since API 3.0.0 - */ + /** @since API 3.0.0 */ public static DhApiTerrainDataPoint create( byte detailLevel, int blockLightLevel, int skyLightLevel, @@ -91,20 +74,15 @@ public class DhApiTerrainDataPoint return new DhApiTerrainDataPoint( detailLevel, blockLightLevel, skyLightLevel, bottomYBlockPos, topYBlockPos, - blockStateWrapper, biomeWrapper, - false); + blockStateWrapper, biomeWrapper); } - /** - * Only visible to internal DH methods - * @param ignoredParameter is only present to differentiate the two constructors and isn't actually used - */ + /** Only visible to internal DH methods */ private DhApiTerrainDataPoint( byte detailLevel, int blockLightLevel, int skyLightLevel, int bottomYBlockPos, int topYBlockPos, - IDhApiBlockStateWrapper blockStateWrapper, IDhApiBiomeWrapper biomeWrapper, - boolean ignoredParameter + IDhApiBlockStateWrapper blockStateWrapper, IDhApiBiomeWrapper biomeWrapper ) { this.detailLevel = detailLevel; @@ -118,4 +96,6 @@ public class DhApiTerrainDataPoint this.biomeWrapper = biomeWrapper; } + + } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/data/DhApiTerrainDataRepo.java b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/data/DhApiTerrainDataRepo.java index c27b8a58e..0dea74d8c 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/data/DhApiTerrainDataRepo.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/data/DhApiTerrainDataRepo.java @@ -277,7 +277,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo if (!getSpecificYCoordinate) { // if we aren't look for a specific datapoint, add each datapoint to the return array - returnArray[i] = DhApiTerrainDataPointUtil.createApiDatapoint(levelWrapper, mapping, requestedDetailLevel, dataPoint); + returnArray[i] = DhApiTerrainDataPointUtil.createApiDatapoint(levelWrapper.getMinHeight(), mapping, requestedDetailLevel, dataPoint); } else { @@ -294,7 +294,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo if (bottomY <= requestedY && requestedY < topY) // blockPositions start from the bottom of the block, thus "<=" for bottomY, just "<" for topY { // this datapoint contains the requested block position, return it - DhApiTerrainDataPoint apiTerrainData = DhApiTerrainDataPointUtil.createApiDatapoint(levelWrapper, mapping, requestedDetailLevel, dataPoint); + DhApiTerrainDataPoint apiTerrainData = DhApiTerrainDataPointUtil.createApiDatapoint(levelWrapper.getMinHeight(), mapping, requestedDetailLevel, dataPoint); return DhApiResult.createSuccess(new DhApiTerrainDataPoint[]{apiTerrainData}); } } @@ -345,7 +345,10 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo @Nullable IDhApiTerrainDataCache dataCache) { - return this.raycastLodData(levelWrapper, new Vec3d(rayOriginX, rayOriginY, rayOriginZ), new Vec3f(rayDirectionX, rayDirectionY, rayDirectionZ), maxRayBlockLength, dataCache); + return this.raycastLodData(levelWrapper, + new Vec3d(rayOriginX, rayOriginY, rayOriginZ), + new Vec3f(rayDirectionX, rayDirectionY, rayDirectionZ), + maxRayBlockLength, dataCache); } /** @@ -363,8 +366,8 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo { rayDirection.normalize(); - int minBlockHeight = levelWrapper.getMinHeight(); - int maxBlockHeight = levelWrapper.getMaxHeight(); + int minLevelBlockHeight = levelWrapper.getMinHeight(); + int maxLevelBlockHeight = levelWrapper.getMaxHeight(); @@ -380,7 +383,8 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo DhApiRaycastResult closetFoundDataPoint = null; - while (blockPos.y >= minBlockHeight && blockPos.y < maxBlockHeight + while (blockPos.y >= minLevelBlockHeight + && blockPos.y < maxLevelBlockHeight && currentLength <= maxRayBlockLength) { // get the LOD columns around this position @@ -403,7 +407,8 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo { // does this LOD contain the given Y position? Vec3i dataPointPos = new Vec3i(columnPos.x, dataPoint.bottomYBlockPos, columnPos.z); - if (exactPos.y >= dataPoint.bottomYBlockPos && exactPos.y <= dataPoint.topYBlockPos) + if (exactPos.y >= dataPoint.bottomYBlockPos + && exactPos.y <= dataPoint.topYBlockPos) { if (closetFoundDataPoint == null) { @@ -572,12 +577,16 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo } // draw raycast position - if (rayCast.success && rayCast.payload != null) + if (rayCast.success + && rayCast.payload != null) { DebugRenderer.makeParticle( new DebugRenderer.BoxParticle( new DebugRenderer.Box( - DhSectionPos.encode((byte) 0, rayCast.payload.pos.x, rayCast.payload.pos.z), rayCast.payload.dataPoint.bottomYBlockPos, rayCast.payload.dataPoint.topYBlockPos, -0.1f, Color.RED), + DhSectionPos.encode((byte) 0, rayCast.payload.pos.x, rayCast.payload.pos.z), + rayCast.payload.dataPoint.bottomYBlockPos, + rayCast.payload.dataPoint.topYBlockPos, + -0.1f, Color.RED), 1.0, 0f ) ); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java index 064c3672b..792318a84 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java @@ -23,6 +23,7 @@ import com.seibel.distanthorizons.api.DhApi; import com.seibel.distanthorizons.api.enums.config.EDhApiMcRenderingFadeMode; import com.seibel.distanthorizons.api.enums.rendering.EDhApiRenderPass; import com.seibel.distanthorizons.api.methods.events.abstractEvents.*; +import com.seibel.distanthorizons.core.api.external.methods.data.DhApiTerrainDataRepo; import com.seibel.distanthorizons.core.api.internal.rendering.DhRenderState; import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; 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 b092cff17..6e4ee8a51 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 @@ -92,8 +92,6 @@ public class FullDataSourceV2 public long lastModifiedUnixDateTime; public long createdUnixDateTime; - public int levelMinY; - /** * stores how far each column has been generated should start with {@link EDhApiWorldGenerationStep#EMPTY} * @@ -299,9 +297,9 @@ public class FullDataSourceV2 * returns {@link FullDataPointUtil#EMPTY_DATA_POINT} if the given {@link DhBlockPos} * is outside this data source's boundaries. */ - public long getDataPointAtBlockPos(DhBlockPos blockPos) + public long getDataPointAtBlockPos(int blockPosX, int relBlockPosY, int blockPosZ) { - DhLodPos requestedPos = new DhLodPos(LodUtil.BLOCK_DETAIL_LEVEL, blockPos.getX(), blockPos.getZ()); + DhLodPos requestedPos = new DhLodPos(LodUtil.BLOCK_DETAIL_LEVEL, blockPosX, blockPosZ); // stop if the requested blockPos is outside this datasource { @@ -345,14 +343,13 @@ public class FullDataSourceV2 - int requestedY = blockPos.getY(); - int bottomY = FullDataPointUtil.getBottomY(dataPoint) + this.levelMinY; + int bottomY = FullDataPointUtil.getBottomY(dataPoint); int height = FullDataPointUtil.getHeight(dataPoint); int topY = bottomY + height; // does this datapoint contain the requested Y position? - if (bottomY <= requestedY - && requestedY < topY) // blockPositions start from the bottom of the block, thus "<=" for bottomY, just "<" for topY + if (bottomY <= relBlockPosY + && relBlockPosY < topY) // blockPositions start from the bottom of the block, thus "<=" for bottomY, just "<" for topY { return dataPoint; } @@ -1300,7 +1297,7 @@ public class FullDataSourceV2 { long datapoint = dataColumn.getLong(i); - DhApiTerrainDataPoint apiDataPoint = DhApiTerrainDataPointUtil.createApiDatapoint(this.levelMinY, this.mapping, DhSectionPos.getDetailLevel(this.pos), datapoint); + DhApiTerrainDataPoint apiDataPoint = DhApiTerrainDataPointUtil.createApiDatapoint(0, this.mapping, DhSectionPos.getDetailLevel(this.pos), datapoint); apiList.add(apiDataPoint); } 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 7b0315396..31153e7c1 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 @@ -42,6 +42,8 @@ import java.util.function.LongConsumer; * Too big, and the LOD dropoff will be very noticeable.
* With those thoughts in mind we decided on a smallest section size of 64 data points square (IE 4x4 chunks). * + * TODO absolute vs section detail levels + * * @author Leetom */ public class DhSectionPos 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 2efacefbf..6b72ede48 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 @@ -65,8 +65,6 @@ public class FullDataSourceV2DTO public long pos; - public int levelMinY; - /** only for the data array */ public int dataChecksum; @@ -132,7 +130,6 @@ public class FullDataSourceV2DTO dto.createdUnixDateTime = dataSource.createdUnixDateTime; dto.applyToParent = dataSource.applyToParent; dto.applyToChildren = dataSource.applyToChildren; - dto.levelMinY = dataSource.levelMinY; } return dto; @@ -296,8 +293,6 @@ public class FullDataSourceV2DTO dataSource.lastModifiedUnixDateTime = this.lastModifiedUnixDateTime; dataSource.createdUnixDateTime = this.createdUnixDateTime; - dataSource.levelMinY = this.levelMinY; - dataSource.isEmpty = false; if (this.applyToParent != null) @@ -868,7 +863,6 @@ public class FullDataSourceV2DTO public String toString() { return MoreObjects.toStringHelper(this) - .add("levelMinY", this.levelMinY) .add("pos", DhSectionPos.toString(this.pos)) .add("dataChecksum", this.dataChecksum) .add("compressedDataByteArray length", this.compressedDataByteArray.size()) 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 f16bbadce..b8af16e75 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 @@ -98,7 +98,6 @@ public class FullDataSourceV2Repo extends AbstractDhRepo