diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java index 00d4d4175..2735e76a5 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java @@ -90,12 +90,14 @@ public class FullDataSourceV2 implements IDataSource /** * stores how far each column has been generated should start with {@link EDhApiWorldGenerationStep#EMPTY} - * @see EDhApiWorldGenerationStep + * + * @see EDhApiWorldGenerationStep */ public byte[] columnGenerationSteps; /** * stores what world compression was used for each column. - * @see EDhApiWorldCompressionMode + * + * @see EDhApiWorldCompressionMode */ public byte[] columnWorldCompressionMode; @@ -379,7 +381,7 @@ public class FullDataSourceV2 implements IDataSource for (int x = 0; x < WIDTH; x += 2) { for (int z = 0; z < WIDTH; z += 2) - { + { int recipientX = (x / 2) + recipientOffsetX; int recipientZ = (z / 2) + recipientOffsetZ; int recipientIndex = relativePosToIndex(recipientX, recipientZ); @@ -612,7 +614,7 @@ public class FullDataSourceV2 implements IDataSource int id = determineMostValueInColumnSlice(mergeIds, inputDataSource.mapping); byte blockLight = (byte) determineAverageValueInColumnSlice(mergeBlockLights); byte skyLight = (byte) determineAverageValueInColumnSlice(mergeSkyLights); - + // if this slice is different then the last one, create a new one if (id != lastId // block and sky light might not be necessary @@ -698,7 +700,7 @@ public class FullDataSourceV2 implements IDataSource { LodUtil.assertTrue(sliceArray.length == 4, "Column Slice should only contain 4 values."); } - + int value0 = sliceArray[0]; int count0 = 0; int value1 = sliceArray[1]; @@ -719,26 +721,42 @@ public class FullDataSourceV2 implements IDataSource } if (value == value0) + { count0++; + } else if (value == value1) + { count1++; + } else if (value == value2) + { count2++; + } else + { count3++; + } } // return the most common occurance int maxCount = Math.max(count0, Math.max(count1, Math.max(count2, count3))); if (maxCount == count0) - // if the max count is 1 then we'll just go with the first column + // if the max count is 1 then we'll just go with the first column + { return value0; + } else if (maxCount == count1) + { return value1; + } else if (maxCount == count2) + { return value2; - else + } + else + { return value3; + } } private static int determineAverageValueInColumnSlice(int[] sliceArray) { @@ -876,8 +894,8 @@ public class FullDataSourceV2 implements IDataSource { int index = relativePosToIndex(relX, relZ); this.dataPoints[index] = longArray; - this.columnGenerationSteps[index] = worldGenStep.value; - this.columnWorldCompressionMode[index] = worldCompressionMode.value; + this.columnGenerationSteps[index] = worldGenStep.value; + this.columnWorldCompressionMode[index] = worldCompressionMode.value; if (RUN_UPDATE_DEV_VALIDATION) @@ -942,7 +960,7 @@ public class FullDataSourceV2 implements IDataSource // the positions are the same, use the hash as a quick method // to determine if the data inside is the same. // Note: this isn't perfect, but should work well enough for our use case. - return other.hashCode() == this.hashCode(); + return other.hashCode() == this.hashCode(); } } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractDataSourceHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractDataSourceHandler.java index 5b425a72f..0754e0dcd 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractDataSourceHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractDataSourceHandler.java @@ -46,7 +46,7 @@ public abstract class AbstractDataSourceHandler * The lowest numerical detail level possible. * * @see AbstractDataSourceHandler#TOP_SECTION_DETAIL_LEVEL - * */ + */ public static final byte MIN_SECTION_DETAIL_LEVEL = DhSectionPos.SECTION_MINIMUM_DETAIL_LEVEL; @@ -223,7 +223,8 @@ public abstract class AbstractDataSourceHandler /** * After this method returns the inputData will be written to file. - * @param updatePos the position to update + * + * @param updatePos the position to update */ protected void updateDataSourceAtPos(long updatePos, @NotNull FullDataSourceV2 inputData, boolean lockOnUpdatePos) { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java index a4ff3cbb0..af105b2e5 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java @@ -289,7 +289,8 @@ public class FullDataSourceProviderV2 } }); } - catch (RejectedExecutionException ignore) { /* the executor was shut down, it should be back up shortly and able to accept new jobs */ } + catch (RejectedExecutionException ignore) + { /* the executor was shut down, it should be back up shortly and able to accept new jobs */ } catch (Exception e) { this.parentUpdatingPosSet.remove(parentUpdatePos); @@ -299,7 +300,10 @@ public class FullDataSourceProviderV2 } } - catch (InterruptedException ignored) { Thread.currentThread().interrupt(); } + catch (InterruptedException ignored) + { + Thread.currentThread().interrupt(); + } catch (Exception e) { LOGGER.error("Unexpected error in the parent update queue thread. Error: " + e.getMessage(), e); @@ -339,7 +343,7 @@ public class FullDataSourceProviderV2 LOGGER.info("deleting [" + dimensionName + "] - ["+totalDeleteCount+"] unused data sources..."); this.legacyDeletionCount = totalDeleteCount; - + ArrayList unusedDataPosList = this.legacyFileHandler.repo.getUnusedDataSourcePositionStringList(50); while (unusedDataPosList.size() != 0) { @@ -368,8 +372,8 @@ public class FullDataSourceProviderV2 } catch (InterruptedException ignore){} } - LOGGER.info("Done deleting [" + dimensionName + "] - ["+totalDeleteCount+"] unused data sources."); + } @@ -553,8 +557,8 @@ public class FullDataSourceProviderV2 * return false;
* }
* - * to the beginning of your override. - * Otherwise, parent retrieval limits will be ignored. + * to the beginning of your override. + * Otherwise, parent retrieval limits will be ignored. */ public boolean canQueueRetrieval() { @@ -569,13 +573,13 @@ public class FullDataSourceProviderV2 * an empty array if all positions were generated */ @Nullable - public LongArrayList getPositionsToRetrieve(Long pos) { return null; } + public LongArrayList getPositionsToRetrieve(Long pos) { return null; } /** * Returns how many positions could potentially be generated for this position assuming the position is empty. * Used when estimating the total number of retrieval requests. */ - public int getMaxPossibleRetrievalPositionCountForPos(Long pos) { return -1; } - + public int getMaxPossibleRetrievalPositionCountForPos(Long pos) { return -1; } + /** @return true if the position was queued, false if not */ public boolean queuePositionForRetrieval(Long genPos) { return false; } @@ -585,7 +589,7 @@ public class FullDataSourceProviderV2 public void clearRetrievalQueue() { } /** Can be used to display how many total retrieval requests might be available. */ - public void setTotalRetrievalPositionCount(int newCount) { } + public void setTotalRetrievalPositionCount(int newCount) { } /** * Returns how many data sources are currently in memory and haven't diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataSourceProvider.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataSourceProvider.java index be7b14207..e970295c9 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataSourceProvider.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/GeneratedFullDataSourceProvider.java @@ -393,6 +393,7 @@ public class GeneratedFullDataSourceProvider extends FullDataSourceProviderV2 im GeneratedFullDataSourceProvider.this.delayedFullDataSourceSaveCache.queueDataSourceForUpdateAndSave(chunkSizedFullDataSource); }; } + } private void onDataSourceSave(FullDataSourceV2 fullDataSource) { 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 d0eecf2ea..b37cff85a 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 @@ -21,6 +21,7 @@ package com.seibel.distanthorizons.core.generation.tasks; import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2; +import javax.annotation.Nullable; import java.util.function.Consumer; /** @@ -32,6 +33,7 @@ public interface IWorldGenTaskTracker /** Returns true if the task hasn't been garbage collected. */ boolean isMemoryAddressValid(); + @Nullable Consumer getChunkDataConsumer(); } 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 0bccd9ecf..6a96b0926 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 @@ -157,9 +157,9 @@ public class DhClientServerLevel extends AbstractDhLevel implements IDhClientLev public void clearRenderCache() { this.clientside.clearRenderCache(); } @Override - public IServerLevelWrapper getServerLevelWrapper() { return serverLevelWrapper; } + public IServerLevelWrapper getServerLevelWrapper() { return this.serverLevelWrapper; } @Override - public ILevelWrapper getLevelWrapper() { return getServerLevelWrapper(); } + public ILevelWrapper getLevelWrapper() { return this.getServerLevelWrapper(); } @Override public FullDataSourceProviderV2 getFullDataProvider() { return this.serverside.fullDataFileHandler; } @@ -167,7 +167,7 @@ public class DhClientServerLevel extends AbstractDhLevel implements IDhClientLev @Override public AbstractSaveStructure getSaveStructure() { - return serverside.saveStructure; + return this.serverside.saveStructure; } @Override diff --git a/core/src/main/java/com/seibel/distanthorizons/core/world/DhClientWorld.java b/core/src/main/java/com/seibel/distanthorizons/core/world/DhClientWorld.java index a008eed7a..d9f752454 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/world/DhClientWorld.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/world/DhClientWorld.java @@ -156,10 +156,7 @@ public class DhClientWorld extends AbstractDhWorld implements IDhClientWorld } } - private void _clientTick() - { - this.levels.values().forEach(DhClientLevel::clientTick); - } + private void _clientTick() { this.levels.values().forEach(DhClientLevel::clientTick); } public void clientTick() { this.eventLoop.tick(); }