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 913588b4d..ce7ef834a 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 @@ -27,12 +27,12 @@ import com.seibel.distanthorizons.api.interfaces.data.IDhApiTerrainDataRepo; import com.seibel.distanthorizons.api.objects.math.DhApiVec3i; import com.seibel.distanthorizons.core.api.internal.SharedApi; import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.level.IDhLevel; import com.seibel.distanthorizons.core.pos.DhLodPos; import com.seibel.distanthorizons.core.pos.DhSectionPos; -import com.seibel.distanthorizons.core.util.FullDataPointUtil; +import com.seibel.distanthorizons.core.util.FullDataPointUtilV2; import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.RayCastUtil; import com.seibel.distanthorizons.core.world.AbstractDhWorld; @@ -211,7 +211,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo try { // attempt to get/generate the data source for this section - NewFullDataSource dataSource = level.getFullDataProvider().getAsync(sectionPos).get(); + FullDataSourceV2 dataSource = level.getFullDataProvider().getAsync(sectionPos).get(); if (dataSource == null) { return DhApiResult.createFail("Unable to find/generate any data at the " + DhSectionPos.class.getSimpleName() + " [" + sectionPos + "]."); @@ -248,8 +248,8 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo if (dataPoint != 0) { int requestedY = nullableBlockYPos; - int bottomY = FullDataPointUtil.getBottomY(dataPoint) + levelMinimumHeight; - int height = FullDataPointUtil.getHeight(dataPoint); + int bottomY = FullDataPointUtilV2.getBottomY(dataPoint) + levelMinimumHeight; + int height = FullDataPointUtilV2.getHeight(dataPoint); int topY = bottomY + height; // does this datapoint contain the requested Y position? @@ -281,15 +281,15 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo private static DhApiTerrainDataPoint generateApiDatapoint(IDhApiLevelWrapper levelWrapper, FullDataPointIdMap mapping, byte detailLevel, long dataPoint) { - IBlockStateWrapper blockState = mapping.getBlockStateWrapper(FullDataPointUtil.getId(dataPoint)); - IBiomeWrapper biomeWrapper = mapping.getBiomeWrapper(FullDataPointUtil.getId(dataPoint)); + IBlockStateWrapper blockState = mapping.getBlockStateWrapper(FullDataPointUtilV2.getId(dataPoint)); + IBiomeWrapper biomeWrapper = mapping.getBiomeWrapper(FullDataPointUtilV2.getId(dataPoint)); - int bottomY = FullDataPointUtil.getBottomY(dataPoint) + levelWrapper.getMinHeight(); - int height = FullDataPointUtil.getHeight(dataPoint); + int bottomY = FullDataPointUtilV2.getBottomY(dataPoint) + levelWrapper.getMinHeight(); + int height = FullDataPointUtilV2.getHeight(dataPoint); int topY = bottomY + height; return new DhApiTerrainDataPoint(detailLevel, - FullDataPointUtil.getBlockLight(dataPoint), FullDataPointUtil.getSkyLight(dataPoint), + FullDataPointUtilV2.getBlockLight(dataPoint), FullDataPointUtilV2.getSkyLight(dataPoint), topY, bottomY, blockState, biomeWrapper); } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV1.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV1.java index f15ae49a6..9a6f4c0e5 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV1.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV1.java @@ -39,9 +39,12 @@ import java.util.Arrays; /** * Formerly "CompleteFullDataSource".
- * Should be fully populated, containing 1 data point for each column. - * + * Should be fully populated, containing 1 data point for each column.

+ * + * Replaced by {@link FullDataSourceV2}. + * * @see FullDataPointUtilV1 + * @see FullDataSourceV2 */ public class FullDataSourceV1 implements IDataSource { @@ -98,7 +101,7 @@ public class FullDataSourceV1 implements IDataSource @Deprecated @Override - public boolean update(NewFullDataSource dataSource, IDhLevel level) { throw new UnsupportedOperationException("Deprecated"); } + public boolean update(FullDataSourceV2 dataSource, IDhLevel level) { throw new UnsupportedOperationException("Deprecated"); } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/NewFullDataSource.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java similarity index 89% rename from core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/NewFullDataSource.java rename to core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java index 4227ed3d1..c0d311889 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/NewFullDataSource.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java @@ -23,11 +23,11 @@ import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGeneratio import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap; import com.seibel.distanthorizons.core.dataObjects.transformers.LodDataBuilder; import com.seibel.distanthorizons.core.file.IDataSource; -import com.seibel.distanthorizons.core.file.fullDatafile.NewFullDataFileHandler; +import com.seibel.distanthorizons.core.file.fullDatafile.FullDataFileHandlerV2; import com.seibel.distanthorizons.core.level.IDhLevel; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.pos.DhSectionPos; -import com.seibel.distanthorizons.core.util.FullDataPointUtil; +import com.seibel.distanthorizons.core.util.FullDataPointUtilV2; import com.seibel.distanthorizons.core.util.FullDataPointUtilV1; import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.util.RenderDataPointUtil; @@ -47,10 +47,10 @@ import java.util.concurrent.locks.ReentrantLock; * TODO create a child object that extends AutoClosable * that can be pooled to reduce GC overhead * - * @see FullDataPointUtil + * @see FullDataPointUtilV2 * @see FullDataSourceV1 */ -public class NewFullDataSource implements IDataSource +public class FullDataSourceV2 implements IDataSource { private static final Logger LOGGER = DhLoggerBuilder.getLogger(); /** useful for debugging, but can slow down update operations quite a bit due to being called so often. */ @@ -100,8 +100,8 @@ public class NewFullDataSource implements IDataSource // constructors // //==============// - public static NewFullDataSource createEmpty(DhSectionPos pos) { return new NewFullDataSource(pos); } - private NewFullDataSource(DhSectionPos pos) + public static FullDataSourceV2 createEmpty(DhSectionPos pos) { return new FullDataSourceV2(pos); } + private FullDataSourceV2(DhSectionPos pos) { this.pos = pos; this.dataPoints = new long[WIDTH * WIDTH][]; @@ -113,8 +113,8 @@ public class NewFullDataSource implements IDataSource this.columnGenerationSteps = new byte[WIDTH * WIDTH]; } - public static NewFullDataSource createWithData(DhSectionPos pos, FullDataPointIdMap mapping, long[][] data, byte[] columnGenerationStep) { return new NewFullDataSource(pos, mapping, data, columnGenerationStep); } - private NewFullDataSource(DhSectionPos pos, FullDataPointIdMap mapping, long[][] data, byte[] columnGenerationSteps) + public static FullDataSourceV2 createWithData(DhSectionPos pos, FullDataPointIdMap mapping, long[][] data, byte[] columnGenerationStep) { return new FullDataSourceV2(pos, mapping, data, columnGenerationStep); } + private FullDataSourceV2(DhSectionPos pos, FullDataPointIdMap mapping, long[][] data, byte[] columnGenerationSteps) { LodUtil.assertTrue(data.length == WIDTH * WIDTH); @@ -126,16 +126,16 @@ public class NewFullDataSource implements IDataSource this.columnGenerationSteps = columnGenerationSteps; } - public static NewFullDataSource createFromChunk(IChunkWrapper chunkWrapper) { return LodDataBuilder.createGeneratedDataSource(chunkWrapper); } + public static FullDataSourceV2 createFromChunk(IChunkWrapper chunkWrapper) { return LodDataBuilder.createGeneratedDataSource(chunkWrapper); } - public static NewFullDataSource createFromCompleteDataSource(FullDataSourceV1 legacyData) + public static FullDataSourceV2 createFromCompleteDataSource(FullDataSourceV1 legacyData) { if (FullDataSourceV1.WIDTH != WIDTH) { throw new UnsupportedOperationException( - "Unable to convert CompleteFullDataSource into NewFullDataSource. " + + "Unable to convert ["+FullDataSourceV1.class.getSimpleName()+"] into ["+FullDataSourceV2.class.getSimpleName()+"]. " + "Data sources have different data point widths and no converter is present. " + - "CompleteFullDataSource width ["+ FullDataSourceV1.WIDTH+"], NewFullDataSource width ["+WIDTH+"]."); + "input width ["+ FullDataSourceV1.WIDTH+"], recipient width ["+WIDTH+"]."); } @@ -182,7 +182,7 @@ public class NewFullDataSource implements IDataSource blockLight = 0; } - long newDataPoint = FullDataPointUtil.encode(id, height, bottomY, blockLight, skyLight); + long newDataPoint = FullDataPointUtilV2.encode(id, height, bottomY, blockLight, skyLight); dataColumn[i] = newDataPoint; @@ -200,7 +200,7 @@ public class NewFullDataSource implements IDataSource } } - NewFullDataSource newFullDataSource = NewFullDataSource.createWithData(legacyData.getSectionPos(), legacyData.mapping, dataPoints, columnGenerationSteps); + FullDataSourceV2 fullDataSource = FullDataSourceV2.createWithData(legacyData.getSectionPos(), legacyData.mapping, dataPoints, columnGenerationSteps); // should only be used if debugging, this is a very expensive operation @@ -213,7 +213,7 @@ public class NewFullDataSource implements IDataSource long[] legacyDataColumn = legacyData.get(x, z); if (legacyDataColumn != null && legacyDataColumn.length != 0) { - long[] newDataColumn = newFullDataSource.get(x, z); + long[] newDataColumn = fullDataSource.get(x, z); if (newDataColumn == null) { @@ -239,7 +239,7 @@ public class NewFullDataSource implements IDataSource } } - return newFullDataSource; + return fullDataSource; } @@ -251,8 +251,8 @@ public class NewFullDataSource implements IDataSource public long[] get(int relX, int relZ) throws IndexOutOfBoundsException { return this.dataPoints[relativePosToIndex(relX, relZ)]; } @Override - public boolean update(NewFullDataSource inputDataSource, @Nullable IDhLevel level) { return this.update(inputDataSource); } - public boolean update(NewFullDataSource inputDataSource) + public boolean update(FullDataSourceV2 inputDataSource, @Nullable IDhLevel level) { return this.update(inputDataSource); } + public boolean update(FullDataSourceV2 inputDataSource) { // shouldn't happen, but James saw it happen once if (inputDataSource.mapping.getMaxValidId() == 0) @@ -288,7 +288,7 @@ public class NewFullDataSource implements IDataSource throw new UnsupportedOperationException("Unsupported data source update. Expected input detail level of ["+thisDetailLevel+"] or ["+(thisDetailLevel+1)+"], received detail level ["+inputDetailLevel+"]."); } - if (dataChanged && this.pos.getDetailLevel() < NewFullDataFileHandler.TOP_SECTION_DETAIL_LEVEL) + if (dataChanged && this.pos.getDetailLevel() < FullDataFileHandlerV2.TOP_SECTION_DETAIL_LEVEL) { // mark that this data source should be applied to its parent this.applyToParent = true; @@ -302,7 +302,7 @@ public class NewFullDataSource implements IDataSource return dataChanged; } - public boolean updateFromSameDetailLevel(NewFullDataSource inputDataSource, int[] remappedIds) + public boolean updateFromSameDetailLevel(FullDataSourceV2 inputDataSource, int[] remappedIds) { // both data sources should have the same detail level if (inputDataSource.pos.getDetailLevel() != this.pos.getDetailLevel()) @@ -351,7 +351,7 @@ public class NewFullDataSource implements IDataSource return dataChanged; } - public boolean updateFromOneBelowDetailLevel(NewFullDataSource inputDataSource, int[] remappedIds) + public boolean updateFromOneBelowDetailLevel(FullDataSourceV2 inputDataSource, int[] remappedIds) { if (inputDataSource.pos.getDetailLevel() + 1 != this.pos.getDetailLevel()) { @@ -406,7 +406,7 @@ public class NewFullDataSource implements IDataSource return dataChanged; } - private static long[] mergeInputTwoByTwoDataColumn(NewFullDataSource inputDataSource, int x, int z) + private static long[] mergeInputTwoByTwoDataColumn(FullDataSourceV2 inputDataSource, int x, int z) { ArrayList newColumnList = new ArrayList<>(); @@ -460,8 +460,8 @@ public class NewFullDataSource implements IDataSource } long datapoint = inputDataArray[dataPointIndex]; - int datapointMinY = FullDataPointUtil.getBottomY(datapoint); - int numbOfBlocksTall = FullDataPointUtil.getHeight(datapoint); + int datapointMinY = FullDataPointUtilV2.getBottomY(datapoint); + int numbOfBlocksTall = FullDataPointUtilV2.getHeight(datapoint); int datapointMaxY = (datapointMinY + numbOfBlocksTall); @@ -504,9 +504,9 @@ public class NewFullDataSource implements IDataSource int[] mergeSkyLights = new int[4]; for (int i = 0; i < 4; i++) { - mergeIds[i] = FullDataPointUtil.getId(datapointsForYSlice[i]); - mergeBlockLights[i] = FullDataPointUtil.getBlockLight(datapointsForYSlice[i]); - mergeSkyLights[i] = FullDataPointUtil.getSkyLight(datapointsForYSlice[i]); + mergeIds[i] = FullDataPointUtilV2.getId(datapointsForYSlice[i]); + mergeBlockLights[i] = FullDataPointUtilV2.getBlockLight(datapointsForYSlice[i]); + mergeSkyLights[i] = FullDataPointUtilV2.getSkyLight(datapointsForYSlice[i]); } @@ -523,7 +523,7 @@ public class NewFullDataSource implements IDataSource { if (height != 0) { - newColumnList.add(FullDataPointUtil.encode(lastId, height, minY, lastBlockLight, lastSkyLight)); + newColumnList.add(FullDataPointUtilV2.encode(lastId, height, minY, lastBlockLight, lastSkyLight)); } lastId = id; @@ -537,7 +537,7 @@ public class NewFullDataSource implements IDataSource // add the last slice if present if (height != 0) { - newColumnList.add(FullDataPointUtil.encode(lastId, height, minY, lastBlockLight, lastSkyLight)); + newColumnList.add(FullDataPointUtilV2.encode(lastId, height, minY, lastBlockLight, lastSkyLight)); } @@ -560,7 +560,7 @@ public class NewFullDataSource implements IDataSource long[] dataColumn = this.dataPoints[dataPointIndex]; for (int i = 0; i < dataColumn.length; i++) { - dataColumn[i] = FullDataPointUtil.remap(remappedIds, dataColumn[i]); + dataColumn[i] = FullDataPointUtilV2.remap(remappedIds, dataColumn[i]); } } private static boolean areDataColumnsDifferent(long[] oldDataArray, long[] newDataArray) @@ -705,7 +705,7 @@ public class NewFullDataSource implements IDataSource for (int i = 0; i < longArray.length; i++) { long dataPoint = longArray[i]; - int id = FullDataPointUtil.getId(dataPoint); + int id = FullDataPointUtilV2.getId(dataPoint); if (id > maxValidId) { LodUtil.assertNotReach("Column set with higher than possible ID. ID [" + id + "], max valid ID [" + maxValidId + "]."); @@ -738,11 +738,11 @@ public class NewFullDataSource implements IDataSource @Override public boolean equals(Object obj) { - if (!(obj instanceof NewFullDataSource)) + if (!(obj instanceof FullDataSourceV2)) { return false; } - NewFullDataSource other = (NewFullDataSource) obj; + FullDataSourceV2 other = (FullDataSourceV2) obj; if (!other.pos.equals(this.pos)) { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/ColumnRenderSource.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/ColumnRenderSource.java index 8e1c776ad..9eb58d3bb 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/ColumnRenderSource.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/render/ColumnRenderSource.java @@ -20,7 +20,7 @@ package com.seibel.distanthorizons.core.dataObjects.render; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.dataObjects.transformers.FullDataToRenderDataTransformer; import com.seibel.distanthorizons.core.file.IDataSource; import com.seibel.distanthorizons.core.level.IDhLevel; @@ -289,7 +289,7 @@ public class ColumnRenderSource implements IDataSource } @Override - public boolean update(NewFullDataSource inputFullDataSource, IDhClientLevel level) + public boolean update(FullDataSourceV2 inputFullDataSource, IDhClientLevel level) { final String errorMessagePrefix = "Unable to complete update for RenderSource pos: [" + this.sectionPos + "] and pos: [" + inputFullDataSource.getSectionPos() + "]. Error:"; @@ -310,9 +310,9 @@ public class ColumnRenderSource implements IDataSource int halfBlockWidth = inputFullDataSource.getSectionPos().getBlockWidth() / 2; DhBlockPos2D minBlockPos = new DhBlockPos2D(centerBlockPos.x - halfBlockWidth, centerBlockPos.z - halfBlockWidth); - for (int x = 0; x < NewFullDataSource.WIDTH; x++) + for (int x = 0; x < FullDataSourceV2.WIDTH; x++) { - for (int z = 0; z < NewFullDataSource.WIDTH; z++) + for (int z = 0; z < FullDataSourceV2.WIDTH; z++) { ColumnArrayView columnArrayView = this.getVerticalDataPointView(x, z); int columnHash = columnArrayView.getDataHash(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/ChunkToLodBuilder.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/ChunkToLodBuilder.java index a3a727f65..663a6f033 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/ChunkToLodBuilder.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/ChunkToLodBuilder.java @@ -23,7 +23,7 @@ import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; import com.seibel.distanthorizons.core.config.Config; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.logging.ConfigBasedLogger; import com.seibel.distanthorizons.core.pos.DhChunkPos; @@ -57,7 +57,7 @@ public class ChunkToLodBuilder implements AutoCloseable // data generation // //=================// - public CompletableFuture tryGenerateData(IChunkWrapper chunkWrapper) + public CompletableFuture tryGenerateData(IChunkWrapper chunkWrapper) { if (chunkWrapper == null) { @@ -74,7 +74,7 @@ public class ChunkToLodBuilder implements AutoCloseable } // Otherwise, it means we're the first to do so. Let's submit our task to this entry. - CompletableFuture future = new CompletableFuture<>(); + CompletableFuture future = new CompletableFuture<>(); this.concurrentTaskToBuildList.addLast(new Task(chunkWrapper.getChunkPos(), future)); return future; } @@ -158,7 +158,7 @@ public class ChunkToLodBuilder implements AutoCloseable { if (LodDataBuilder.canGenerateLodFromChunk(latestChunk)) { - NewFullDataSource dataSource = LodDataBuilder.createGeneratedDataSource(latestChunk); + FullDataSourceV2 dataSource = LodDataBuilder.createGeneratedDataSource(latestChunk); if (dataSource != null) { task.future.complete(dataSource); @@ -233,11 +233,11 @@ public class ChunkToLodBuilder implements AutoCloseable private static class Task { public final DhChunkPos chunkPos; - public final CompletableFuture future; + public final CompletableFuture future; /** This is tracked so impossible tasks can be removed from the queue */ public long generationAttemptExpirationTimeMs = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(10); - Task(DhChunkPos chunkPos, CompletableFuture future) + Task(DhChunkPos chunkPos, CompletableFuture future) { this.chunkPos = chunkPos; this.future = future; 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 817c6802d..37cbfb931 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 @@ -22,7 +22,7 @@ package com.seibel.distanthorizons.core.dataObjects.transformers; import com.seibel.distanthorizons.api.enums.config.EBlocksToAvoid; import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.dataObjects.render.ColumnRenderSource; import com.seibel.distanthorizons.core.dataObjects.render.columnViews.ColumnArrayView; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; @@ -30,7 +30,7 @@ import com.seibel.distanthorizons.core.level.IDhClientLevel; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.pos.DhBlockPos; import com.seibel.distanthorizons.core.pos.DhSectionPos; -import com.seibel.distanthorizons.core.util.FullDataPointUtil; +import com.seibel.distanthorizons.core.util.FullDataPointUtilV2; import com.seibel.distanthorizons.core.util.RenderDataPointUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory; import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper; @@ -41,7 +41,7 @@ import org.apache.logging.log4j.Logger; import java.util.HashSet; /** - * Handles converting {@link NewFullDataSource}'s to {@link ColumnRenderSource}. + * Handles converting {@link FullDataSourceV2}'s to {@link ColumnRenderSource}. */ public class FullDataToRenderDataTransformer { @@ -56,7 +56,7 @@ public class FullDataToRenderDataTransformer // public transformer interface // //==============================// - public static ColumnRenderSource transformFullDataToRenderSource(NewFullDataSource fullDataSource, IDhClientLevel level) + public static ColumnRenderSource transformFullDataToRenderSource(FullDataSourceV2 fullDataSource, IDhClientLevel level) { if (fullDataSource == null) { @@ -92,7 +92,7 @@ public class FullDataToRenderDataTransformer * @throws InterruptedException Can be caused by interrupting the thread upstream. * Generally thrown if the method is running after the client leaves the current world. */ - private static ColumnRenderSource transformCompleteFullDataToColumnData(IDhClientLevel level, NewFullDataSource fullDataSource) throws InterruptedException + private static ColumnRenderSource transformCompleteFullDataToColumnData(IDhClientLevel level, FullDataSourceV2 fullDataSource) throws InterruptedException { final DhSectionPos pos = fullDataSource.getSectionPos(); final byte dataDetail = fullDataSource.getDataDetailLevel(); @@ -174,11 +174,11 @@ public class FullDataToRenderDataTransformer for (int i = 0; i < fullColumnData.length; i++) { long fullData = fullColumnData[i]; - int bottomY = FullDataPointUtil.getBottomY(fullData); - int blockHeight = FullDataPointUtil.getHeight(fullData); - int id = FullDataPointUtil.getId(fullData); - int blockLight = FullDataPointUtil.getBlockLight(fullData); - int skyLight = FullDataPointUtil.getSkyLight(fullData); + int bottomY = FullDataPointUtilV2.getBottomY(fullData); + int blockHeight = FullDataPointUtilV2.getHeight(fullData); + int id = FullDataPointUtilV2.getId(fullData); + int blockLight = FullDataPointUtilV2.getBlockLight(fullData); + int skyLight = FullDataPointUtilV2.getSkyLight(fullData); // TODO how should corrupted data be handled? // TODO why is the full data corrupted in the first place? FullDataPointUtil hasn't been changed in a long time, could one of the full data point objects be corrupted? diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/LodDataBuilder.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/LodDataBuilder.java index 26d34d8bb..b2af153c1 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/LodDataBuilder.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/transformers/LodDataBuilder.java @@ -24,12 +24,12 @@ import java.util.List; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep; import com.seibel.distanthorizons.api.objects.data.DhApiChunk; import com.seibel.distanthorizons.api.objects.data.DhApiTerrainDataPoint; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.pos.DhChunkPos; import com.seibel.distanthorizons.core.pos.DhSectionPos; -import com.seibel.distanthorizons.core.util.FullDataPointUtil; +import com.seibel.distanthorizons.core.util.FullDataPointUtilV2; import com.seibel.distanthorizons.core.util.LodUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; @@ -42,8 +42,8 @@ public class LodDataBuilder { private static final Logger LOGGER = DhLoggerBuilder.getLogger(); private static final IBlockStateWrapper AIR = SingletonInjector.INSTANCE.get(IWrapperFactory.class).getAirBlockStateWrapper(); - /** how many chunks wide the {@link NewFullDataSource} is. */ - private static final int NUMB_OF_CHUNKS_WIDE = NewFullDataSource.WIDTH / LodUtil.CHUNK_WIDTH; + /** how many chunks wide the {@link FullDataSourceV2} is. */ + private static final int NUMB_OF_CHUNKS_WIDE = FullDataSourceV2.WIDTH / LodUtil.CHUNK_WIDTH; private static boolean getTopErrorLogged = false; @@ -53,7 +53,7 @@ public class LodDataBuilder // converters // //============// - public static NewFullDataSource createGeneratedDataSource(IChunkWrapper chunkWrapper) + public static FullDataSourceV2 createGeneratedDataSource(IChunkWrapper chunkWrapper) { if (!canGenerateLodFromChunk(chunkWrapper)) { @@ -70,7 +70,7 @@ public class LodDataBuilder sectionPosZ = (sectionPosZ < 0) ? ((sectionPosZ + 1) / NUMB_OF_CHUNKS_WIDE) - 1 : (sectionPosZ / NUMB_OF_CHUNKS_WIDE); DhSectionPos pos = new DhSectionPos(DhSectionPos.SECTION_BLOCK_DETAIL_LEVEL, sectionPosX, sectionPosZ); - NewFullDataSource dataSource = NewFullDataSource.createEmpty(pos); + FullDataSourceV2 dataSource = FullDataSourceV2.createEmpty(pos); dataSource.markNotEmpty(); @@ -177,7 +177,7 @@ public class LodDataBuilder if (!newBiome.equals(biome) || !newBlockState.equals(blockState)) { - longs.add(FullDataPointUtil.encode(mappedId, lastY - y, y + 1 - chunkWrapper.getMinBuildHeight(), blockLight, skyLight)); + longs.add(FullDataPointUtilV2.encode(mappedId, lastY - y, y + 1 - chunkWrapper.getMinBuildHeight(), blockLight, skyLight)); biome = newBiome; blockState = newBlockState; mappedId = dataSource.getMapping().addIfNotPresentAndGetId(biome, blockState); @@ -186,7 +186,7 @@ public class LodDataBuilder lastY = y; } } - longs.add(FullDataPointUtil.encode(mappedId, lastY - y, y + 1 - chunkWrapper.getMinBuildHeight(), blockLight, skyLight)); + longs.add(FullDataPointUtilV2.encode(mappedId, lastY - y, y + 1 - chunkWrapper.getMinBuildHeight(), blockLight, skyLight)); // reverse the array so index 0 is the lowest, // this is necessary for later logic @@ -211,9 +211,9 @@ public class LodDataBuilder /** @throws ClassCastException if an API user returns the wrong object type(s) */ - public static NewFullDataSource createFromApiChunkData(DhApiChunk dataPoints) throws ClassCastException + public static FullDataSourceV2 createFromApiChunkData(DhApiChunk dataPoints) throws ClassCastException { - NewFullDataSource accessor = NewFullDataSource.createEmpty(new DhSectionPos(new DhChunkPos(dataPoints.chunkPosX, dataPoints.chunkPosZ))); + FullDataSourceV2 accessor = FullDataSourceV2.createEmpty(new DhSectionPos(new DhChunkPos(dataPoints.chunkPosX, dataPoints.chunkPosZ))); for (int relZ = 0; relZ < LodUtil.CHUNK_WIDTH; relZ++) { for (int relX = 0; relX < LodUtil.CHUNK_WIDTH; relX++) @@ -237,7 +237,7 @@ public class LodDataBuilder (IBlockStateWrapper) (dataPoint.blockStateWrapper) ); - packedDataPoints[index] = FullDataPointUtil.encode( + packedDataPoints[index] = FullDataPointUtilV2.encode( id, dataPoint.topYBlockPos - dataPoint.bottomYBlockPos, dataPoint.bottomYBlockPos - dataPoints.topYBlockPos, diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractLegacyDataSourceHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractLegacyDataSourceHandler.java index 7a3c65dc1..71ca44501 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractLegacyDataSourceHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractLegacyDataSourceHandler.java @@ -1,7 +1,7 @@ package com.seibel.distanthorizons.core.file; import com.seibel.distanthorizons.api.enums.config.EDhApiDataCompressionMode; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.dataObjects.render.ColumnRenderSource; import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure; import com.seibel.distanthorizons.core.level.IDhLevel; @@ -190,7 +190,7 @@ public abstract class AbstractLegacyDataSourceHandler updateDataSourceAsync(NewFullDataSource inputDataSource) + public CompletableFuture updateDataSourceAsync(FullDataSourceV2 inputDataSource) { ThreadPoolExecutor executor = ThreadPoolUtil.getFileHandlerExecutor(); if (executor == null || executor.isTerminated()) @@ -218,7 +218,7 @@ public abstract class AbstractLegacyDataSourceHandler updateDataSourceAsync(NewFullDataSource inputDataSource) + public CompletableFuture updateDataSourceAsync(FullDataSourceV2 inputDataSource) { ThreadPoolExecutor executor = ThreadPoolUtil.getUpdatePropagatorExecutor(); if (executor == null || executor.isTerminated()) @@ -202,7 +202,7 @@ public abstract class AbstractNewDataSourceHandler * After this method returns the inputData will be written to file. * @param updatePos the position to update */ - protected void updateDataSourceAtPos(DhSectionPos updatePos, NewFullDataSource inputData, boolean lockOnUpdatePos) + protected void updateDataSourceAtPos(DhSectionPos updatePos, FullDataSourceV2 inputData, boolean lockOnUpdatePos) { boolean methodLocked = false; // a lock is necessary to prevent two threads from writing to the same position at once, 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 c4ae71ee1..e7a1fa5e8 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 @@ -2,7 +2,7 @@ package com.seibel.distanthorizons.core.file; import com.seibel.distanthorizons.api.enums.EDhApiDetailLevel; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +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; @@ -26,7 +26,7 @@ public interface IDataSource extends IBaseDTO, TDhL { CompletableFuture getAsync(DhSectionPos pos); - CompletableFuture updateDataSourceAsync(NewFullDataSource inputData); + CompletableFuture updateDataSourceAsync(FullDataSourceV2 inputData); } 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 733af7001..f92cfa7dc 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 @@ -1,6 +1,6 @@ package com.seibel.distanthorizons.core.file.fullDatafile; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +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; @@ -22,7 +22,7 @@ public class DelayedFullDataSourceSaveCache private static final Timer DELAY_UPDATE_TIMER = TimerUtil.CreateTimer("Delayed Full Datasource Save Timer"); - public final ConcurrentHashMap dataSourceByPosition = new ConcurrentHashMap<>(); + public final ConcurrentHashMap dataSourceByPosition = new ConcurrentHashMap<>(); private final ConcurrentHashMap saveTimerTasksBySectionPos = new ConcurrentHashMap<>(); private final ISaveDataSourceFunc onSaveTimeoutFunc; @@ -46,14 +46,14 @@ public class DelayedFullDataSourceSaveCache // update queue // //==============// - public void queueDataSourceForUpdateAndSave(NewFullDataSource inputDataSource) + public void queueDataSourceForUpdateAndSave(FullDataSourceV2 inputDataSource) { DhSectionPos dataSourcePos = inputDataSource.getSectionPos(); this.dataSourceByPosition.compute(dataSourcePos, (inputPos, temporaryDataSource) -> { if (temporaryDataSource == null) { - temporaryDataSource = NewFullDataSource.createEmpty(inputPos); + temporaryDataSource = FullDataSourceV2.createEmpty(inputPos); } temporaryDataSource.update(inputDataSource); @@ -67,7 +67,7 @@ public class DelayedFullDataSourceSaveCache try { - NewFullDataSource dataSourceToSave = DelayedFullDataSourceSaveCache.this.dataSourceByPosition.remove(dataSourcePos); + FullDataSourceV2 dataSourceToSave = DelayedFullDataSourceSaveCache.this.dataSourceByPosition.remove(dataSourcePos); if (dataSourceToSave != null) { DelayedFullDataSourceSaveCache.this.onSaveTimeoutFunc.save(dataSourceToSave); @@ -115,7 +115,7 @@ public class DelayedFullDataSourceSaveCache public interface ISaveDataSourceFunc { /** called after the timeout expires */ - void save(NewFullDataSource inputDataSource); + void save(FullDataSourceV2 inputDataSource); } } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/NewFullDataFileHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataFileHandlerV2.java similarity index 90% rename from core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/NewFullDataFileHandler.java rename to core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataFileHandlerV2.java index 43e5bf85e..ead649c20 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/NewFullDataFileHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataFileHandlerV2.java @@ -22,7 +22,7 @@ package com.seibel.distanthorizons.core.file.fullDatafile; import com.seibel.distanthorizons.api.enums.config.EDhApiDataCompressionMode; import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV1; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure; import com.seibel.distanthorizons.core.file.AbstractNewDataSourceHandler; import com.seibel.distanthorizons.core.level.IDhLevel; @@ -30,8 +30,8 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.render.renderer.DebugRenderer; import com.seibel.distanthorizons.core.render.renderer.IDebugRenderable; -import com.seibel.distanthorizons.core.sql.dto.NewFullDataSourceDTO; -import com.seibel.distanthorizons.core.sql.repo.NewFullDataSourceRepo; +import com.seibel.distanthorizons.core.sql.dto.FullDataSourceV2DTO; +import com.seibel.distanthorizons.core.sql.repo.FullDataSourceV2Repo; import com.seibel.distanthorizons.core.util.ThreadUtil; import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil; import org.apache.logging.log4j.Logger; @@ -46,8 +46,8 @@ import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReentrantLock; -public class NewFullDataFileHandler - extends AbstractNewDataSourceHandler +public class FullDataFileHandlerV2 + extends AbstractNewDataSourceHandler implements IFullDataSourceProvider, IDebugRenderable { private static final Logger LOGGER = DhLoggerBuilder.getLogger(); @@ -93,8 +93,8 @@ public class NewFullDataFileHandler // constructor // //=============// - public NewFullDataFileHandler(IDhLevel level, AbstractSaveStructure saveStructure) { this(level, saveStructure, null); } - public NewFullDataFileHandler(IDhLevel level, AbstractSaveStructure saveStructure, @Nullable File saveDirOverride) + public FullDataFileHandlerV2(IDhLevel level, AbstractSaveStructure saveStructure) { this(level, saveStructure, null); } + public FullDataFileHandlerV2(IDhLevel level, AbstractSaveStructure saveStructure, @Nullable File saveDirOverride) { super(level, saveStructure, saveDirOverride); this.legacyFileHandler = new FullDataFileHandlerV1(level, saveStructure, saveDirOverride); @@ -120,11 +120,11 @@ public class NewFullDataFileHandler //====================// @Override - protected NewFullDataSourceRepo createRepo() + protected FullDataSourceV2Repo createRepo() { try { - return new NewFullDataSourceRepo("jdbc:sqlite", this.saveDir.getPath() + "/" + AbstractSaveStructure.DATABASE_NAME); + return new FullDataSourceV2Repo("jdbc:sqlite", this.saveDir.getPath() + "/" + AbstractSaveStructure.DATABASE_NAME); } catch (SQLException e) { @@ -135,13 +135,13 @@ public class NewFullDataFileHandler } @Override - protected NewFullDataSourceDTO createDtoFromDataSource(NewFullDataSource dataSource) + protected FullDataSourceV2DTO createDtoFromDataSource(FullDataSourceV2 dataSource) { try { // when creating new data use the compressor currently selected in the config EDhApiDataCompressionMode compressionModeEnum = Config.Client.Advanced.LodBuilding.dataCompression.get(); - return NewFullDataSourceDTO.CreateFromDataSource(dataSource, compressionModeEnum); + return FullDataSourceV2DTO.CreateFromDataSource(dataSource, compressionModeEnum); } catch (IOException e) { @@ -151,17 +151,17 @@ public class NewFullDataFileHandler } @Override - protected NewFullDataSource createDataSourceFromDto(NewFullDataSourceDTO dto) throws InterruptedException, IOException + protected FullDataSourceV2 createDataSourceFromDto(FullDataSourceV2DTO dto) throws InterruptedException, IOException { return dto.createDataSource(this.level.getLevelWrapper()); } @Override - protected NewFullDataSource createNewDataSourceFromExistingDtos(DhSectionPos pos) + protected FullDataSourceV2 createNewDataSourceFromExistingDtos(DhSectionPos pos) { // TODO maybe just set children update flags to true? - return NewFullDataSource.createEmpty(pos); + return FullDataSourceV2.createEmpty(pos); } @Override - protected NewFullDataSource makeEmptyDataSource(DhSectionPos pos) { return NewFullDataSource.createEmpty(pos); } + protected FullDataSourceV2 makeEmptyDataSource(DhSectionPos pos) { return FullDataSourceV2.createEmpty(pos); } @Override public boolean canQueueRetrieval() @@ -253,7 +253,7 @@ public class NewFullDataFileHandler childReadLock.lock(); this.lockedPosSet.add(childPos); - NewFullDataSource dataSource = this.get(childPos); + FullDataSourceV2 dataSource = this.get(childPos); this.updateDataSourceAtPos(parentUpdatePos, dataSource, false); this.repo.setApplyToParent(childPos, false); } @@ -333,7 +333,7 @@ public class NewFullDataFileHandler { // convert the legacy data source to the new format, // this is a relatively cheap operation - NewFullDataSource newDataSource = NewFullDataSource.createFromCompleteDataSource(legacyDataSource); + FullDataSourceV2 newDataSource = FullDataSourceV2.createFromCompleteDataSource(legacyDataSource); newDataSource.applyToParent = true; // the actual update process can be moderately expensive due to having to update diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/NewGeneratedFullDataFileHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataFileHandler.java similarity index 93% rename from core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/NewGeneratedFullDataFileHandler.java rename to core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataFileHandler.java index 2f08a75bd..d3c338711 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/NewGeneratedFullDataFileHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataFileHandler.java @@ -21,7 +21,7 @@ package com.seibel.distanthorizons.core.file.fullDatafile; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiWorldGenerationStep; import com.seibel.distanthorizons.core.config.Config; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure; import com.seibel.distanthorizons.core.generation.IWorldGenerationQueue; import com.seibel.distanthorizons.core.generation.tasks.IWorldGenTaskTracker; @@ -43,7 +43,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.function.Function; -public class NewGeneratedFullDataFileHandler extends NewFullDataFileHandler implements IDebugRenderable +public class GeneratedFullDataFileHandler extends FullDataFileHandlerV2 implements IDebugRenderable { private static final Logger LOGGER = DhLoggerBuilder.getLogger(); @@ -61,7 +61,7 @@ public class NewGeneratedFullDataFileHandler extends NewFullDataFileHandler impl // constructor // //=============// - public NewGeneratedFullDataFileHandler(IDhLevel level, AbstractSaveStructure saveStructure) { super(level, saveStructure); } + public GeneratedFullDataFileHandler(IDhLevel level, AbstractSaveStructure saveStructure) { super(level, saveStructure); } @@ -248,11 +248,11 @@ public class NewGeneratedFullDataFileHandler extends NewFullDataFileHandler impl EDhApiWorldGenerationStep currentMinWorldGenStep = EDhApiWorldGenerationStep.LIGHT; checkWorldGenLoop: - for (int x = 0; x < NewFullDataSource.WIDTH; x++) + for (int x = 0; x < FullDataSourceV2.WIDTH; x++) { - for (int z = 0; z < NewFullDataSource.WIDTH; z++) + for (int z = 0; z < FullDataSourceV2.WIDTH; z++) { - int index = NewFullDataSource.relativePosToIndex(x, z); + int index = FullDataSourceV2.relativePosToIndex(x, z); byte genStepValue = columnGenerationSteps[index]; if (genStepValue < currentMinWorldGenStep.value) @@ -338,16 +338,16 @@ public class NewGeneratedFullDataFileHandler extends NewFullDataFileHandler impl public boolean isMemoryAddressValid() { return true; } @Override - public Consumer getChunkDataConsumer() + public Consumer getChunkDataConsumer() { return (chunkSizedFullDataSource) -> { - NewGeneratedFullDataFileHandler.this.delayedFullDataSourceSaveCache.queueDataSourceForUpdateAndSave(chunkSizedFullDataSource); + GeneratedFullDataFileHandler.this.delayedFullDataSourceSaveCache.queueDataSourceForUpdateAndSave(chunkSizedFullDataSource); }; } } - private void onDataSourceSave(NewFullDataSource fullDataSource) - { NewGeneratedFullDataFileHandler.this.updateDataSourceAsync(fullDataSource); } + private void onDataSourceSave(FullDataSourceV2 fullDataSource) + { GeneratedFullDataFileHandler.this.updateDataSourceAsync(fullDataSource); } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/IFullDataSourceProvider.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/IFullDataSourceProvider.java index cf1a7bdbb..7b5a81291 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/IFullDataSourceProvider.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/IFullDataSourceProvider.java @@ -19,7 +19,7 @@ package com.seibel.distanthorizons.core.file.fullDatafile; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.file.ISourceProvider; import com.seibel.distanthorizons.core.level.IDhLevel; import com.seibel.distanthorizons.core.pos.DhSectionPos; @@ -30,15 +30,15 @@ import java.util.ArrayList; import java.util.concurrent.CompletableFuture; /** - * Handles reading, writing, and updating {@link NewFullDataSource}'s.
+ * Handles reading, writing, and updating {@link FullDataSourceV2}'s.
* Should be backed by a database handled by a {@link LegacyFullDataRepo}. */ -public interface IFullDataSourceProvider extends ISourceProvider, AutoCloseable +public interface IFullDataSourceProvider extends ISourceProvider, AutoCloseable { - CompletableFuture getAsync(DhSectionPos pos); - NewFullDataSource get(DhSectionPos pos); + CompletableFuture getAsync(DhSectionPos pos); + FullDataSourceV2 get(DhSectionPos pos); - CompletableFuture updateDataSourceAsync(NewFullDataSource chunkData); + CompletableFuture updateDataSourceAsync(FullDataSourceV2 chunkData); /** @return -1 if this provider never has unsaved data sources */ default int getUnsavedDataSourceCount() { return -1; } @@ -49,7 +49,7 @@ public interface IFullDataSourceProvider extends ISourceProvider getAsync(DhSectionPos pos); - CompletableFuture updateDataSourceAsync(NewFullDataSource dataSource); + CompletableFuture updateDataSourceAsync(FullDataSourceV2 dataSource); /** Deletes any data stored in the render cache so it can be re-created */ void deleteRenderCache(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/renderfile/RenderSourceFileHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/renderfile/RenderSourceFileHandler.java index d7ae22c10..b0510559b 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/renderfile/RenderSourceFileHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/renderfile/RenderSourceFileHandler.java @@ -19,11 +19,11 @@ package com.seibel.distanthorizons.core.file.renderfile; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.dataObjects.render.ColumnRenderSourceLoader; import com.seibel.distanthorizons.core.dataObjects.transformers.FullDataToRenderDataTransformer; import com.seibel.distanthorizons.core.file.AbstractLegacyDataSourceHandler; -import com.seibel.distanthorizons.core.file.fullDatafile.NewFullDataFileHandler; +import com.seibel.distanthorizons.core.file.fullDatafile.FullDataFileHandlerV2; import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.logging.f3.F3Screen; @@ -49,7 +49,7 @@ public class RenderSourceFileHandler extends AbstractLegacyDataSourceHandler updateDataSourceAsync(NewFullDataSource inputDataSource) + public CompletableFuture updateDataSourceAsync(FullDataSourceV2 inputDataSource) { // TODO once the legacy data provider has been replaced this can be removed this.updateDataSourceAtPos(inputDataSource.getSectionPos(), inputDataSource); @@ -140,8 +140,7 @@ public class RenderSourceFileHandler extends AbstractLegacyDataSourceHandler chunkDataConsumer + Consumer chunkDataConsumer ) { EDhApiDistantGeneratorMode generatorMode = Config.Client.Advanced.WorldGenerator.distantGeneratorMode.get(); @@ -450,7 +450,7 @@ public class WorldGenerationQueue implements IWorldGenerationQueue, IDebugRender try { IChunkWrapper chunk = WRAPPER_FACTORY.createChunkWrapper(generatedObjectArray); - NewFullDataSource dataSource = LodDataBuilder.createGeneratedDataSource(chunk); + FullDataSourceV2 dataSource = LodDataBuilder.createGeneratedDataSource(chunk); LodUtil.assertTrue(dataSource != null); chunkDataConsumer.accept(dataSource); } @@ -475,7 +475,7 @@ public class WorldGenerationQueue implements IWorldGenerationQueue, IDebugRender { try { - NewFullDataSource dataSource = LodDataBuilder.createFromApiChunkData(dataPoints); + FullDataSourceV2 dataSource = LodDataBuilder.createFromApiChunkData(dataPoints); chunkDataConsumer.accept(dataSource); } catch (ClassCastException e) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/IWorldGenTaskTracker.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/IWorldGenTaskTracker.java index 4568f9821..d0eecf2ea 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/IWorldGenTaskTracker.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/tasks/IWorldGenTaskTracker.java @@ -19,7 +19,7 @@ package com.seibel.distanthorizons.core.generation.tasks; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import java.util.function.Consumer; @@ -32,6 +32,6 @@ public interface IWorldGenTaskTracker /** Returns true if the task hasn't been garbage collected. */ boolean isMemoryAddressValid(); - Consumer getChunkDataConsumer(); + Consumer getChunkDataConsumer(); } 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 39c145c01..ea7b5b91e 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 @@ -19,7 +19,7 @@ package com.seibel.distanthorizons.core.generation.tasks; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.pos.DhSectionPos; import java.util.Iterator; @@ -46,13 +46,13 @@ public final class WorldGenTaskGroup this.dataDetail = dataDetail; } - public void consumeChunkData(NewFullDataSource chunkSizedFullDataView) + public void consumeChunkData(FullDataSourceV2 chunkSizedFullDataView) { Iterator tasks = this.worldGenTasks.iterator(); while (tasks.hasNext()) { WorldGenTask task = tasks.next(); - Consumer chunkDataConsumer = task.taskTracker.getChunkDataConsumer(); + Consumer chunkDataConsumer = task.taskTracker.getChunkDataConsumer(); if (chunkDataConsumer == null) { tasks.remove(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhLevel.java b/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhLevel.java index d4a9d8a27..46c7ad97d 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhLevel.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhLevel.java @@ -20,7 +20,7 @@ package com.seibel.distanthorizons.core.level; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiChunkModifiedEvent; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.dataObjects.transformers.ChunkToLodBuilder; import com.seibel.distanthorizons.core.file.fullDatafile.DelayedFullDataSourceSaveCache; import com.seibel.distanthorizons.core.pos.DhChunkPos; @@ -59,7 +59,7 @@ public abstract class AbstractDhLevel implements IDhLevel @Override public void updateChunkAsync(IChunkWrapper chunkWrapper) { - NewFullDataSource dataSource = NewFullDataSource.createFromChunk(chunkWrapper); + FullDataSourceV2 dataSource = FullDataSourceV2.createFromChunk(chunkWrapper); if (dataSource == null) { // This can happen if, among other reasons, a chunk save is superseded by a later event @@ -81,7 +81,7 @@ public abstract class AbstractDhLevel implements IDhLevel this.delayedFullDataSourceSaveCache.queueDataSourceForUpdateAndSave(dataSource); } - private void onDataSourceSave(NewFullDataSource fullDataSource) + private void onDataSourceSave(FullDataSourceV2 fullDataSource) { this.updateDataSourcesAsync(fullDataSource).thenRun(() -> { 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 c1648dab7..d5cddb202 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 @@ -22,12 +22,11 @@ package com.seibel.distanthorizons.core.level; import com.seibel.distanthorizons.api.enums.rendering.EDebugRendering; import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam; import com.seibel.distanthorizons.core.config.Config; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.file.AbstractNewDataSourceHandler; import com.seibel.distanthorizons.core.file.fullDatafile.IFullDataSourceProvider; -import com.seibel.distanthorizons.core.file.fullDatafile.NewFullDataFileHandler; -import com.seibel.distanthorizons.core.file.renderfile.IRenderSourceProvider; +import com.seibel.distanthorizons.core.file.fullDatafile.FullDataFileHandlerV2; import com.seibel.distanthorizons.core.file.renderfile.RenderSourceFileHandler; import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; @@ -47,14 +46,14 @@ import java.io.Closeable; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicReference; -public class ClientLevelModule implements Closeable, AbstractNewDataSourceHandler.IDataSourceUpdateFunc +public class ClientLevelModule implements Closeable, AbstractNewDataSourceHandler.IDataSourceUpdateFunc { private static final Logger LOGGER = DhLoggerBuilder.getLogger(); private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class); private final IDhClientLevel parentClientLevel; - public final NewFullDataFileHandler fullDataSourceProvider; + public final FullDataFileHandlerV2 fullDataSourceProvider; public final AtomicReference ClientRenderStateRef = new AtomicReference<>(); public final F3Screen.NestedMessage f3Message; @@ -210,9 +209,9 @@ public class ClientLevelModule implements Closeable, AbstractNewDataSourceHandle // data handling // //===============// - public CompletableFuture updateDataSourcesAsync(NewFullDataSource data) { return this.parentClientLevel.getFullDataProvider().updateDataSourceAsync(data); } + public CompletableFuture updateDataSourcesAsync(FullDataSourceV2 data) { return this.parentClientLevel.getFullDataProvider().updateDataSourceAsync(data); } @Override - public void OnDataSourceUpdated(NewFullDataSource updatedFullDataSource) + public void OnDataSourceUpdated(FullDataSourceV2 updatedFullDataSource) { // if rendering also update the render sources ClientRenderState ClientRenderState = this.ClientRenderStateRef.get(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/DhClientLevel.java b/core/src/main/java/com/seibel/distanthorizons/core/level/DhClientLevel.java index 439b0228d..285008ab2 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/DhClientLevel.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/DhClientLevel.java @@ -20,10 +20,9 @@ package com.seibel.distanthorizons.core.level; import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; -import com.seibel.distanthorizons.core.file.fullDatafile.IFullDataSourceProvider; -import com.seibel.distanthorizons.core.file.fullDatafile.NewFullDataFileHandler; -import com.seibel.distanthorizons.core.file.fullDatafile.NewRemoteFullDataFileHandler; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; +import com.seibel.distanthorizons.core.file.fullDatafile.FullDataFileHandlerV2; +import com.seibel.distanthorizons.core.file.fullDatafile.RemoteFullDataFileHandler; import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.pos.DhBlockPos; @@ -46,7 +45,7 @@ public class DhClientLevel extends AbstractDhLevel implements IDhClientLevel public final ClientLevelModule clientside; public final IClientLevelWrapper levelWrapper; public final AbstractSaveStructure saveStructure; - public final NewRemoteFullDataFileHandler dataFileHandler; + public final RemoteFullDataFileHandler dataFileHandler; @@ -59,7 +58,7 @@ public class DhClientLevel extends AbstractDhLevel implements IDhClientLevel { this.levelWrapper = clientLevelWrapper; this.saveStructure = saveStructure; - this.dataFileHandler = new NewRemoteFullDataFileHandler(this, saveStructure, fullDataSaveDirOverride); + this.dataFileHandler = new RemoteFullDataFileHandler(this, saveStructure, fullDataSaveDirOverride); this.clientside = new ClientLevelModule(this); if (enableRendering) @@ -119,7 +118,7 @@ public class DhClientLevel extends AbstractDhLevel implements IDhClientLevel public ILevelWrapper getLevelWrapper() { return levelWrapper; } @Override - public CompletableFuture updateDataSourcesAsync(NewFullDataSource data) { return this.clientside.updateDataSourcesAsync(data); } + public CompletableFuture updateDataSourcesAsync(FullDataSourceV2 data) { return this.clientside.updateDataSourcesAsync(data); } @Override public int getMinY() { return levelWrapper.getMinHeight(); } @@ -138,7 +137,7 @@ public class DhClientLevel extends AbstractDhLevel implements IDhClientLevel //=======================// @Override - public NewFullDataFileHandler getFullDataProvider() { return this.dataFileHandler; } + public FullDataFileHandlerV2 getFullDataProvider() { return this.dataFileHandler; } @Override public AbstractSaveStructure getSaveStructure() 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 f2cf7a8e8..5b5a24a62 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 @@ -20,10 +20,9 @@ package com.seibel.distanthorizons.core.level; import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; -import com.seibel.distanthorizons.core.file.fullDatafile.IFullDataSourceProvider; -import com.seibel.distanthorizons.core.file.fullDatafile.NewFullDataFileHandler; +import com.seibel.distanthorizons.core.file.fullDatafile.FullDataFileHandlerV2; import com.seibel.distanthorizons.core.render.LodRenderSection; import com.seibel.distanthorizons.core.render.renderer.DebugRenderer; import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure; @@ -175,7 +174,7 @@ public class DhClientServerLevel extends AbstractDhLevel implements IDhClientLev public ILevelWrapper getLevelWrapper() { return getServerLevelWrapper(); } @Override - public NewFullDataFileHandler getFullDataProvider() { return this.serverside.dataFileHandler; } + public FullDataFileHandlerV2 getFullDataProvider() { return this.serverside.dataFileHandler; } @Override public AbstractSaveStructure getSaveStructure() @@ -187,7 +186,7 @@ public class DhClientServerLevel extends AbstractDhLevel implements IDhClientLev public boolean hasSkyLight() { return this.serverLevelWrapper.hasSkyLight(); } @Override - public CompletableFuture updateDataSourcesAsync(NewFullDataSource data) { return this.clientside.updateDataSourcesAsync(data); } + public CompletableFuture updateDataSourcesAsync(FullDataSourceV2 data) { return this.clientside.updateDataSourcesAsync(data); } @Override public int getMinY() { return getLevelWrapper().getMinHeight(); } 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 f3e4b3164..5f7f06136 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 @@ -19,8 +19,8 @@ package com.seibel.distanthorizons.core.level; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; -import com.seibel.distanthorizons.core.file.fullDatafile.NewFullDataFileHandler; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; +import com.seibel.distanthorizons.core.file.fullDatafile.FullDataFileHandlerV2; import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure; import com.seibel.distanthorizons.core.pos.DhBlockPos2D; import com.seibel.distanthorizons.core.pos.DhSectionPos; @@ -51,7 +51,7 @@ public class DhServerLevel extends AbstractDhLevel implements IDhServerLevel public void serverTick() { this.chunkToLodBuilder.tick(); } @Override - public CompletableFuture updateDataSourcesAsync(NewFullDataSource data) { return this.getFullDataProvider().updateDataSourceAsync(data); } + public CompletableFuture updateDataSourcesAsync(FullDataSourceV2 data) { return this.getFullDataProvider().updateDataSourceAsync(data); } @Override public int getMinY() { return getLevelWrapper().getMinHeight(); } @@ -93,7 +93,7 @@ public class DhServerLevel extends AbstractDhLevel implements IDhServerLevel public ILevelWrapper getLevelWrapper() { return getServerLevelWrapper(); } @Override - public NewFullDataFileHandler getFullDataProvider() { return this.serverside.dataFileHandler; } + public FullDataFileHandlerV2 getFullDataProvider() { return this.serverside.dataFileHandler; } @Override public AbstractSaveStructure getSaveStructure() diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/IDhLevel.java b/core/src/main/java/com/seibel/distanthorizons/core/level/IDhLevel.java index f8baafd4a..7dd2450e6 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/IDhLevel.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/IDhLevel.java @@ -19,8 +19,8 @@ package com.seibel.distanthorizons.core.level; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; -import com.seibel.distanthorizons.core.file.fullDatafile.NewFullDataFileHandler; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; +import com.seibel.distanthorizons.core.file.fullDatafile.FullDataFileHandlerV2; import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure; import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; @@ -39,13 +39,13 @@ public interface IDhLevel extends AutoCloseable void updateChunkAsync(IChunkWrapper chunk); - NewFullDataFileHandler getFullDataProvider(); + FullDataFileHandlerV2 getFullDataProvider(); AbstractSaveStructure getSaveStructure(); boolean hasSkyLight(); - CompletableFuture updateDataSourcesAsync(NewFullDataSource data); + CompletableFuture updateDataSourcesAsync(FullDataSourceV2 data); /** * this number is generally related to how many data sources have been updated diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/IDhWorldGenLevel.java b/core/src/main/java/com/seibel/distanthorizons/core/level/IDhWorldGenLevel.java index 118d4a272..94108b380 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/IDhWorldGenLevel.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/IDhWorldGenLevel.java @@ -19,9 +19,9 @@ package com.seibel.distanthorizons.core.level; -import com.seibel.distanthorizons.core.file.fullDatafile.NewGeneratedFullDataFileHandler; +import com.seibel.distanthorizons.core.file.fullDatafile.GeneratedFullDataFileHandler; -public interface IDhWorldGenLevel extends IDhLevel, NewGeneratedFullDataFileHandler.IOnWorldGenCompleteListener +public interface IDhWorldGenLevel extends IDhLevel, GeneratedFullDataFileHandler.IOnWorldGenCompleteListener { void doWorldGen(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/ServerLevelModule.java b/core/src/main/java/com/seibel/distanthorizons/core/level/ServerLevelModule.java index cdc32f285..9e8b132be 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/ServerLevelModule.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/ServerLevelModule.java @@ -22,7 +22,7 @@ package com.seibel.distanthorizons.core.level; import com.seibel.distanthorizons.api.interfaces.override.worldGenerator.IDhApiWorldGenerator; import com.seibel.distanthorizons.core.config.AppliedConfigState; import com.seibel.distanthorizons.core.config.Config; -import com.seibel.distanthorizons.core.file.fullDatafile.NewGeneratedFullDataFileHandler; +import com.seibel.distanthorizons.core.file.fullDatafile.GeneratedFullDataFileHandler; import com.seibel.distanthorizons.core.file.structure.AbstractSaveStructure; import com.seibel.distanthorizons.core.generation.BatchGenerator; import com.seibel.distanthorizons.core.generation.WorldGenerationQueue; @@ -36,7 +36,7 @@ public class ServerLevelModule public final IDhServerLevel parentServerLevel; public final AbstractSaveStructure saveStructure; - public final NewGeneratedFullDataFileHandler dataFileHandler; + public final GeneratedFullDataFileHandler dataFileHandler; public final AppliedConfigState worldGeneratorEnabledConfig; public final WorldGenModule worldGenModule; @@ -47,7 +47,7 @@ public class ServerLevelModule { this.parentServerLevel = parentServerLevel; this.saveStructure = saveStructure; - this.dataFileHandler = new NewGeneratedFullDataFileHandler(parentServerLevel, saveStructure); + this.dataFileHandler = new GeneratedFullDataFileHandler(parentServerLevel, saveStructure); this.worldGeneratorEnabledConfig = new AppliedConfigState<>(Config.Client.Advanced.WorldGenerator.enableDistantGeneration); this.worldGenModule = new WorldGenModule(this.dataFileHandler, this.parentServerLevel); } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/WorldGenModule.java b/core/src/main/java/com/seibel/distanthorizons/core/level/WorldGenModule.java index 0d7f5bf98..302e31b1a 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/WorldGenModule.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/WorldGenModule.java @@ -19,7 +19,7 @@ package com.seibel.distanthorizons.core.level; -import com.seibel.distanthorizons.core.file.fullDatafile.NewGeneratedFullDataFileHandler; +import com.seibel.distanthorizons.core.file.fullDatafile.GeneratedFullDataFileHandler; import com.seibel.distanthorizons.core.generation.IWorldGenerationQueue; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.logging.f3.F3Screen; @@ -34,15 +34,15 @@ public class WorldGenModule implements Closeable { private static final Logger LOGGER = DhLoggerBuilder.getLogger(); - private final NewGeneratedFullDataFileHandler dataFileHandler; - private final NewGeneratedFullDataFileHandler.IOnWorldGenCompleteListener onWorldGenCompleteListener; + private final GeneratedFullDataFileHandler dataFileHandler; + private final GeneratedFullDataFileHandler.IOnWorldGenCompleteListener onWorldGenCompleteListener; private final AtomicReference worldGenStateRef = new AtomicReference<>(); private final F3Screen.DynamicMessage worldGenF3Message; - public WorldGenModule(NewGeneratedFullDataFileHandler dataFileHandler, NewGeneratedFullDataFileHandler.IOnWorldGenCompleteListener onWorldGenCompleteListener) + public WorldGenModule(GeneratedFullDataFileHandler dataFileHandler, GeneratedFullDataFileHandler.IOnWorldGenCompleteListener onWorldGenCompleteListener) { this.dataFileHandler = dataFileHandler; this.onWorldGenCompleteListener = onWorldGenCompleteListener; @@ -71,7 +71,7 @@ public class WorldGenModule implements Closeable // world gen control // //===================// - public void startWorldGen(NewGeneratedFullDataFileHandler dataFileHandler, AbstractWorldGenState newWgs) + public void startWorldGen(GeneratedFullDataFileHandler dataFileHandler, AbstractWorldGenState newWgs) { // create the new world generator if (!this.worldGenStateRef.compareAndSet(null, newWgs)) @@ -83,7 +83,7 @@ public class WorldGenModule implements Closeable dataFileHandler.setWorldGenerationQueue(newWgs.worldGenerationQueue); } - public void stopWorldGen(NewGeneratedFullDataFileHandler dataFileHandler) + public void stopWorldGen(GeneratedFullDataFileHandler dataFileHandler) { AbstractWorldGenState worldGenState = this.worldGenStateRef.get(); if (worldGenState == null) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/pos/DhLodPos.java b/core/src/main/java/com/seibel/distanthorizons/core/pos/DhLodPos.java index 1706e9365..cbc08fb64 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/pos/DhLodPos.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/pos/DhLodPos.java @@ -19,7 +19,7 @@ package com.seibel.distanthorizons.core.pos; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.coreapi.util.BitShiftUtil; import com.seibel.distanthorizons.core.util.LodUtil; import org.jetbrains.annotations.NotNull; @@ -122,7 +122,7 @@ public class DhLodPos implements Comparable public DhLodPos getDhSectionRelativePositionForDetailLevel() throws IllegalArgumentException { return this.getDhSectionRelativePositionForDetailLevel(this.detailLevel); } /** * Returns a DhLodPos with the given detail level and an X/Z position somewhere between (0,0) and (63,63). - * This is done to access specific sections from a {@link NewFullDataSource} where LOD columns are stored + * This is done to access specific sections from a {@link FullDataSourceV2} where LOD columns are stored * in 64 x 64 blocks. * * @throws IllegalArgumentException if this position's detail level is lower than the output detail level diff --git a/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/NewFullDataSourceDTO.java b/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/FullDataSourceV2DTO.java similarity index 85% rename from core/src/main/java/com/seibel/distanthorizons/core/sql/dto/NewFullDataSourceDTO.java rename to core/src/main/java/com/seibel/distanthorizons/core/sql/dto/FullDataSourceV2DTO.java index d61f0e2a2..dc631e72a 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/NewFullDataSourceDTO.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/sql/dto/FullDataSourceV2DTO.java @@ -21,9 +21,8 @@ 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.config.Config; import com.seibel.distanthorizons.core.dataObjects.fullData.FullDataPointIdMap; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.pos.DhSectionPos; import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataInputStream; import com.seibel.distanthorizons.core.util.objects.dataStreams.DhDataOutputStream; @@ -36,8 +35,8 @@ import java.io.IOException; import java.util.zip.Adler32; import java.util.zip.CheckedOutputStream; -/** handles storing {@link NewFullDataSource}'s in the database. */ -public class NewFullDataSourceDTO implements IBaseDTO +/** handles storing {@link FullDataSourceV2}'s in the database. */ +public class FullDataSourceV2DTO implements IBaseDTO { public DhSectionPos pos; @@ -67,20 +66,20 @@ public class NewFullDataSourceDTO implements IBaseDTO // constructor // //=============// - public static NewFullDataSourceDTO CreateFromDataSource(NewFullDataSource dataSource, EDhApiDataCompressionMode compressionModeEnum) throws IOException + public static FullDataSourceV2DTO CreateFromDataSource(FullDataSourceV2 dataSource, EDhApiDataCompressionMode compressionModeEnum) throws IOException { CheckedByteArray checkedDataPointArray = writeDataSourceDataArrayToBlob(dataSource.dataPoints, compressionModeEnum); byte[] mappingByteArray = writeDataMappingToBlob(dataSource.getMapping(), compressionModeEnum); - return new NewFullDataSourceDTO( + return new FullDataSourceV2DTO( dataSource.getSectionPos(), - checkedDataPointArray.checksum, dataSource.columnGenerationSteps, NewFullDataSource.DATA_FORMAT_VERSION, compressionModeEnum, checkedDataPointArray.byteArray, + checkedDataPointArray.checksum, dataSource.columnGenerationSteps, FullDataSourceV2.DATA_FORMAT_VERSION, compressionModeEnum, checkedDataPointArray.byteArray, dataSource.lastModifiedUnixDateTime, dataSource.createdUnixDateTime, mappingByteArray, dataSource.applyToParent, dataSource.levelMinY ); } - public NewFullDataSourceDTO( + public FullDataSourceV2DTO( DhSectionPos pos, int dataChecksum, byte[] columnGenStepByteArray, byte dataFormatVersion, EDhApiDataCompressionMode compressionModeEnum, byte[] dataByteArray, long lastModifiedUnixDateTime, long createdUnixDateTime, @@ -111,22 +110,22 @@ public class NewFullDataSourceDTO implements IBaseDTO // data source population // //========================// - public NewFullDataSource createDataSource(@NotNull ILevelWrapper levelWrapper) throws IOException, InterruptedException - { return this.populateDataSource(NewFullDataSource.createEmpty(this.pos), levelWrapper); } + public FullDataSourceV2 createDataSource(@NotNull ILevelWrapper levelWrapper) throws IOException, InterruptedException + { return this.populateDataSource(FullDataSourceV2.createEmpty(this.pos), levelWrapper); } - public NewFullDataSource populateDataSource(NewFullDataSource dataSource, @NotNull ILevelWrapper levelWrapper) throws IOException, InterruptedException + public FullDataSourceV2 populateDataSource(FullDataSourceV2 dataSource, @NotNull ILevelWrapper levelWrapper) throws IOException, InterruptedException { return this.internalPopulateDataSource(dataSource, levelWrapper, false); } /** * May be missing one or more data fields.
* Designed to be used without access to Minecraft or any supporting objects. */ - public NewFullDataSource createUnitTestDataSource() throws IOException, InterruptedException - { return this.internalPopulateDataSource(NewFullDataSource.createEmpty(this.pos), null, true); } + public FullDataSourceV2 createUnitTestDataSource() throws IOException, InterruptedException + { return this.internalPopulateDataSource(FullDataSourceV2.createEmpty(this.pos), null, true); } - private NewFullDataSource internalPopulateDataSource(NewFullDataSource dataSource, ILevelWrapper levelWrapper, boolean unitTest) throws IOException, InterruptedException + private FullDataSourceV2 internalPopulateDataSource(FullDataSourceV2 dataSource, ILevelWrapper levelWrapper, boolean unitTest) throws IOException, InterruptedException { - if (NewFullDataSource.DATA_FORMAT_VERSION != this.dataFormatVersion) + if (FullDataSourceV2.DATA_FORMAT_VERSION != this.dataFormatVersion) { throw new IllegalStateException("There should only be one data format right now anyway."); } @@ -175,7 +174,7 @@ public class NewFullDataSourceDTO implements IBaseDTO // write the data - int dataArrayLength = NewFullDataSource.WIDTH * NewFullDataSource.WIDTH; + int dataArrayLength = FullDataSourceV2.WIDTH * FullDataSourceV2.WIDTH; for (int xz = 0; xz < dataArrayLength; xz++) { long[] dataColumn = dataArray[xz]; @@ -206,7 +205,7 @@ public class NewFullDataSourceDTO implements IBaseDTO // read the data - int dataArrayLength = NewFullDataSource.WIDTH * NewFullDataSource.WIDTH; + int dataArrayLength = FullDataSourceV2.WIDTH * FullDataSourceV2.WIDTH; long[][] dataArray = new long[dataArrayLength][]; for (int xz = 0; xz < dataArray.length; xz++) { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/NewFullDataSourceRepo.java b/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/FullDataSourceV2Repo.java similarity index 93% rename from core/src/main/java/com/seibel/distanthorizons/core/sql/repo/NewFullDataSourceRepo.java rename to core/src/main/java/com/seibel/distanthorizons/core/sql/repo/FullDataSourceV2Repo.java index 410c5a3e4..ebfa1240d 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/NewFullDataSourceRepo.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/sql/repo/FullDataSourceV2Repo.java @@ -21,7 +21,7 @@ package com.seibel.distanthorizons.core.sql.repo; import com.seibel.distanthorizons.api.enums.config.EDhApiDataCompressionMode; import com.seibel.distanthorizons.core.pos.DhSectionPos; -import com.seibel.distanthorizons.core.sql.dto.NewFullDataSourceDTO; +import com.seibel.distanthorizons.core.sql.dto.FullDataSourceV2DTO; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -29,11 +29,11 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -public class NewFullDataSourceRepo extends AbstractDhRepo +public class FullDataSourceV2Repo extends AbstractDhRepo { - public NewFullDataSourceRepo(String databaseType, String databaseLocation) throws SQLException + public FullDataSourceV2Repo(String databaseType, String databaseLocation) throws SQLException { - super(databaseType, databaseLocation, NewFullDataSourceDTO.class); + super(databaseType, databaseLocation, FullDataSourceV2DTO.class); } @@ -55,7 +55,7 @@ public class NewFullDataSourceRepo extends AbstractDhRepo objectMap) throws ClassCastException + public FullDataSourceV2DTO convertDictionaryToDto(Map objectMap) throws ClassCastException { byte detailLevel = (Byte) objectMap.get("DetailLevel"); byte sectionDetailLevel = (byte) (detailLevel + DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL); @@ -80,7 +80,7 @@ public class NewFullDataSourceRepo extends AbstractDhRepo * * @see FullDataSourceV1 - * @see FullDataPointUtil + * @see FullDataPointUtilV2 */ public class FullDataPointUtilV1 { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtil.java b/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV2.java similarity index 99% rename from core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtil.java rename to core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV2.java index 1e1ebfc49..0d9540567 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtil.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/FullDataPointUtilV2.java @@ -49,7 +49,7 @@ import org.jetbrains.annotations.Contract; * @see RenderDataPointUtil * @see FullDataPointUtilV1 */ -public class FullDataPointUtil +public class FullDataPointUtilV2 { /** Represents the data held by an empty data point */ public static final int EMPTY_DATA_POINT = 0; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/RenderDataPointUtil.java b/core/src/main/java/com/seibel/distanthorizons/core/util/RenderDataPointUtil.java index 240a0b4aa..316255595 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/RenderDataPointUtil.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/RenderDataPointUtil.java @@ -29,7 +29,7 @@ import com.seibel.distanthorizons.core.dataObjects.render.columnViews.IColumnDat * A helper class that is used to access the data from a long * formatted as a render data point.

* - * To access data from a long formatted as a full data point see: {@link FullDataPointUtil} + * To access data from a long formatted as a full data point see: {@link FullDataPointUtilV2} * * DataPoint Format:
* @@ -55,7 +55,7 @@ import com.seibel.distanthorizons.core.dataObjects.render.columnViews.IColumnDat * BL BL BL BL SL SL SL SL |
*
* - * @see FullDataPointUtil + * @see FullDataPointUtilV2 */ public class RenderDataPointUtil { diff --git a/core/src/main/resources/sqlScripts/0020-sqlite-createGeneratedFullDataSourceTables.sql b/core/src/main/resources/sqlScripts/0020-sqlite-createFullDataSourceV2Tables.sql similarity index 100% rename from core/src/main/resources/sqlScripts/0020-sqlite-createGeneratedFullDataSourceTables.sql rename to core/src/main/resources/sqlScripts/0020-sqlite-createFullDataSourceV2Tables.sql diff --git a/core/src/main/resources/sqlScripts/scriptList.txt b/core/src/main/resources/sqlScripts/scriptList.txt index 2a2f2e905..b41618ae7 100644 --- a/core/src/main/resources/sqlScripts/scriptList.txt +++ b/core/src/main/resources/sqlScripts/scriptList.txt @@ -1,3 +1,3 @@ 0010-sqlite-createInitialDataTables.sql -0020-sqlite-createGeneratedFullDataSourceTables.sql +0020-sqlite-createFullDataSourceV2Tables.sql diff --git a/core/src/test/java/tests/CompressionTest.java b/core/src/test/java/tests/CompressionTest.java index 228c6bc92..68319522c 100644 --- a/core/src/test/java/tests/CompressionTest.java +++ b/core/src/test/java/tests/CompressionTest.java @@ -20,10 +20,10 @@ package tests; import com.seibel.distanthorizons.api.enums.config.EDhApiDataCompressionMode; -import com.seibel.distanthorizons.core.dataObjects.fullData.sources.NewFullDataSource; +import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; import com.seibel.distanthorizons.core.pos.DhSectionPos; -import com.seibel.distanthorizons.core.sql.dto.NewFullDataSourceDTO; -import com.seibel.distanthorizons.core.sql.repo.NewFullDataSourceRepo; +import com.seibel.distanthorizons.core.sql.dto.FullDataSourceV2DTO; +import com.seibel.distanthorizons.core.sql.repo.FullDataSourceV2Repo; import org.junit.Assert; import java.io.*; @@ -155,7 +155,7 @@ public class CompressionTest // byte[] dictionary; // { // String uncompressedDatabaseFilePath = TEST_DIR + "/" + UNCOMPRESSED_DB_FILE_NAME; - // NewFullDataSourceRepo uncompressedRepo = new NewFullDataSourceRepo("jdbc:sqlite", uncompressedDatabaseFilePath); + // FullDataSourceV2Repo uncompressedRepo = new FullDataSourceV2Repo("jdbc:sqlite", uncompressedDatabaseFilePath); // ArrayList positionList = uncompressedRepo.getAllPositions(); // // // sample size of 10 MB or less @@ -165,7 +165,7 @@ public class CompressionTest // for (int i = 0; i < positionList.size(); i++) // { // DhSectionPos pos = positionList.get(i); - // NewFullDataSourceDTO uncompressedDto = uncompressedRepo.getByKey(pos); + // FullDataSourceV2DTO uncompressedDto = uncompressedRepo.getByKey(pos); // // dictTrainer.addSample(uncompressedDto.dataByteArray); // } @@ -260,7 +260,7 @@ public class CompressionTest File uncompressedDatabaseFile = new File(uncompressedDatabaseFilePath); Assert.assertTrue(uncompressedDatabaseFile.exists()); - NewFullDataSourceRepo uncompressedRepo = new NewFullDataSourceRepo("jdbc:sqlite", uncompressedDatabaseFilePath); + FullDataSourceV2Repo uncompressedRepo = new FullDataSourceV2Repo("jdbc:sqlite", uncompressedDatabaseFilePath); String compressedDatabaseFilePath = TEST_DIR + "/output/" + DB_FILE_NAME_PREFIX + "_" + compressorName + ".sqlite"; @@ -268,7 +268,7 @@ public class CompressionTest compressedDatabaseFile.mkdirs(); compressedDatabaseFile.delete(); Assert.assertTrue(!compressedDatabaseFile.exists()); - NewFullDataSourceRepo compressedRepo = new NewFullDataSourceRepo("jdbc:sqlite", compressedDatabaseFilePath); + FullDataSourceV2Repo compressedRepo = new FullDataSourceV2Repo("jdbc:sqlite", compressedDatabaseFilePath); @@ -292,9 +292,9 @@ public class CompressionTest // uncompressed input // - NewFullDataSourceDTO uncompressedDto = uncompressedRepo.getByKey(pos); + FullDataSourceV2DTO uncompressedDto = uncompressedRepo.getByKey(pos); Assert.assertEquals(uncompressedDto.compressionModeEnum, EDhApiDataCompressionMode.UNCOMPRESSED); - NewFullDataSource uncompressedDataSource = uncompressedDto.createUnitTestDataSource(); + FullDataSourceV2 uncompressedDataSource = uncompressedDto.createUnitTestDataSource(); long uncompressedDtoSize = uncompressedRepo.getDataSizeInBytes(pos); minUncompressedDtoSizeInBytes = Math.min(uncompressedDtoSize, minUncompressedDtoSizeInBytes); @@ -307,7 +307,7 @@ public class CompressionTest long startWriteNanoTime = System.nanoTime(); - NewFullDataSourceDTO compressedDto = NewFullDataSourceDTO.CreateFromDataSource(uncompressedDataSource, compressionMode); + FullDataSourceV2DTO compressedDto = FullDataSourceV2DTO.CreateFromDataSource(uncompressedDataSource, compressionMode); compressedRepo.save(compressedDto); long endWriteNanoTime = System.nanoTime(); @@ -326,7 +326,7 @@ public class CompressionTest long startReadNanoTime = System.nanoTime(); compressedDto = compressedRepo.getByKey(pos); - NewFullDataSource compressedDataSource = compressedDto.createUnitTestDataSource(); + FullDataSourceV2 compressedDataSource = compressedDto.createUnitTestDataSource(); long endReadMsTime = System.nanoTime(); totalReadTimeInNano += (endReadMsTime - startReadNanoTime);