From 9834b20a9fda0ff4444ca46b6b413961948cee81 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 28 Jul 2024 08:56:18 -0500 Subject: [PATCH] Revert and Deprecate DhApiChunk and DhApiTerrainDataPoint constructors --- .../api/objects/data/DhApiChunk.java | 22 ++++++- .../objects/data/DhApiTerrainDataPoint.java | 57 ++++++++++++++++++- .../methods/data/DhApiTerrainDataRepo.java | 5 +- 3 files changed, 80 insertions(+), 4 deletions(-) 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 8bbed6ded..70535e5e8 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 @@ -52,7 +52,27 @@ public class DhApiChunk // constructors // //==============// - public DhApiChunk(int chunkPosX, int chunkPosZ, int bottomYBlockPos, int topYBlockPos) + /** + * 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 + */ + public static DhApiChunk create(int chunkPosX, int chunkPosZ, int bottomYBlockPos, int topYBlockPos) + { return new DhApiChunk(chunkPosX, chunkPosZ, topYBlockPos, bottomYBlockPos, false); } + + /** + * 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) { 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 ab2cb9f01..caae71320 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 @@ -19,9 +19,12 @@ package com.seibel.distanthorizons.api.objects.data; +import com.seibel.distanthorizons.api.enums.EDhApiDetailLevel; import com.seibel.distanthorizons.api.interfaces.block.IDhApiBiomeWrapper; import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper; +import java.util.ArrayList; + /** * Holds a single datapoint of terrain data. * @@ -37,6 +40,8 @@ public class DhApiTerrainDataPoint * 2 = 4x4 blocks
* 4 = chunk (16x16 blocks)
* 9 = region (512x512 blocks)
+ * + * @see EDhApiDetailLevel */ public final byte detailLevel; @@ -50,7 +55,57 @@ public class DhApiTerrainDataPoint - public DhApiTerrainDataPoint(byte detailLevel, int blockLightLevel, int skyLightLevel, int bottomYBlockPos, int topYBlockPos, IDhApiBlockStateWrapper blockStateWrapper, IDhApiBiomeWrapper biomeWrapper) + //==============// + // 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 + */ + public static DhApiTerrainDataPoint create( + byte detailLevel, + int blockLightLevel, int skyLightLevel, + int bottomYBlockPos, int topYBlockPos, + IDhApiBlockStateWrapper blockStateWrapper, IDhApiBiomeWrapper biomeWrapper + ) + { + return new DhApiTerrainDataPoint( + detailLevel, blockLightLevel, skyLightLevel, + bottomYBlockPos, topYBlockPos, + blockStateWrapper, biomeWrapper, + false); + } + + /** + * Only visible to internal DH methods + * @param ignoredParameter is only present to differentiate the two constructors and isn't actually used + */ + private DhApiTerrainDataPoint( + byte detailLevel, + int blockLightLevel, int skyLightLevel, + int bottomYBlockPos, int topYBlockPos, + IDhApiBlockStateWrapper blockStateWrapper, IDhApiBiomeWrapper biomeWrapper, + boolean ignoredParameter + ) { this.detailLevel = detailLevel; 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 cf7d337c0..1d4f3331f 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 @@ -326,9 +326,10 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo int height = FullDataPointUtil.getHeight(dataPoint); int topY = bottomY + height; - return new DhApiTerrainDataPoint(detailLevel, + return DhApiTerrainDataPoint.create( + detailLevel, FullDataPointUtil.getBlockLight(dataPoint), FullDataPointUtil.getSkyLight(dataPoint), - topY, bottomY, + bottomY, topY, blockState, biomeWrapper); }