From 707c55653ab3cb97b44df577c3991eb96bc028ef Mon Sep 17 00:00:00 2001 From: cola98765 Date: Wed, 13 Oct 2021 12:01:56 +0200 Subject: [PATCH 1/7] removed single level container --- .../com/seibel/lod/objects/LodRegion.java | 2 +- .../lod/objects/SingleLevelContainer.java | 236 ------------------ 2 files changed, 1 insertion(+), 237 deletions(-) delete mode 100644 src/main/java/com/seibel/lod/objects/SingleLevelContainer.java diff --git a/src/main/java/com/seibel/lod/objects/LodRegion.java b/src/main/java/com/seibel/lod/objects/LodRegion.java index 94ac415d2..358a39d2c 100644 --- a/src/main/java/com/seibel/lod/objects/LodRegion.java +++ b/src/main/java/com/seibel/lod/objects/LodRegion.java @@ -500,7 +500,7 @@ public class LodRegion for (byte detailLevelIndex = (byte) (minDetailLevel - 1); detailLevelIndex >= detailLevel; detailLevelIndex--) { if (dataContainer[detailLevelIndex + 1] == null) - dataContainer[detailLevelIndex + 1] = new SingleLevelContainer((byte) (detailLevelIndex + 1)); + dataContainer[detailLevelIndex + 1] = new VerticalLevelContainer((byte) (detailLevelIndex + 1)); dataContainer[detailLevelIndex] = dataContainer[detailLevelIndex + 1].expand(); } diff --git a/src/main/java/com/seibel/lod/objects/SingleLevelContainer.java b/src/main/java/com/seibel/lod/objects/SingleLevelContainer.java deleted file mode 100644 index 4da2d1b54..000000000 --- a/src/main/java/com/seibel/lod/objects/SingleLevelContainer.java +++ /dev/null @@ -1,236 +0,0 @@ -package com.seibel.lod.objects; - -import com.seibel.lod.util.DataPointUtil; -import com.seibel.lod.util.LevelPosUtil; -import com.seibel.lod.util.LodUtil; -import com.seibel.lod.util.ThreadMapUtil; - -import java.util.Arrays; - -/** - * This object holds the LOD data for a single dataPoint. - * - * @author Leonardo Amato - * @version 9-28-2021 - */ -public class SingleLevelContainer implements LevelContainer -{ - /** The detailLevel of this LevelContainer */ - public final byte detailLevel; - /** How many dataPoints wide is this LevelContainer? */ - public final int dataWidthCount; - - /** This holds all the dataPoints for this LevelContainer */ - public final long[][] dataContainer; - - - - /** Constructor */ - public SingleLevelContainer(byte newDetailLevel) - { - this.detailLevel = newDetailLevel; - - // equivalent to 2^(...) - dataWidthCount = 1 << (LodUtil.REGION_DETAIL_LEVEL - newDetailLevel); - dataContainer = new long[dataWidthCount][dataWidthCount]; - } - - /** */ - public SingleLevelContainer(byte[] inputData) - { - int tempIndex; - int index = 0; - long newData; - detailLevel = inputData[index]; - index++; - dataWidthCount = (int) Math.pow(2, LodUtil.REGION_DETAIL_LEVEL - detailLevel); - this.dataContainer = new long[dataWidthCount][dataWidthCount]; - - for (int x = 0; x < dataWidthCount; x++) - { - for (int z = 0; z < dataWidthCount; z++) - { - newData = 0; - if (inputData[index] == 0) - { - index++; - } - else if (inputData[index] == 3) - { - newData = 3; - index++; - } - else if (index + 7 >= inputData.length) - { - break; - } - else - { - for (tempIndex = 0; tempIndex < 8; tempIndex++) - newData += (((long) inputData[index + tempIndex]) & 0xff) << (8 * tempIndex); - index = index + 8; - } - - dataContainer[x][z] = newData; - } - } - } - - - - - - @Override - public void clear(int posX, int posZ) - { - posX = LevelPosUtil.getRegionModule(detailLevel, posX); - posZ = LevelPosUtil.getRegionModule(detailLevel, posZ); - dataContainer[posX][posZ] = DataPointUtil.EMPTY_DATA; - } - - @Override - public boolean addData(long data, int posX, int posZ, int index) - { - posX = LevelPosUtil.getRegionModule(detailLevel, posX); - posZ = LevelPosUtil.getRegionModule(detailLevel, posZ); - dataContainer[posX][posZ] = data; - return true; - } - - @Override - public boolean addSingleData(long newData, int posX, int posZ) - { - posX = LevelPosUtil.getRegionModule(detailLevel, posX); - posZ = LevelPosUtil.getRegionModule(detailLevel, posZ); - dataContainer[posX][posZ] = newData; - return true; - } - - @Override - public long getData(int posX, int posZ, int index) - { - posX = LevelPosUtil.getRegionModule(detailLevel, posX); - posZ = LevelPosUtil.getRegionModule(detailLevel, posZ); - /* TODO Improve this using a thread map to long[] - * actually single level stuff is already kinda deprecated - cola*/ - - return dataContainer[posX][posZ]; - } - - @Override - public long getSingleData(int posX, int posZ) - { - posX = LevelPosUtil.getRegionModule(detailLevel, posX); - posZ = LevelPosUtil.getRegionModule(detailLevel, posZ); - /* TODO Improve this using a thread map to long[] - * actually single level stuff is already kinda deprecated - cola*/ - return dataContainer[posX][posZ]; - } - - @Override - public byte getDetailLevel() - { - return detailLevel; - } - - @Override - public LevelContainer expand() - { - return new SingleLevelContainer((byte) (getDetailLevel() - 1)); - } - - - - /** TODO could this be renamed mergeData? */ - @Override - public void updateData(LevelContainer lowerLevelContainer, int posX, int posZ) - { - //We reset the array - long[] dataToMerge = ThreadMapUtil.getSingleUpdateArray(); - - int childPosX; - int childPosZ; - long data; - posX = LevelPosUtil.getRegionModule(detailLevel, posX); - posZ = LevelPosUtil.getRegionModule(detailLevel, posZ); - for (int x = 0; x <= 1; x++) - { - for (int z = 0; z <= 1; z++) - { - childPosX = 2 * posX + x; - childPosZ = 2 * posZ + z; - dataToMerge[2 * x + z] = lowerLevelContainer.getSingleData(childPosX, childPosZ); - } - } - data = DataPointUtil.mergeSingleData(dataToMerge); - addSingleData(data, posX, posZ); - } - - @Override - public int getMaxVerticalData() - { - return 1; - } - - @Override - public boolean doesItExist(int posX, int posZ) - { - posX = LevelPosUtil.getRegionModule(detailLevel, posX); - posZ = LevelPosUtil.getRegionModule(detailLevel, posZ); - //Improve this using a thread map to long[] - return DataPointUtil.doesItExist(getSingleData(posX, posZ)); - } - - @Override - public byte[] toDataString() - { - int index = 0; - int tempIndex; - byte[] tempData = ThreadMapUtil.getSaveContainer(1 + (dataWidthCount * dataWidthCount * 8)); - - tempData[index] = detailLevel; - index++; - for (int x = 0; x < dataWidthCount; x++) - { - for (int z = 0; z < dataWidthCount; z++) - { - if (dataContainer[x][z] == 0) - { - tempData[index] = 0; - index++; - } - else if (dataContainer[x][z] == 3) - { - tempData[index] = 3; - index++; - } - else - { - for (tempIndex = 0; tempIndex < 8; tempIndex++) - tempData[index + tempIndex] = (byte) (dataContainer[x][z] >>> (8 * tempIndex)); - index += 8; - } - } - } - return Arrays.copyOfRange(tempData, 0, index); - } - - @Override - public String toString() - { - return String.valueOf(detailLevel); - } - - - @Override - public int getMaxNumberOfLods() - { - return dataWidthCount * dataWidthCount * getMaxVerticalData(); - } - - @Override - public int getMaxMemoryUse() - { - return getMaxNumberOfLods() * 2; //2 byte - } -} From c7dbc28a9a10c07686af65d853ea229554e42878 Mon Sep 17 00:00:00 2001 From: cola98765 Date: Wed, 13 Oct 2021 12:08:47 +0200 Subject: [PATCH 2/7] cleaned out some code --- .../bufferBuilding/lodTemplates/Box.java | 14 +--- .../com/seibel/lod/enums/FogDistance.java | 2 +- .../com/seibel/lod/enums/FogDrawOverride.java | 2 +- .../java/com/seibel/lod/enums/FogQuality.java | 2 +- .../seibel/lod/enums/GenerationPriority.java | 2 +- .../lod/enums/HorizontalResolution.java | 2 +- .../com/seibel/lod/enums/LodTemplate.java | 2 +- .../com/seibel/lod/enums/ShadingMode.java | 2 +- .../com/seibel/lod/proxy/ClientProxy.java | 7 +- .../com/seibel/lod/util/DataPointUtil.java | 65 ------------------- 10 files changed, 10 insertions(+), 90 deletions(-) diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/Box.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/Box.java index 6639a7074..4bc4eadd6 100644 --- a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/Box.java +++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/Box.java @@ -398,12 +398,7 @@ public class Box } } - /** - * We use this method to set the various width of the column - * @param xWidth - * @param yWidth - * @param zWidth - */ + /** We use this method to set the various width of the column */ public void setWidth(int xWidth, int yWidth, int zWidth) { boxWidth[X] = xWidth; @@ -411,12 +406,7 @@ public class Box boxWidth[Z] = zWidth; } - /** - * We use this method to set the various offset of the column - * @param xOffset - * @param yOffset - * @param zOffset - */ + /** We use this method to set the various offset of the column */ public void setOffset(int xOffset, int yOffset, int zOffset) { boxOffset[X] = xOffset; diff --git a/src/main/java/com/seibel/lod/enums/FogDistance.java b/src/main/java/com/seibel/lod/enums/FogDistance.java index 25b697997..96baf7b72 100644 --- a/src/main/java/com/seibel/lod/enums/FogDistance.java +++ b/src/main/java/com/seibel/lod/enums/FogDistance.java @@ -32,5 +32,5 @@ public enum FogDistance FAR, /** only looks good if the fog quality is set to Fancy. */ - NEAR_AND_FAR; + NEAR_AND_FAR } \ No newline at end of file diff --git a/src/main/java/com/seibel/lod/enums/FogDrawOverride.java b/src/main/java/com/seibel/lod/enums/FogDrawOverride.java index 8199e85fc..405311f42 100644 --- a/src/main/java/com/seibel/lod/enums/FogDrawOverride.java +++ b/src/main/java/com/seibel/lod/enums/FogDrawOverride.java @@ -39,5 +39,5 @@ public enum FogDrawOverride ALWAYS_DRAW_FOG_FAST, /** Always draw fog on the LODs */ - ALWAYS_DRAW_FOG_FANCY; + ALWAYS_DRAW_FOG_FANCY } \ No newline at end of file diff --git a/src/main/java/com/seibel/lod/enums/FogQuality.java b/src/main/java/com/seibel/lod/enums/FogQuality.java index ec2bf69a8..641117066 100644 --- a/src/main/java/com/seibel/lod/enums/FogQuality.java +++ b/src/main/java/com/seibel/lod/enums/FogQuality.java @@ -27,5 +27,5 @@ public enum FogQuality { FAST, FANCY, - OFF; + OFF } diff --git a/src/main/java/com/seibel/lod/enums/GenerationPriority.java b/src/main/java/com/seibel/lod/enums/GenerationPriority.java index 2e5b0a0fc..4968c5037 100644 --- a/src/main/java/com/seibel/lod/enums/GenerationPriority.java +++ b/src/main/java/com/seibel/lod/enums/GenerationPriority.java @@ -31,5 +31,5 @@ public enum GenerationPriority { NEAR_FIRST, - FAR_FIRST; + FAR_FIRST } diff --git a/src/main/java/com/seibel/lod/enums/HorizontalResolution.java b/src/main/java/com/seibel/lod/enums/HorizontalResolution.java index 8382993cf..e1bb023dc 100644 --- a/src/main/java/com/seibel/lod/enums/HorizontalResolution.java +++ b/src/main/java/com/seibel/lod/enums/HorizontalResolution.java @@ -80,7 +80,7 @@ public enum HorizontalResolution - private HorizontalResolution(int newLengthCount, int newDetailLevel) + HorizontalResolution(int newLengthCount, int newDetailLevel) { detailLevel = (byte) newDetailLevel; dataPointLengthCount = newLengthCount; diff --git a/src/main/java/com/seibel/lod/enums/LodTemplate.java b/src/main/java/com/seibel/lod/enums/LodTemplate.java index f62a0ddff..e82758d4a 100644 --- a/src/main/java/com/seibel/lod/enums/LodTemplate.java +++ b/src/main/java/com/seibel/lod/enums/LodTemplate.java @@ -46,7 +46,7 @@ public enum LodTemplate public final AbstractLodTemplate template; - private LodTemplate(AbstractLodTemplate newTemplate) + LodTemplate(AbstractLodTemplate newTemplate) { template = newTemplate; } diff --git a/src/main/java/com/seibel/lod/enums/ShadingMode.java b/src/main/java/com/seibel/lod/enums/ShadingMode.java index f6dc94791..17fce842f 100644 --- a/src/main/java/com/seibel/lod/enums/ShadingMode.java +++ b/src/main/java/com/seibel/lod/enums/ShadingMode.java @@ -18,5 +18,5 @@ public enum ShadingMode * LODs will have darker sides and bottoms to simulate * Minecraft's fast, top down lighting. */ - GAME_SHADING; + GAME_SHADING } \ No newline at end of file diff --git a/src/main/java/com/seibel/lod/proxy/ClientProxy.java b/src/main/java/com/seibel/lod/proxy/ClientProxy.java index 9ac7188eb..d4728ee01 100644 --- a/src/main/java/com/seibel/lod/proxy/ClientProxy.java +++ b/src/main/java/com/seibel/lod/proxy/ClientProxy.java @@ -97,12 +97,7 @@ public class ClientProxy // render event // //==============// - /** - * Do any setup that is required to draw LODs - * and then tell the LodRenderer to draw. - * - * @param mcMatrixStack - */ + /** Do any setup that is required to draw LODs and then tell the LodRenderer to draw. */ public void renderLods(MatrixStack mcMatrixStack, float partialTicks) { // comment out when creating a release diff --git a/src/main/java/com/seibel/lod/util/DataPointUtil.java b/src/main/java/com/seibel/lod/util/DataPointUtil.java index c0d360736..d474306b7 100644 --- a/src/main/java/com/seibel/lod/util/DataPointUtil.java +++ b/src/main/java/com/seibel/lod/util/DataPointUtil.java @@ -202,71 +202,6 @@ public class DataPointUtil isVoid(dataPoint) + " " + doesItExist(dataPoint) + '\n'; } - - /** - * This method merge column of single data together - * @deprecated - */ - public static long mergeSingleData(long[] dataToMerge) - { - int numberOfChildren = 0; - - int tempAlpha = 0; - int tempRed = 0; - int tempGreen = 0; - int tempBlue = 0; - int tempHeight = Integer.MIN_VALUE; - int tempDepth = Integer.MAX_VALUE; - int tempLightBlock = 0; - int tempLightSky = 0; - byte tempGenMode = DistanceGenerationMode.SERVER.complexity; - boolean allEmpty = true; - boolean allVoid = true; - for (long data : dataToMerge) - { - if (DataPointUtil.doesItExist(data)) - { - allEmpty = false; - if (!(DataPointUtil.isVoid(data))) - { - numberOfChildren++; - allVoid = false; - tempAlpha += DataPointUtil.getAlpha(data); - tempRed += DataPointUtil.getRed(data); - tempGreen += DataPointUtil.getGreen(data); - tempBlue += DataPointUtil.getBlue(data); - tempHeight = Math.max(tempHeight, DataPointUtil.getHeight(data)); - tempDepth = Math.min(tempDepth, DataPointUtil.getDepth(data)); - tempLightBlock += DataPointUtil.getLightBlock(data); - tempLightSky += DataPointUtil.getLightSky(data); - } - tempGenMode = (byte) Math.min(tempGenMode, DataPointUtil.getGenerationMode(data)); - } else - { - tempGenMode = (byte) Math.min(tempGenMode, DistanceGenerationMode.NONE.complexity); - } - } - - if (allEmpty) - { - //no child has been initialized - return DataPointUtil.EMPTY_DATA; - } else if (allVoid) - { - //all the children are void - return DataPointUtil.createVoidDataPoint(tempGenMode); - } else - { - //we have at least 1 child - tempAlpha = tempAlpha / numberOfChildren; - tempRed = tempRed / numberOfChildren; - tempGreen = tempGreen / numberOfChildren; - tempBlue = tempBlue / numberOfChildren; - tempLightBlock = tempLightBlock / numberOfChildren; - tempLightSky = tempLightSky / numberOfChildren; - return DataPointUtil.createDataPoint(tempAlpha, tempRed, tempGreen, tempBlue, tempHeight, tempDepth, tempLightSky, tempLightBlock, tempGenMode); - } - } public static void shrinkArray(short[] array, int packetSize, int start, int length, int arraySize) { From 4baa649972689fb5624ceca7485221cb16848adc Mon Sep 17 00:00:00 2001 From: cola98765 Date: Wed, 13 Oct 2021 12:45:21 +0200 Subject: [PATCH 3/7] cleaned out some code. Applied autoformat everywhere --- _IDE files/intellij Auto Formatting V1.xml | 50 ++++++ src/main/java/com/seibel/lod/LodMain.java | 49 +++--- src/main/java/com/seibel/lod/ModInfo.java | 4 +- .../bufferBuilding/LodBufferBuilder.java | 85 +++++----- .../lodTemplates/AbstractLodTemplate.java | 6 +- .../bufferBuilding/lodTemplates/Box.java | 10 +- .../lodTemplates/CubicLodTemplate.java | 6 +- .../lodTemplates/DynamicLodTemplate.java | 6 +- .../lodTemplates/TriangularLodTemplate.java | 6 +- .../lod/builders/lodBuilding/LodBuilder.java | 100 ++++-------- .../lodBuilding/LodBuilderConfig.java | 13 +- .../worldGeneration/LodNodeGenWorker.java | 17 +- .../worldGeneration/LodServerWorld.java | 149 +++++++++--------- .../worldGeneration/LodWorldGenerator.java | 41 +++-- .../java/com/seibel/lod/config/LodConfig.java | 27 +--- .../seibel/lod/enums/BufferRebuildTimes.java | 10 +- .../java/com/seibel/lod/enums/DebugMode.java | 5 +- .../com/seibel/lod/enums/DetailDropOff.java | 4 +- .../lod/enums/DistanceGenerationMode.java | 18 +-- .../com/seibel/lod/enums/FogDistance.java | 2 +- .../com/seibel/lod/enums/FogDrawOverride.java | 8 +- .../java/com/seibel/lod/enums/FogQuality.java | 2 +- .../seibel/lod/enums/GenerationPriority.java | 2 +- .../com/seibel/lod/enums/GlProxyContext.java | 3 +- .../seibel/lod/enums/HorizontalQuality.java | 12 +- .../lod/enums/HorizontalResolution.java | 40 ++--- .../com/seibel/lod/enums/HorizontalScale.java | 2 +- .../com/seibel/lod/enums/LodTemplate.java | 20 ++- .../com/seibel/lod/enums/ShadingMode.java | 3 +- .../com/seibel/lod/enums/VanillaOverdraw.java | 5 +- .../com/seibel/lod/enums/VerticalQuality.java | 14 +- .../lod/handlers/LodDimensionFileHandler.java | 21 ++- .../lod/handlers/ReflectionHandler.java | 1 - .../seibel/lod/mixin/MixinWorldRenderer.java | 1 - .../seibel/lod/objects/LevelContainer.java | 20 +-- .../com/seibel/lod/objects/LodDimension.java | 26 ++- .../com/seibel/lod/objects/LodRegion.java | 10 +- .../java/com/seibel/lod/objects/LodWorld.java | 6 +- .../lod/objects/NearFarFogSettings.java | 7 +- .../lod/objects/PosToGenerateContainer.java | 1 - .../lod/objects/PosToRenderContainer.java | 3 +- .../com/seibel/lod/objects/RegionPos.java | 7 +- .../lod/objects/VerticalLevelContainer.java | 142 +++++++++-------- .../com/seibel/lod/proxy/ClientProxy.java | 9 +- .../java/com/seibel/lod/proxy/GlProxy.java | 12 +- .../com/seibel/lod/render/LodRenderer.java | 29 ++-- .../com/seibel/lod/render/RenderUtil.java | 8 +- .../java/com/seibel/lod/util/ColorUtil.java | 31 ++-- .../com/seibel/lod/util/DataPointUtil.java | 15 +- .../com/seibel/lod/util/LodThreadFactory.java | 3 +- .../java/com/seibel/lod/util/LodUtil.java | 24 ++- .../com/seibel/lod/util/ThreadMapUtil.java | 32 +--- .../seibel/lod/wrappers/MinecraftWrapper.java | 30 ++-- 53 files changed, 547 insertions(+), 610 deletions(-) create mode 100644 _IDE files/intellij Auto Formatting V1.xml diff --git a/_IDE files/intellij Auto Formatting V1.xml b/_IDE files/intellij Auto Formatting V1.xml new file mode 100644 index 000000000..126cc559c --- /dev/null +++ b/_IDE files/intellij Auto Formatting V1.xml @@ -0,0 +1,50 @@ + + \ No newline at end of file diff --git a/src/main/java/com/seibel/lod/LodMain.java b/src/main/java/com/seibel/lod/LodMain.java index 801ca6a21..5bfe30122 100644 --- a/src/main/java/com/seibel/lod/LodMain.java +++ b/src/main/java/com/seibel/lod/LodMain.java @@ -15,11 +15,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod; import com.seibel.lod.config.LodConfig; import com.seibel.lod.proxy.ClientProxy; - import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModLoadingContext; @@ -35,7 +35,6 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; *
* If you are looking for the real start of the mod * check out the ClientProxy. - * * @author James Seibel * @version 7-3-2021 */ @@ -53,28 +52,28 @@ public class LodMain } - public LodMain() - { - // Register the methods - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::init); - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientStart); - - // Register ourselves for server and other game events we are interested in - MinecraftForge.EVENT_BUS.register(this); - } - - private void onClientStart(final FMLClientSetupEvent event) - { - client_proxy = new ClientProxy(); + public LodMain() + { + // Register the methods + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::init); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientStart); + + // Register ourselves for server and other game events we are interested in + MinecraftForge.EVENT_BUS.register(this); + } + + private void onClientStart(final FMLClientSetupEvent event) + { + client_proxy = new ClientProxy(); MinecraftForge.EVENT_BUS.register(client_proxy); - } - - - - @SubscribeEvent - public void onServerStarting(FMLServerStartingEvent event) - { - // this is called when the server starts - } - + } + + + + @SubscribeEvent + public void onServerStarting(FMLServerStartingEvent event) + { + // this is called when the server starts + } + } diff --git a/src/main/java/com/seibel/lod/ModInfo.java b/src/main/java/com/seibel/lod/ModInfo.java index 59c0a6606..5af9ef660 100644 --- a/src/main/java/com/seibel/lod/ModInfo.java +++ b/src/main/java/com/seibel/lod/ModInfo.java @@ -15,16 +15,16 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod; /** * This file is similar to mcmod.info - * * @author James Seibel * @version 08-29-2021 */ public final class ModInfo -{ +{ public static final String MODID = "lod"; public static final String MODNAME = "LOD"; public static final String MODAPI = "LodAPI"; diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java index aa8cb3008..755b0f4aa 100644 --- a/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java +++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java @@ -15,24 +15,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.builders.bufferBuilding; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.locks.ReentrantLock; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL15; -import org.lwjgl.opengl.GL15C; -import org.lwjgl.opengl.GL45; - import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.mojang.blaze3d.systems.RenderSystem; import com.seibel.lod.builders.bufferBuilding.lodTemplates.Box; @@ -45,22 +30,30 @@ import com.seibel.lod.objects.RegionPos; import com.seibel.lod.proxy.ClientProxy; import com.seibel.lod.proxy.GlProxy; import com.seibel.lod.render.LodRenderer; -import com.seibel.lod.util.DataPointUtil; -import com.seibel.lod.util.DetailDistanceUtil; -import com.seibel.lod.util.LevelPosUtil; -import com.seibel.lod.util.LodThreadFactory; -import com.seibel.lod.util.LodUtil; -import com.seibel.lod.util.ThreadMapUtil; - +import com.seibel.lod.util.*; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.vertex.VertexBuffer; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL15; +import org.lwjgl.opengl.GL15C; +import org.lwjgl.opengl.GL45; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.locks.ReentrantLock; /** * This object is used to create NearFarBuffer objects. - * * @author James Seibel * @version 10-10-2021 */ @@ -72,7 +65,7 @@ public class LodBufferBuilder public static final ExecutorService bufferBuilderThreads = Executors.newFixedThreadPool(LodConfig.CLIENT.threading.numberOfBufferBuilderThreads.get(), new ThreadFactoryBuilder().setNameFormat("Buffer-Builder-%d").build()); /** - * When uploading to a buffer that is too small, + * When uploading to a buffer that is too small, * recreate it this many times bigger than the upload payload */ public static final double BUFFER_EXPANSION_MULTIPLIER = 1.5; @@ -95,7 +88,7 @@ public class LodBufferBuilder * How many buffers there are for the given region.
* This is done because some regions may require more memory than * can be directly allocated, so we split the regions into smaller sections.
- * This keeps track of those sections. + * This keeps track of those sections. */ public volatile int[][] numberOfBuffersPerRegion; @@ -109,7 +102,7 @@ public class LodBufferBuilder /** used to debug how the buildableStorageBuffers are growing */ public int[][][] bufferPreviousCapacity; - /** + /** * This is toggled when the buffers are swapped, so we only * display the expansion log for one set of buffers */ @@ -344,9 +337,9 @@ public class LodBufferBuilder chunkZdist = LevelPosUtil.getChunkPos(detailLevel, zAdj) - playerChunkPos.z; if (posToRender.contains(detailLevel, xAdj, zAdj) && (gameChunkRenderDistance < Math.abs(chunkXdist) - || gameChunkRenderDistance < Math.abs(chunkZdist) - || !(vanillaRenderedChunks[chunkXdist + gameChunkRenderDistance + 1][chunkZdist + gameChunkRenderDistance + 1] - && (!LodUtil.isBorderChunk(vanillaRenderedChunks, chunkXdist + gameChunkRenderDistance + 1, chunkZdist + gameChunkRenderDistance + 1) || smallRenderDistance)))) + || gameChunkRenderDistance < Math.abs(chunkZdist) + || !(vanillaRenderedChunks[chunkXdist + gameChunkRenderDistance + 1][chunkZdist + gameChunkRenderDistance + 1] + && (!LodUtil.isBorderChunk(vanillaRenderedChunks, chunkXdist + gameChunkRenderDistance + 1, chunkZdist + gameChunkRenderDistance + 1) || smallRenderDistance)))) { for (int verticalIndex = 0; verticalIndex < lodDim.getMaxVerticalData(detailLevel, xAdj, zAdj); verticalIndex++) { @@ -379,7 +372,7 @@ public class LodBufferBuilder } // for pos to in list to render - // the thread executed successfully + // the thread executed successfully return true; }; @@ -412,7 +405,7 @@ public class LodBufferBuilder long buildTime = endTime - startTime; @SuppressWarnings("unused") long executeTime = executeEnd - executeStart; - + // ClientProxy.LOGGER.info("Thread Build time: " + buildTime + " ms" + '\n' + // "thread execute time: " + executeTime + " ms"); @@ -542,7 +535,7 @@ public class LodBufferBuilder // create the buffer storage (GPU memory) buildableStorageBufferIds[x][z][i] = GL45.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, buildableStorageBufferIds[x][z][i]); - GL45.glBufferStorage(GL15.GL_ARRAY_BUFFER, regionMemoryRequired, 0); // the 0 flag means to create the storage in the GPU's memory + GL45.glBufferStorage(GL15.GL_ARRAY_BUFFER, regionMemoryRequired, 0); // the 0 flag means to create the storage in the GPUs memory GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); drawableStorageBufferIds[x][z][i] = GL45.glGenBuffers(); @@ -584,9 +577,9 @@ public class LodBufferBuilder // This way we don't have to worry about what context this // was called from (if any). RenderSystem.recordRenderCall(() -> { - GL45.glDeleteBuffers(buildableId); - GL45.glDeleteBuffers(drawableId); - }); + GL45.glDeleteBuffers(buildableId); + GL45.glDeleteBuffers(drawableId); + }); } } } @@ -607,7 +600,7 @@ public class LodBufferBuilder { for (int k = 0; k < buildableVbos[i][j].length; k++) { - int buildableId; + int buildableId; int drawableId; // variables passed into a lambda expression @@ -622,14 +615,14 @@ public class LodBufferBuilder drawableId = drawableVbos[i][j][k].id; else drawableId = 0; - - + + RenderSystem.recordRenderCall(() -> { if (buildableId != 0) GL45.glDeleteBuffers(buildableId); if (drawableId != 0) GL45.glDeleteBuffers(drawableId); - }); + }); } } } @@ -701,7 +694,7 @@ public class LodBufferBuilder for (int i = 0; i < buildableBuffers[x][z].length; i++) { ByteBuffer uploadBuffer = buildableBuffers[x][z][i].popNextBuffer().getSecond(); - vboUpload(buildableVbos[x][z][i], buildableStorageBufferIds[x][z][i], uploadBuffer, x,z,i, true); + vboUpload(buildableVbos[x][z][i], buildableStorageBufferIds[x][z][i], uploadBuffer, x, z, i, true); lodDim.setRegenRegionBufferByArrayIndex(x, z, false); } } @@ -727,9 +720,9 @@ public class LodBufferBuilder /** Uploads the uploadBuffer into the VBO and then into GPU memory. */ private void vboUpload(VertexBuffer vbo, int storageBufferId, ByteBuffer uploadBuffer, - int xVboIndex, int zVboIndex, int iVboIndex, boolean allowBufferExpansion) - // x/zVboIndex are just used for the debugging console logging - // and should be removed when the logger is removed. + int xVboIndex, int zVboIndex, int iVboIndex, boolean allowBufferExpansion) + // x/zVboIndex are just used for the debugging console logging + // and should be removed when the logger is removed. { // this shouldn't happen, but just to be safe if (vbo.id != -1 && GlProxy.getInstance().getGlContext() == GlProxyContext.LOD_BUILDER) @@ -788,7 +781,7 @@ public class LodBufferBuilder else { // upload the buffer into system memory... - vboBuffer.put(uploadBuffer); + vboBuffer.put(uploadBuffer); GL15.glUnmapBuffer(GL15.GL_ARRAY_BUFFER); // ...then upload into GPU memory @@ -797,7 +790,7 @@ public class LodBufferBuilder GL45.glCopyNamedBufferSubData(vbo.id, storageBufferId, 0, 0, uploadBuffer.capacity()); } } - catch(Exception e) + catch (Exception e) { ClientProxy.LOGGER.error("vboUpload failed: " + e.getClass().getSimpleName()); e.printStackTrace(); diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/AbstractLodTemplate.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/AbstractLodTemplate.java index bb102c8b1..e9203b342 100644 --- a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/AbstractLodTemplate.java +++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/AbstractLodTemplate.java @@ -18,20 +18,18 @@ package com.seibel.lod.builders.bufferBuilding.lodTemplates; -import java.util.Map; - import com.seibel.lod.enums.DebugMode; import com.seibel.lod.util.ColorUtil; - import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import java.util.Map; + /** * This is the abstract class used to create different * BufferBuilders. - * * @author James Seibel * @version 10-10-2021 */ diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/Box.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/Box.java index 4bc4eadd6..65fc50774 100644 --- a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/Box.java +++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/Box.java @@ -16,7 +16,6 @@ import java.util.Map; /** * Similar to Minecraft's AxisAlignedBoundingBox. - * * @author Leonardo Amato * @version 10-2-2021 */ @@ -147,7 +146,9 @@ public class Box public final int[] colorMap; /** The original color (before shading) of this box */ public int color; - /** */ + /** + * + */ public final Map adjHeight; public final Map adjDepth; @@ -241,6 +242,7 @@ public class Box /** determine which faces should be culled */ public void setUpCulling(int cullingDistance, BlockPos playerPos) { + //TODO is passing playerPos needed? playerPos = MinecraftWrapper.INSTANCE.getPlayer().blockPosition(); for (Direction direction : DIRECTIONS) { @@ -439,7 +441,6 @@ public class Box /** - * * @param direction direction of the face we want to render * @param vertexIndex index of the vertex of the face (0-1-2-3) * @return position x of the relative vertex @@ -450,7 +451,6 @@ public class Box } /** - * * @param direction direction of the face we want to render * @param vertexIndex index of the vertex of the face (0-1-2-3) * @return position y of the relative vertex @@ -461,7 +461,6 @@ public class Box } /** - * * @param direction direction of the face we want to render * @param vertexIndex index of the vertex of the face (0-1-2-3) * @param adjIndex, index of the n-th culled face of this direction @@ -489,7 +488,6 @@ public class Box } /** - * * @param direction direction of the face we want to render * @param vertexIndex index of the vertex of the face (0-1-2-3) * @return position z of the relative vertex diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java index c14a941b1..15d3a1c9f 100644 --- a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java +++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java @@ -18,20 +18,18 @@ package com.seibel.lod.builders.bufferBuilding.lodTemplates; -import java.util.Map; - import com.seibel.lod.enums.DebugMode; import com.seibel.lod.util.DataPointUtil; import com.seibel.lod.util.LodUtil; - import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import java.util.Map; + /** * Builds LODs as rectangular prisms. - * * @author James Seibel * @version 10-10-2021 */ diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/DynamicLodTemplate.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/DynamicLodTemplate.java index 5afde314d..3145e1705 100644 --- a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/DynamicLodTemplate.java +++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/DynamicLodTemplate.java @@ -18,22 +18,20 @@ package com.seibel.lod.builders.bufferBuilding.lodTemplates; -import java.util.Map; - import com.seibel.lod.enums.DebugMode; import com.seibel.lod.proxy.ClientProxy; - import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import java.util.Map; + /** * TODO DynamicLodTemplate * Chunks smoothly transition between * each other, unless a neighboring chunk * is at a significantly different height. - * * @author James Seibel * @version 06-16-2021 */ diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/TriangularLodTemplate.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/TriangularLodTemplate.java index 2442cd998..c84a93dfa 100644 --- a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/TriangularLodTemplate.java +++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/TriangularLodTemplate.java @@ -18,20 +18,18 @@ package com.seibel.lod.builders.bufferBuilding.lodTemplates; -import java.util.Map; - import com.seibel.lod.enums.DebugMode; import com.seibel.lod.proxy.ClientProxy; - import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.texture.NativeImage; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import java.util.Map; + /** * TODO #21 TriangularLodTemplate * Builds each LOD chunk as a singular rectangular prism. - * * @author James Seibel * @version 06-16-2021 */ diff --git a/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java b/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java index 0d301843e..718df8af2 100644 --- a/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java +++ b/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java @@ -18,14 +18,6 @@ package com.seibel.lod.builders.lodBuilding; -import java.awt.Color; -import java.util.List; -import java.util.Random; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - import com.seibel.lod.config.LodConfig; import com.seibel.lod.enums.DistanceGenerationMode; import com.seibel.lod.enums.HorizontalResolution; @@ -33,26 +25,9 @@ import com.seibel.lod.enums.VerticalQuality; import com.seibel.lod.objects.LodDimension; import com.seibel.lod.objects.LodRegion; import com.seibel.lod.objects.LodWorld; -import com.seibel.lod.util.ColorUtil; -import com.seibel.lod.util.DataPointUtil; -import com.seibel.lod.util.DetailDistanceUtil; -import com.seibel.lod.util.LevelPosUtil; -import com.seibel.lod.util.LodThreadFactory; -import com.seibel.lod.util.LodUtil; -import com.seibel.lod.util.ThreadMapUtil; +import com.seibel.lod.util.*; import com.seibel.lod.wrappers.MinecraftWrapper; - -import net.minecraft.block.AbstractPlantBlock; -import net.minecraft.block.AbstractTopPlantBlock; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.BushBlock; -import net.minecraft.block.FlowerBlock; -import net.minecraft.block.GrassBlock; -import net.minecraft.block.IGrowable; -import net.minecraft.block.LeavesBlock; -import net.minecraft.block.TallGrassBlock; +import net.minecraft.block.*; import net.minecraft.block.material.MaterialColor; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -72,10 +47,17 @@ import net.minecraft.world.chunk.IChunk; import net.minecraft.world.gen.Heightmap; import net.minecraftforge.client.model.data.ModelDataMap; +import java.awt.*; +import java.util.List; +import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + /** * This object is in charge of creating Lod related objects. (specifically: Lod * World, Dimension, and Region objects) - * * @author Leonardo Amato * @author James Seibel * @version 10-9-2021 @@ -111,7 +93,7 @@ public class LodBuilder /** * How wide LodDimensions should be in regions
- * Is automatically set before the first frame in ClientProxy. + * Is automatically set before the first frame in ClientProxy. */ public int defaultDimensionWidthInRegions = 0; @@ -176,7 +158,6 @@ public class LodBuilder /** * Creates a LodNode for a chunk in the given world. - * * @throws IllegalArgumentException thrown if either the chunk or world is null. */ public void generateLodNodeFromChunk(LodDimension lodDim, IChunk chunk) throws IllegalArgumentException @@ -186,7 +167,6 @@ public class LodBuilder /** * Creates a LodNode for a chunk in the given world. - * * @throws IllegalArgumentException thrown if either the chunk or world is null. */ public void generateLodNodeFromChunk(LodDimension lodDim, IChunk chunk, LodBuilderConfig config) @@ -522,8 +502,8 @@ public class LodBuilder for (Direction direction : directions) { quads = mc.getModelManager().getBlockModelShaper().getBlockModel(blockState).getQuads(blockState, direction, new Random(0), dataMap); - listSize = Math.max(listSize,quads.size()); - for(BakedQuad bakedQuad : quads) + listSize = Math.max(listSize, quads.size()); + for (BakedQuad bakedQuad : quads) { isTinted |= bakedQuad.isTinted(); tintIndex = Math.max(tintIndex, bakedQuad.getTintIndex()); @@ -618,19 +598,19 @@ public class LodBuilder private boolean useGrassTint(Block block) { return block instanceof GrassBlock - || block instanceof BushBlock - || block instanceof IGrowable - || block instanceof AbstractPlantBlock - || block instanceof AbstractTopPlantBlock - || block instanceof TallGrassBlock; + || block instanceof BushBlock + || block instanceof IGrowable + || block instanceof AbstractPlantBlock + || block instanceof AbstractTopPlantBlock + || block instanceof TallGrassBlock; } /** determine if the given block should use the biome's foliage color */ private boolean useLeafTint(Block block) { return block instanceof LeavesBlock - || block == Blocks.VINE - || block == Blocks.SUGAR_CANE; + || block == Blocks.VINE + || block == Blocks.SUGAR_CANE; } /** determine if the given block should use the biome's water color */ @@ -643,7 +623,7 @@ public class LodBuilder private int getColorForBlock(IChunk chunk, BlockPos blockPos) { int blockColor; - int colorInt = 0; + int colorInt; int xRel = blockPos.getX() - chunk.getPos().getMinBlockX(); int zRel = blockPos.getZ() - chunk.getPos().getMinBlockZ(); @@ -659,8 +639,8 @@ public class LodBuilder // block special cases // TODO: this needs to be replaced by a config file of some sort if (blockState == Blocks.AIR.defaultBlockState() - || blockState == Blocks.CAVE_AIR.defaultBlockState() - || blockState == Blocks.BARRIER.defaultBlockState()) + || blockState == Blocks.CAVE_AIR.defaultBlockState() + || blockState == Blocks.BARRIER.defaultBlockState()) { return 0; } @@ -668,7 +648,7 @@ public class LodBuilder blockColor = getColorTextureForBlock(blockState, blockPos, true); //if the blockColor is 0 we reset it and don't use the faceColor - if(blockColor == 0) + if (blockColor == 0) { tintColor.remove(blockState.getBlock()); toTint.remove(blockState.getBlock()); @@ -676,8 +656,8 @@ public class LodBuilder blockColor = getColorTextureForBlock(blockState, blockPos, false); } - //if the blockColor is still 0 we use use the default materia color - if(blockColor == 0) + //if the blockColor is still 0 we use the default material color + if (blockColor == 0) { tintColor.replace(blockState.getBlock(), 0); toTint.replace(blockState.getBlock(), false); @@ -688,32 +668,22 @@ public class LodBuilder { int tintValue = 0; if (useGrassTint(blockState.getBlock())) - { // grass and green plants tintValue = biome.getGrassColor(x, z); - } else if (useWaterTint(blockState.getBlock())) - { // water tintValue = biome.getWaterColor(); - }else - { + else // leaves tintValue = biome.getFoliageColor(); - } colorInt = ColorUtil.multiplyRGBcolors(tintValue | 0xFF000000, blockColor); } else - { colorInt = blockColor; - } - //colorInt = blockColor; return colorInt; } - /** - * Returns a color int for the given biome. - */ + /** Returns a color int for the given biome. */ private int getColorForBiome(int x, int z, Biome biome) { int colorInt; @@ -776,9 +746,7 @@ public class LodBuilder public static final ConcurrentMap notFullBlock = new ConcurrentHashMap<>(); public static final ConcurrentMap smallBlock = new ConcurrentHashMap<>(); - /** - * Is the block at the given blockPos a valid LOD point? - */ + /** Is the block at the given blockPos a valid LOD point? */ private boolean isLayerValidLodPoint(IChunk chunk, BlockPos.Mutable blockPos) { BlockState blockState = chunk.getBlockState(blockPos); @@ -792,9 +760,9 @@ public class LodBuilder if (avoidSmallBlock || avoidNonFullBlock) { if (!smallBlock.containsKey(blockState.getBlock()) - || smallBlock.get(blockState.getBlock()) == null - || !notFullBlock.containsKey(blockState.getBlock()) - || notFullBlock.get(blockState.getBlock()) == null + || smallBlock.get(blockState.getBlock()) == null + || !notFullBlock.containsKey(blockState.getBlock()) + || notFullBlock.get(blockState.getBlock()) == null ) { VoxelShape voxelShape = blockState.getShape(chunk, blockPos); @@ -835,8 +803,8 @@ public class LodBuilder return blockState.getBlock() != Blocks.AIR - && blockState.getBlock() != Blocks.CAVE_AIR - && blockState.getBlock() != Blocks.BARRIER; + && blockState.getBlock() != Blocks.CAVE_AIR + && blockState.getBlock() != Blocks.BARRIER; } return false; diff --git a/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilderConfig.java b/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilderConfig.java index d4b2d58d8..e7641d845 100644 --- a/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilderConfig.java +++ b/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilderConfig.java @@ -25,7 +25,6 @@ import com.seibel.lod.enums.DistanceGenerationMode; * Generally this will only be used if we want to generate a * LodChunk using an incomplete Chunk, otherwise the defaults * work best for a fully generated chunk (IE has correct surface blocks). - * * @author James Seibel * @version 8-14-2021 */ @@ -56,10 +55,10 @@ public class LodBuilderConfig } /** - * @param newUseHeightmap default = false - * @param newUseBiomeColors default = false + * @param newUseHeightmap default = false + * @param newUseBiomeColors default = false * @param newUseSolidBlocksInBiomeColor default = true - * @param newDistanceGenerationMode default = Server + * @param newDistanceGenerationMode default = Server */ public LodBuilderConfig(boolean newUseHeightmap, boolean newUseBiomeColors, boolean newUseSolidBlocksInBiomeColor, DistanceGenerationMode newDistanceGenerationMode) @@ -71,8 +70,8 @@ public class LodBuilderConfig } /** - * @param newUseHeightmap default = false - * @param newUseBiomeColors default = false + * @param newUseHeightmap default = false + * @param newUseBiomeColors default = false * @param newUseSolidBlocksInBiomeColor default = true */ public LodBuilderConfig(boolean newUseHeightmap, boolean newUseBiomeColors, boolean newUseSolidBlocksInBiomeColor) @@ -85,7 +84,7 @@ public class LodBuilderConfig } /** - * @param newDistanceGenerationMode default = Server + * @param newDistanceGenerationMode default = Server */ public LodBuilderConfig(DistanceGenerationMode newDistanceGenerationMode) { diff --git a/src/main/java/com/seibel/lod/builders/worldGeneration/LodNodeGenWorker.java b/src/main/java/com/seibel/lod/builders/worldGeneration/LodNodeGenWorker.java index 47ff416b0..c7b4108bf 100644 --- a/src/main/java/com/seibel/lod/builders/worldGeneration/LodNodeGenWorker.java +++ b/src/main/java/com/seibel/lod/builders/worldGeneration/LodNodeGenWorker.java @@ -59,7 +59,6 @@ import java.util.function.Supplier; /** * This is used to generate a LodChunk at a given ChunkPos. - * * @author James Seibel * @version 9-7-2021 */ @@ -71,9 +70,11 @@ public class LodNodeGenWorker implements IWorker private final LodChunkGenThread thread; - /** If a configured feature fails for whatever reason, + /** + * If a configured feature fails for whatever reason, * add it to this list, this is to hopefully remove any - * features that could cause issues down the line. */ + * features that could cause issues down the line. + */ private static final ConcurrentHashMap> configuredFeaturesToAvoid = new ConcurrentHashMap<>(); @@ -384,7 +385,7 @@ public class LodNodeGenWorker implements IWorker /** * takes about 15 - 20 ms - * + *

* Causes concurrentModification Exceptions, * which could cause instability or world generation bugs */ @@ -506,9 +507,9 @@ public class LodNodeGenWorker implements IWorker /** * on pre generated chunks 0 - 1 ms * on un generated chunks 0 - 50 ms - * with the median seeming to hover around 15 - 30 ms - * and outliers in the 100 - 200 ms range - * + * with the median seeming to hover around 15 - 30 ms + * and outliers in the 100 - 200 ms range + *

* Note this should not be multithreaded and does cause server/simulation lag * (Higher lag for generating than loading) */ @@ -606,7 +607,7 @@ public class LodNodeGenWorker implements IWorker /** * Stops the current genThreads if they are running * and then recreates the Executor service.

- * + *

* This is done to clear any outstanding tasks * that may exist after the player leaves their current world. * If this isn't done unfinished tasks may be left in the queue diff --git a/src/main/java/com/seibel/lod/builders/worldGeneration/LodServerWorld.java b/src/main/java/com/seibel/lod/builders/worldGeneration/LodServerWorld.java index 686b9d659..835641937 100644 --- a/src/main/java/com/seibel/lod/builders/worldGeneration/LodServerWorld.java +++ b/src/main/java/com/seibel/lod/builders/worldGeneration/LodServerWorld.java @@ -15,16 +15,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.builders.worldGeneration; -import java.util.HashMap; -import java.util.List; -import java.util.Random; -import java.util.function.Predicate; -import java.util.stream.Stream; - import com.seibel.lod.util.LodUtil; - import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; @@ -40,11 +34,7 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.SectionPos; import net.minecraft.util.registry.DynamicRegistries; -import net.minecraft.world.DifficultyInstance; -import net.minecraft.world.DimensionType; -import net.minecraft.world.EmptyTickList; -import net.minecraft.world.ISeedReader; -import net.minecraft.world.ITickList; +import net.minecraft.world.*; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeManager; import net.minecraft.world.border.WorldBorder; @@ -59,272 +49,277 @@ import net.minecraft.world.lighting.WorldLightManager; import net.minecraft.world.server.ServerWorld; import net.minecraft.world.storage.IWorldInfo; +import java.util.HashMap; +import java.util.List; +import java.util.Random; +import java.util.function.Predicate; +import java.util.stream.Stream; + /** * This is a fake ServerWorld used when generating features. * This allows us to keep each LodChunk generation independent * of the actual ServerWorld, allowing us * to multithread generation. - * * @author James Seibel * @version 7-26-2021 */ public class LodServerWorld implements ISeedReader { - + public HashMap heightmaps = new HashMap<>(); - + public final IChunk chunk; - + public final ServerWorld serverWorld; - + public LodServerWorld(ServerWorld newServerWorld, IChunk newChunk) { chunk = newChunk; serverWorld = newServerWorld; } - - + + @Override public int getHeight(Type heightmapType, int x, int z) { // make sure the block position is set relative to the chunk x = x % LodUtil.CHUNK_WIDTH; x = (x < 0) ? x + 16 : x; - + z = z % LodUtil.CHUNK_WIDTH; z = (z < 0) ? z + 16 : z; - + return chunk.getOrCreateHeightmapUnprimed(LodUtil.DEFAULT_HEIGHTMAP).getFirstAvailable(x, z); } - + @Override public Biome getBiome(BlockPos pos) { return chunk.getBiomes().getNoiseBiome(pos.getX() >> 2, pos.getY() >> 2, pos.getZ() >> 2); } - + @Override public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { return chunk.setBlockState(pos, state, false) == state; } - + @Override public BlockState getBlockState(BlockPos pos) { return chunk.getBlockState(pos); } - + @Override public FluidState getFluidState(BlockPos pos) { return chunk.getFluidState(pos); } - - + + @Override public boolean isStateAtPosition(BlockPos pos, Predicate state) { return state.test(chunk.getBlockState(pos)); } - + @Override public ITickList getBlockTicks() { return EmptyTickList.empty(); } - + @Override public IChunk getChunk(int x, int z, ChunkStatus requiredStatus, boolean nonnull) { return chunk; } - + @Override public Stream> startsForFeature(SectionPos p_241827_1_, Structure p_241827_2_) { return serverWorld.startsForFeature(p_241827_1_, p_241827_2_); } - + @Override public ITickList getLiquidTicks() { return EmptyTickList.empty(); } - + @Override public WorldLightManager getLightEngine() { return new WorldLightManager(null, false, false); } - + @Override public long getSeed() { return serverWorld.getSeed(); } - + @Override public DynamicRegistries registryAccess() { return serverWorld.registryAccess(); } - - + + /** * All methods below shouldn't be needed * and thus have been left unimplemented. */ - - + + @Override public Random getRandom() { throw new UnsupportedOperationException("Not Implemented"); } - + @Override public void playSound(PlayerEntity player, BlockPos pos, SoundEvent soundIn, SoundCategory category, float volume, - float pitch) + float pitch) { throw new UnsupportedOperationException("Not Implemented"); } - + @Override public void addParticle(IParticleData particleData, double x, double y, double z, double xSpeed, double ySpeed, - double zSpeed) + double zSpeed) { throw new UnsupportedOperationException("Not Implemented"); } - + @Override public BiomeManager getBiomeManager() { throw new UnsupportedOperationException("Not Implemented"); } - + @Override public int getSeaLevel() { throw new UnsupportedOperationException("Not Implemented"); } - + @Override public float getShade(Direction p_230487_1_, boolean p_230487_2_) { throw new UnsupportedOperationException("Not Implemented"); } - + @Override public WorldBorder getWorldBorder() { throw new UnsupportedOperationException("Not Implemented"); } - + @Override public boolean removeBlock(BlockPos pos, boolean isMoving) { throw new UnsupportedOperationException("Not Implemented"); } - + @Override public boolean destroyBlock(BlockPos pos, boolean dropBlock, Entity entity, int recursionLeft) { throw new UnsupportedOperationException("Not Implemented"); } - - + + @Override public ServerWorld getLevel() { throw new UnsupportedOperationException("Not Implemented"); } - - + + @Override public AbstractChunkProvider getChunkSource() { throw new UnsupportedOperationException("Not Implemented"); } - - + + @Override public DifficultyInstance getCurrentDifficultyAt(BlockPos arg0) { throw new UnsupportedOperationException("Not Implemented"); } - - + + @Override public IWorldInfo getLevelData() { throw new UnsupportedOperationException("Not Implemented"); } - - + + @Override public void levelEvent(PlayerEntity arg0, int arg1, BlockPos arg2, int arg3) { throw new UnsupportedOperationException("Not Implemented"); - + } - - + + @Override public List getEntities(Entity arg0, AxisAlignedBB arg1, Predicate arg2) { throw new UnsupportedOperationException("Not Implemented"); } - - + + @Override public List getEntitiesOfClass(Class arg0, AxisAlignedBB arg1, - Predicate arg2) + Predicate arg2) { throw new UnsupportedOperationException("Not Implemented"); } - - + + @Override public List players() { throw new UnsupportedOperationException("Not Implemented"); } - - + + @Override public int getSkyDarken() { throw new UnsupportedOperationException("Not Implemented"); } - - + + @Override public Biome getUncachedNoiseBiome(int p_225604_1_, int p_225604_2_, int p_225604_3_) { throw new UnsupportedOperationException("Not Implemented"); } - - + + @Override public boolean isClientSide() { throw new UnsupportedOperationException("Not Implemented"); } - - + + @Override public DimensionType dimensionType() { throw new UnsupportedOperationException("Not Implemented"); } - - + + @Override public TileEntity getBlockEntity(BlockPos p_175625_1_) { throw new UnsupportedOperationException("Not Implemented"); } - + } diff --git a/src/main/java/com/seibel/lod/builders/worldGeneration/LodWorldGenerator.java b/src/main/java/com/seibel/lod/builders/worldGeneration/LodWorldGenerator.java index c5069863a..01724ba5a 100644 --- a/src/main/java/com/seibel/lod/builders/worldGeneration/LodWorldGenerator.java +++ b/src/main/java/com/seibel/lod/builders/worldGeneration/LodWorldGenerator.java @@ -1,11 +1,5 @@ package com.seibel.lod.builders.worldGeneration; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicInteger; - import com.seibel.lod.builders.lodBuilding.LodBuilder; import com.seibel.lod.config.LodConfig; import com.seibel.lod.enums.DistanceGenerationMode; @@ -17,14 +11,18 @@ import com.seibel.lod.util.LevelPosUtil; import com.seibel.lod.util.LodThreadFactory; import com.seibel.lod.util.LodUtil; import com.seibel.lod.wrappers.MinecraftWrapper; - import net.minecraft.util.math.ChunkPos; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.WorldWorkerManager; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicInteger; + /** * A singleton that handles all long distance LOD world generation. - * * @author James Seibel * @version 9-25-2021 */ @@ -69,9 +67,8 @@ public class LodWorldGenerator /** * Queues up LodNodeGenWorkers for the given lodDimension. - * * @param renderer needed so the LodNodeGenWorkers can flag that the - * buffers need to be rebuilt. + * buffers need to be rebuilt. */ public void queueGenerationRequests(LodDimension lodDim, LodRenderer renderer, LodBuilder lodBuilder) { @@ -104,19 +101,19 @@ public class LodWorldGenerator maxChunkGenRequests, playerPosX, playerPosZ); - - + + byte detailLevel; int posX; int posZ; int nearIndex = 0; int farIndex = 0; - + for (int i = 0; i < posToGenerate.getNumberOfPos(); i++) { // I wish there was a way to compress this code, but I'm not aware of // an easy way to do so. - + // add the near positions if (posToGenerate.getNthDetail(nearIndex, true) != 0 && nearIndex < posToGenerate.getNumberOfNearPos()) { @@ -126,11 +123,11 @@ public class LodWorldGenerator nearIndex++; ChunkPos chunkPos = new ChunkPos(LevelPosUtil.getChunkPos(detailLevel, posX), LevelPosUtil.getChunkPos(detailLevel, posZ)); - + // prevent generating the same chunk multiple times if (positionsWaitingToBeGenerated.contains(chunkPos)) continue; - + // don't add more to the generation queue then allowed if (numberOfChunksWaitingToGenerate.get() >= maxChunkGenRequests) break; @@ -140,8 +137,8 @@ public class LodWorldGenerator LodNodeGenWorker genWorker = new LodNodeGenWorker(chunkPos, DetailDistanceUtil.getDistanceGenerationMode(detailLevel), lodBuilder, lodDim, serverWorld); WorldWorkerManager.addWorker(genWorker); } - - + + // add the far positions if (posToGenerate.getNthDetail(farIndex, false) != 0 && farIndex < posToGenerate.getNumberOfFarPos()) { @@ -151,16 +148,16 @@ public class LodWorldGenerator farIndex++; ChunkPos chunkPos = new ChunkPos(LevelPosUtil.getChunkPos(detailLevel, posX), LevelPosUtil.getChunkPos(detailLevel, posZ)); - + // don't add more to the generation queue then allowed if (numberOfChunksWaitingToGenerate.get() >= maxChunkGenRequests) continue; - //break; - + //break; + // prevent generating the same chunk multiple times if (positionsWaitingToBeGenerated.contains(chunkPos)) continue; - + positionsWaitingToBeGenerated.add(chunkPos); numberOfChunksWaitingToGenerate.addAndGet(1); LodNodeGenWorker genWorker = new LodNodeGenWorker(chunkPos, DetailDistanceUtil.getDistanceGenerationMode(detailLevel), lodBuilder, lodDim, serverWorld); diff --git a/src/main/java/com/seibel/lod/config/LodConfig.java b/src/main/java/com/seibel/lod/config/LodConfig.java index 6cae3b764..47a597f2f 100644 --- a/src/main/java/com/seibel/lod/config/LodConfig.java +++ b/src/main/java/com/seibel/lod/config/LodConfig.java @@ -18,38 +18,23 @@ package com.seibel.lod.config; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; - import com.electronwill.nightconfig.core.file.CommentedFileConfig; import com.electronwill.nightconfig.core.io.WritingMode; import com.seibel.lod.ModInfo; -import com.seibel.lod.enums.BufferRebuildTimes; -import com.seibel.lod.enums.DebugMode; -import com.seibel.lod.enums.DetailDropOff; -import com.seibel.lod.enums.DistanceGenerationMode; -import com.seibel.lod.enums.FogDistance; -import com.seibel.lod.enums.FogDrawOverride; -import com.seibel.lod.enums.GenerationPriority; -import com.seibel.lod.enums.HorizontalQuality; -import com.seibel.lod.enums.HorizontalResolution; -import com.seibel.lod.enums.HorizontalScale; -import com.seibel.lod.enums.LodTemplate; -import com.seibel.lod.enums.VanillaOverdraw; -import com.seibel.lod.enums.VerticalQuality; +import com.seibel.lod.enums.*; import com.seibel.lod.util.LodUtil; - import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.logging.log4j.LogManager; + +import java.nio.file.Path; +import java.nio.file.Paths; /** * This handles any configuration the user has access to. - * * @author James Seibel * @version 10-11-2021 */ diff --git a/src/main/java/com/seibel/lod/enums/BufferRebuildTimes.java b/src/main/java/com/seibel/lod/enums/BufferRebuildTimes.java index ecb67e4a6..d70efee9c 100644 --- a/src/main/java/com/seibel/lod/enums/BufferRebuildTimes.java +++ b/src/main/java/com/seibel/lod/enums/BufferRebuildTimes.java @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; /** @@ -22,22 +23,21 @@ package com.seibel.lod.enums; * Far_First
*
* Determines how fast the buffers need to be regenerated - * * @author Leonardo Amato * @version 9-25-2021 */ public enum BufferRebuildTimes { FREQUENT(1000, 500, 2500), - + NORMAL(2000, 1000, 5000), - + RARE(5000, 2000, 10000); - + public final int playerMoveTimeout; public final int renderedChunkTimeout; public final int chunkChangeTimeout; - + BufferRebuildTimes(int playerMoveTimeout, int renderedChunkTimeout, int chunkChangeTimeout) { this.playerMoveTimeout = playerMoveTimeout; diff --git a/src/main/java/com/seibel/lod/enums/DebugMode.java b/src/main/java/com/seibel/lod/enums/DebugMode.java index bcc02cb0b..7f210b836 100644 --- a/src/main/java/com/seibel/lod/enums/DebugMode.java +++ b/src/main/java/com/seibel/lod/enums/DebugMode.java @@ -15,11 +15,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; /** * off, detail, detail wireframe - * * @author James Seibel * @version 8-28-2021 */ @@ -36,7 +36,8 @@ public enum DebugMode /** used when cycling through the different modes */ private DebugMode next; - static + + static { OFF.next = SHOW_DETAIL; SHOW_DETAIL.next = SHOW_DETAIL_WIREFRAME; diff --git a/src/main/java/com/seibel/lod/enums/DetailDropOff.java b/src/main/java/com/seibel/lod/enums/DetailDropOff.java index b09ad34f4..1127eb215 100644 --- a/src/main/java/com/seibel/lod/enums/DetailDropOff.java +++ b/src/main/java/com/seibel/lod/enums/DetailDropOff.java @@ -15,13 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; /** * By_Region_Fast,
* By_Region_Fancy,
* By_Chunk - * * @author Leonardo Amato * @version 9-25-2021 */ @@ -29,7 +29,7 @@ public enum DetailDropOff { /** quality is determined per-region, using the lowest quality that would be used in BY_CHUNK */ FAST, - + /** quality is determined per-block (the best quality option, may cause stuttering when moving) */ FANCY, } diff --git a/src/main/java/com/seibel/lod/enums/DistanceGenerationMode.java b/src/main/java/com/seibel/lod/enums/DistanceGenerationMode.java index fb88826dc..2d23dedb4 100644 --- a/src/main/java/com/seibel/lod/enums/DistanceGenerationMode.java +++ b/src/main/java/com/seibel/lod/enums/DistanceGenerationMode.java @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; /** @@ -26,7 +27,6 @@ package com.seibel.lod.enums; * SERVER

*

* In order of fastest to slowest. - * * @author James Seibel * @author Leonardo Amato * @version 8-7-2021 @@ -37,7 +37,7 @@ public enum DistanceGenerationMode * Don't generate anything */ NONE((byte) 0), - + /** * Only generate the biomes and use biome * grass/foliage color, water color, or ice color @@ -46,7 +46,7 @@ public enum DistanceGenerationMode * Multithreaded - Fastest (2-5 ms) */ BIOME_ONLY((byte) 1), - + /** * Same as BIOME_ONLY, except instead * of always using sea level as the LOD height @@ -54,7 +54,7 @@ public enum DistanceGenerationMode * use predetermined heights to simulate having height data. */ BIOME_ONLY_SIMULATE_HEIGHT((byte) 2), - + /** * Generate the world surface, * this does NOT include caves, trees, @@ -62,7 +62,7 @@ public enum DistanceGenerationMode * Multithreaded - Faster (10-20 ms) */ SURFACE((byte) 3), - + /** * Generate everything except structures. * NOTE: This may cause world generation bugs or instability, @@ -70,7 +70,7 @@ public enum DistanceGenerationMode * Multithreaded - Fast (15-20 ms) */ FEATURES((byte) 4), - + /** * Ask the server to generate/load each chunk. * This is the most compatible, but causes server/simulation lag. @@ -79,13 +79,13 @@ public enum DistanceGenerationMode * Singlethreaded - Slow (15-50 ms, with spikes up to 200 ms) */ SERVER((byte) 5); - - + + /** * The higher the number the more complete the generation is. */ public final byte complexity; - + DistanceGenerationMode(byte complexity) { this.complexity = complexity; diff --git a/src/main/java/com/seibel/lod/enums/FogDistance.java b/src/main/java/com/seibel/lod/enums/FogDistance.java index 96baf7b72..cc9afce05 100644 --- a/src/main/java/com/seibel/lod/enums/FogDistance.java +++ b/src/main/java/com/seibel/lod/enums/FogDistance.java @@ -15,11 +15,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; /** * NEAR, FAR, or NEAR_AND_FAR. - * * @author James Seibel * @version 02-14-2021 */ diff --git a/src/main/java/com/seibel/lod/enums/FogDrawOverride.java b/src/main/java/com/seibel/lod/enums/FogDrawOverride.java index 405311f42..600499c98 100644 --- a/src/main/java/com/seibel/lod/enums/FogDrawOverride.java +++ b/src/main/java/com/seibel/lod/enums/FogDrawOverride.java @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; /** @@ -22,14 +23,15 @@ package com.seibel.lod.enums; * NEVER_DRAW_FOG,
* ALWAYS_DRAW_FOG_FAST,
* ALWAYS_DRAW_FOG_FANCY
- * * @author James Seibel * @version 7-3-2021 */ public enum FogDrawOverride { - /** Use whatever Fog setting optifine is using. - * If optifine isn't installed this defaults to ALWAYS_DRAW_FOG. */ + /** + * Use whatever Fog setting optifine is using. + * If optifine isn't installed this defaults to ALWAYS_DRAW_FOG. + */ USE_OPTIFINE_FOG_SETTING, /** Never draw fog on the LODs */ diff --git a/src/main/java/com/seibel/lod/enums/FogQuality.java b/src/main/java/com/seibel/lod/enums/FogQuality.java index 641117066..e1d5493f3 100644 --- a/src/main/java/com/seibel/lod/enums/FogQuality.java +++ b/src/main/java/com/seibel/lod/enums/FogQuality.java @@ -15,11 +15,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; /** * fast, fancy, or off - * * @author James Seibel * @version 02-14-2021 */ diff --git a/src/main/java/com/seibel/lod/enums/GenerationPriority.java b/src/main/java/com/seibel/lod/enums/GenerationPriority.java index 4968c5037..952f270c1 100644 --- a/src/main/java/com/seibel/lod/enums/GenerationPriority.java +++ b/src/main/java/com/seibel/lod/enums/GenerationPriority.java @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; /** @@ -23,7 +24,6 @@ package com.seibel.lod.enums; *
* Determines which LODs should have priority when generating * outside the normal view distance. - * * @author Leonardo Amato * @version 9-25-2021 */ diff --git a/src/main/java/com/seibel/lod/enums/GlProxyContext.java b/src/main/java/com/seibel/lod/enums/GlProxyContext.java index 52f0b16b9..aece5458b 100644 --- a/src/main/java/com/seibel/lod/enums/GlProxyContext.java +++ b/src/main/java/com/seibel/lod/enums/GlProxyContext.java @@ -1,8 +1,7 @@ package com.seibel.lod.enums; -/** +/** * Minecraft, Lod_Builder, None - * * @author James Seibel * @version 10-1-2021 */ diff --git a/src/main/java/com/seibel/lod/enums/HorizontalQuality.java b/src/main/java/com/seibel/lod/enums/HorizontalQuality.java index 1c64d63a8..08ec328a0 100644 --- a/src/main/java/com/seibel/lod/enums/HorizontalQuality.java +++ b/src/main/java/com/seibel/lod/enums/HorizontalQuality.java @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; /** @@ -23,7 +24,6 @@ package com.seibel.lod.enums; * High
*
* this indicates the base of the quadratic function we use for the quality drop off - * * @author Leonardo Amato * @version 9-29-2021 */ @@ -31,18 +31,18 @@ public enum HorizontalQuality { /** Lods are 2D with heightMap */ LINEAR(1.0f), - + /** Lods are 2D with heightMap */ LOW(1.5f), - + /** Lods expand in three dimension */ MEDIUM(2.0f), - + /** Lods expand in three dimension */ HIGH(2.2f); - + public final double quadraticBase; - + HorizontalQuality(double distanceUnit) { this.quadraticBase = distanceUnit; diff --git a/src/main/java/com/seibel/lod/enums/HorizontalResolution.java b/src/main/java/com/seibel/lod/enums/HorizontalResolution.java index e1bb023dc..0aff880aa 100644 --- a/src/main/java/com/seibel/lod/enums/HorizontalResolution.java +++ b/src/main/java/com/seibel/lod/enums/HorizontalResolution.java @@ -15,20 +15,20 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; +import com.seibel.lod.util.LodUtil; + import java.util.ArrayList; import java.util.Collections; -import com.seibel.lod.util.LodUtil; - /** * chunk
* half_chunk
* four_blocks
* two_blocks
* block
- * * @author James Seibel * @author Leonardo Amato * @version 9-25-2021 @@ -49,16 +49,20 @@ public enum HorizontalResolution /** render 256 LODs for each chunk */ BLOCK(16, 0); - - /** How many DataPoints should - * be drawn per side, per LodChunk */ + + /** + * How many DataPoints should + * be drawn per side, per LodChunk + */ public final int dataPointLengthCount; /** How wide each LOD DataPoint is */ public final int dataPointWidth; - /** This is the same as detailLevel in LodQuadTreeNode, - * lowest is 0 highest is 9 */ + /** + * This is the same as detailLevel in LodQuadTreeNode, + * lowest is 0 highest is 9 + */ public final byte detailLevel; /* Start/End X/Z give the block positions @@ -68,12 +72,12 @@ public enum HorizontalResolution public final int[] endX; public final int[] endZ; - - /** + + /** * 1st dimension: LodDetail.detailLevel
* 2nd dimension: An array of all LodDetails that are less than or
- * equal to that detailLevel + * equal to that detailLevel */ private static HorizontalResolution[][] lowerDetailArrays; @@ -94,15 +98,15 @@ public enum HorizontalResolution int index = 0; - for(int x = 0; x < newLengthCount; x++) + for (int x = 0; x < newLengthCount; x++) { - for(int z = 0; z < newLengthCount; z++) + for (int z = 0; z < newLengthCount; z++) { startX[index] = x * dataPointWidth; startZ[index] = z * dataPointWidth; - endX[index] = (x*dataPointWidth) + dataPointWidth; - endZ[index] = (z*dataPointWidth) + dataPointWidth; + endX[index] = (x * dataPointWidth) + dataPointWidth; + endZ[index] = (z * dataPointWidth) + dataPointWidth; index++; } @@ -115,7 +119,7 @@ public enum HorizontalResolution - /** + /** * Returns an array of all LodDetails that have a detail level * that is less than or equal to the given LodDetail */ @@ -127,12 +131,12 @@ public enum HorizontalResolution lowerDetailArrays = new HorizontalResolution[HorizontalResolution.values().length][]; // go through each LodDetail - for(HorizontalResolution currentDetail : HorizontalResolution.values()) + for (HorizontalResolution currentDetail : HorizontalResolution.values()) { ArrayList lowerDetails = new ArrayList<>(); // find the details lower than currentDetail - for(HorizontalResolution compareDetail : HorizontalResolution.values()) + for (HorizontalResolution compareDetail : HorizontalResolution.values()) { if (currentDetail.detailLevel <= compareDetail.detailLevel) { diff --git a/src/main/java/com/seibel/lod/enums/HorizontalScale.java b/src/main/java/com/seibel/lod/enums/HorizontalScale.java index 4f8546708..1976deaa4 100644 --- a/src/main/java/com/seibel/lod/enums/HorizontalScale.java +++ b/src/main/java/com/seibel/lod/enums/HorizontalScale.java @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; /** @@ -23,7 +24,6 @@ package com.seibel.lod.enums; * High
*
* this is a quality scale for the detail drop-off - * * @author Leonardo Amato * @version 9-25-2021 */ diff --git a/src/main/java/com/seibel/lod/enums/LodTemplate.java b/src/main/java/com/seibel/lod/enums/LodTemplate.java index e82758d4a..6d2ad43be 100644 --- a/src/main/java/com/seibel/lod/enums/LodTemplate.java +++ b/src/main/java/com/seibel/lod/enums/LodTemplate.java @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; import com.seibel.lod.builders.bufferBuilding.lodTemplates.AbstractLodTemplate; @@ -24,23 +25,28 @@ import com.seibel.lod.builders.bufferBuilding.lodTemplates.TriangularLodTemplate /** * Cubic, Triangular, Dynamic - * * @author James Seibel * @version 10-10-2021 */ public enum LodTemplate { - /** LODs are rendered as - * rectangular prisms. */ + /** + * LODs are rendered as + * rectangular prisms. + */ CUBIC(new CubicLodTemplate()), - /** LODs smoothly transition between - * each other. */ + /** + * LODs smoothly transition between + * each other. + */ TRIANGULAR(new TriangularLodTemplate()), - /** LODs smoothly transition between + /** + * LODs smoothly transition between * each other, unless a neighboring LOD - * is at a significantly different height. */ + * is at a significantly different height. + */ DYNAMIC(new DynamicLodTemplate()); diff --git a/src/main/java/com/seibel/lod/enums/ShadingMode.java b/src/main/java/com/seibel/lod/enums/ShadingMode.java index 17fce842f..0b6fd78ad 100644 --- a/src/main/java/com/seibel/lod/enums/ShadingMode.java +++ b/src/main/java/com/seibel/lod/enums/ShadingMode.java @@ -2,7 +2,6 @@ package com.seibel.lod.enums; /** * NONE, GAME_SHADING - * * @author James Seibel * @version 7-25-2020 */ @@ -15,7 +14,7 @@ public enum ShadingMode NONE, /** - * LODs will have darker sides and bottoms to simulate + * LODs will have darker sides and bottoms to simulate * Minecraft's fast, top down lighting. */ GAME_SHADING diff --git a/src/main/java/com/seibel/lod/enums/VanillaOverdraw.java b/src/main/java/com/seibel/lod/enums/VanillaOverdraw.java index 2ce00c91c..57fd34299 100644 --- a/src/main/java/com/seibel/lod/enums/VanillaOverdraw.java +++ b/src/main/java/com/seibel/lod/enums/VanillaOverdraw.java @@ -1,12 +1,11 @@ package com.seibel.lod.enums; -/** +/** * None, Dynamic, Always - * + * *

* This represents how far the LODs should overlap with * the vanilla Minecraft terrain. - * * @author James Seibel * @version 10-11-2021 */ diff --git a/src/main/java/com/seibel/lod/enums/VerticalQuality.java b/src/main/java/com/seibel/lod/enums/VerticalQuality.java index a709854c4..99df919c1 100644 --- a/src/main/java/com/seibel/lod/enums/VerticalQuality.java +++ b/src/main/java/com/seibel/lod/enums/VerticalQuality.java @@ -15,19 +15,19 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.enums; /** * heightmap
* multi_lod
- * * @author Leonardo Amato * @version 10-07-2021 */ public enum VerticalQuality { LOW( - new int[]{2, + new int[] { 2, 2, 2, 2, @@ -37,11 +37,11 @@ public enum VerticalQuality 1, 1, 1, - 1} + 1 } ), MEDIUM( - new int[]{4, + new int[] { 4, 4, 2, 2, @@ -51,11 +51,11 @@ public enum VerticalQuality 1, 1, 1, - 1} + 1 } ), HIGH( - new int[]{ + new int[] { 8, 8, 4, @@ -66,7 +66,7 @@ public enum VerticalQuality 1, 1, 1, - 1} + 1 } ); public final int[] maxVerticalData; diff --git a/src/main/java/com/seibel/lod/handlers/LodDimensionFileHandler.java b/src/main/java/com/seibel/lod/handlers/LodDimensionFileHandler.java index 12f9b4822..31a8a42d7 100644 --- a/src/main/java/com/seibel/lod/handlers/LodDimensionFileHandler.java +++ b/src/main/java/com/seibel/lod/handlers/LodDimensionFileHandler.java @@ -38,7 +38,6 @@ import java.util.concurrent.Executors; * This object handles creating LodRegions * from files and saving LodRegion objects * to file. - * * @author James Seibel * @author Cola * @version 9-25-2021 @@ -130,14 +129,20 @@ public class LodDimensionFileHandler if (fileName != null) { file = new File(fileName); - if (file.exists()) break; + if (file.exists()) + break; } //decrease gen mode - if (tempGenMode == DistanceGenerationMode.SERVER) tempGenMode = DistanceGenerationMode.FEATURES; - else if (tempGenMode == DistanceGenerationMode.FEATURES) tempGenMode = DistanceGenerationMode.SURFACE; - else if (tempGenMode == DistanceGenerationMode.SURFACE) tempGenMode = DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT; - else if (tempGenMode == DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT) tempGenMode = DistanceGenerationMode.BIOME_ONLY; - else if (tempGenMode == DistanceGenerationMode.BIOME_ONLY) tempGenMode = DistanceGenerationMode.NONE; + if (tempGenMode == DistanceGenerationMode.SERVER) + tempGenMode = DistanceGenerationMode.FEATURES; + else if (tempGenMode == DistanceGenerationMode.FEATURES) + tempGenMode = DistanceGenerationMode.SURFACE; + else if (tempGenMode == DistanceGenerationMode.SURFACE) + tempGenMode = DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT; + else if (tempGenMode == DistanceGenerationMode.BIOME_ONLY_SIMULATE_HEIGHT) + tempGenMode = DistanceGenerationMode.BIOME_ONLY; + else if (tempGenMode == DistanceGenerationMode.BIOME_ONLY) + tempGenMode = DistanceGenerationMode.NONE; } if (!file.exists()) //there wasn't a file, don't return anything @@ -200,7 +205,7 @@ public class LodDimensionFileHandler ClientProxy.LOGGER.error("LOD file read error. Unable to read to [" + fileName + "] error [" + ioEx.getMessage() + "]: "); ioEx.printStackTrace(); } - }// file datasize > 0 + } } catch (Exception e) { diff --git a/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java b/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java index a6f54899e..9c2f6eafd 100644 --- a/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java +++ b/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java @@ -29,7 +29,6 @@ import java.lang.reflect.Method; * This object is used to get variables from methods * where they are private. Specifically the fog setting * in Optifine. - * * @author James Seibel * @version 9-25-2021 */ diff --git a/src/main/java/com/seibel/lod/mixin/MixinWorldRenderer.java b/src/main/java/com/seibel/lod/mixin/MixinWorldRenderer.java index 234a02031..2ea118a60 100644 --- a/src/main/java/com/seibel/lod/mixin/MixinWorldRenderer.java +++ b/src/main/java/com/seibel/lod/mixin/MixinWorldRenderer.java @@ -34,7 +34,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; * If this wasn't done, and we used Forge's * render last event, the LODs would render on top * of the normal terrain. - * * @author James Seibel * @version 9-19-2021 */ diff --git a/src/main/java/com/seibel/lod/objects/LevelContainer.java b/src/main/java/com/seibel/lod/objects/LevelContainer.java index 0d1c83820..ecba0d4d8 100644 --- a/src/main/java/com/seibel/lod/objects/LevelContainer.java +++ b/src/main/java/com/seibel/lod/objects/LevelContainer.java @@ -2,8 +2,8 @@ package com.seibel.lod.objects; public interface LevelContainer { - /**With this you can add data to the level container - * + /** + * With this you can add data to the level container * @param data actual data to add in an array of long format. * @param posX x position in the detail level * @param posZ z position in the detail level @@ -12,8 +12,8 @@ public interface LevelContainer */ boolean addData(long data, int posX, int posZ, int index); - /**With this you can add data to the level container - * + /** + * With this you can add data to the level container * @param data actual data to add in an array of long format. * @param posX x position in the detail level * @param posZ z position in the detail level @@ -21,16 +21,16 @@ public interface LevelContainer */ boolean addSingleData(long data, int posX, int posZ); - /**With this you can get data from the level container - * + /** + * With this you can get data from the level container * @param posX x position in the detail level * @param posZ z position in the detail level * @return the data in long array format */ long getData(int posX, int posZ, int index); - /**With this you can get data from the level container - * + /** + * With this you can get data from the level container * @param posX x position in the detail level * @param posZ z position in the detail level * @return the data in long array format @@ -55,14 +55,14 @@ public interface LevelContainer /** Clears the dataPoint at the given array index */ void clear(int posX, int posZ); - /**This return a level container with detail level lower than the current level. + /** + * This return a level container with detail level lower than the current level. * The new level container may use information of this level. * @return the new level container */ LevelContainer expand(); /** - * * @param lowerLevelContainer lower level where we extract the data * @param posX x position in the detail level to update * @param posZ z position in the detail level to update diff --git a/src/main/java/com/seibel/lod/objects/LodDimension.java b/src/main/java/com/seibel/lod/objects/LodDimension.java index 2d0702f25..58eaad3ab 100644 --- a/src/main/java/com/seibel/lod/objects/LodDimension.java +++ b/src/main/java/com/seibel/lod/objects/LodDimension.java @@ -18,28 +18,23 @@ package com.seibel.lod.objects; -import java.io.File; -import java.io.IOException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - import com.seibel.lod.config.LodConfig; import com.seibel.lod.enums.DistanceGenerationMode; import com.seibel.lod.enums.GenerationPriority; import com.seibel.lod.enums.VerticalQuality; import com.seibel.lod.handlers.LodDimensionFileHandler; -import com.seibel.lod.util.DataPointUtil; -import com.seibel.lod.util.DetailDistanceUtil; -import com.seibel.lod.util.LevelPosUtil; -import com.seibel.lod.util.LodThreadFactory; -import com.seibel.lod.util.LodUtil; +import com.seibel.lod.util.*; import com.seibel.lod.wrappers.MinecraftWrapper; - import net.minecraft.util.math.ChunkPos; import net.minecraft.world.DimensionType; import net.minecraft.world.server.ServerChunkProvider; import net.minecraft.world.server.ServerWorld; +import java.io.File; +import java.io.IOException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + /** * This object holds all loaded LOD regions @@ -48,7 +43,6 @@ import net.minecraft.world.server.ServerWorld; * Coordinate Standard:
* Coordinate called posX or posZ are relative LevelPos coordinates
* unless stated otherwise.
- * * @author Leonardo Amato * @author James Seibel * @version 10-10-2021 @@ -92,7 +86,6 @@ public class LodDimension /** * Creates the dimension centered at (0,0) - * * @param newWidth in regions */ public LodDimension(DimensionType newDimension, LodWorld lodWorld, int newWidth) @@ -294,7 +287,6 @@ public class LodDimension /** * Overwrite the LodRegion at the location of newRegion with newRegion. - * * @throws ArrayIndexOutOfBoundsException if newRegion is outside what can be stored in this LodDimension. */ public synchronized void addOrOverwriteRegion(LodRegion newRegion) throws ArrayIndexOutOfBoundsException @@ -597,7 +589,7 @@ public class LodDimension /** * Returns every node that should be rendered based on the position of the player. - * + *

* TODO why isn't posToRender returned? it would make it a bit more clear what is happening */ public void getPosToRender(PosToRenderContainer posToRender, RegionPos regionPos, int playerPosX, @@ -609,7 +601,7 @@ public class LodDimension } /** - * Determines how many vertical LODs could be used + * Determines how many vertical LODs could be used * for the given region at the given detail level */ public int getMaxVerticalData(byte detailLevel, int posX, int posZ) @@ -688,7 +680,7 @@ public class LodDimension /** * TODO we aren't currently using this, is there a reason for that? * is this significantly different than regenRegionBuffer? - * + *

* Returns if the buffer at the given array index needs * to have its buffer resized. */ diff --git a/src/main/java/com/seibel/lod/objects/LodRegion.java b/src/main/java/com/seibel/lod/objects/LodRegion.java index 358a39d2c..562cb9898 100644 --- a/src/main/java/com/seibel/lod/objects/LodRegion.java +++ b/src/main/java/com/seibel/lod/objects/LodRegion.java @@ -16,7 +16,6 @@ import com.seibel.lod.util.LodUtil; * Coordinate Standard:
* Coordinate called posX or posZ are relative LevelPos coordinates
* unless stated otherwise.
- * * @author Leonardo Amato * @version 10-10-2021 */ @@ -87,7 +86,6 @@ public class LodRegion * Inserts the data point into the region. *

* TODO this will always return true unless it has - * * @return true if the data was added successfully */ public boolean addData(byte detailLevel, int posX, int posZ, int verticalIndex, long data) @@ -109,7 +107,6 @@ public class LodRegion /** * Get the dataPoint at the given relative position. - * * @return the data at the relative pos and detail level, * 0 if the data doesn't exist. */ @@ -120,7 +117,6 @@ public class LodRegion /** * Get the dataPoint at the given relative position. - * * @return the data at the relative pos and detail level, * 0 if the data doesn't exist. */ @@ -434,7 +430,6 @@ public class LodRegion /** * Returns the LevelContainer for the detailLevel - * * @throws IllegalArgumentException if the detailLevel is less than minDetailLevel */ public LevelContainer getLevel(byte detailLevel) @@ -448,10 +443,9 @@ public class LodRegion /** * Add the levelContainer to this Region, updating the minDetailLevel * if necessary. - * * @throws IllegalArgumentException if the LevelContainer's detailLevel - * is 2 or more detail levels lower than the - * minDetailLevel of this region. + * is 2 or more detail levels lower than the + * minDetailLevel of this region. */ public void addLevelContainer(LevelContainer levelContainer) { diff --git a/src/main/java/com/seibel/lod/objects/LodWorld.java b/src/main/java/com/seibel/lod/objects/LodWorld.java index 257e9dced..6c38ef78c 100644 --- a/src/main/java/com/seibel/lod/objects/LodWorld.java +++ b/src/main/java/com/seibel/lod/objects/LodWorld.java @@ -26,7 +26,6 @@ import java.util.Map; /** * This stores all LODs for a given world. - * * @author James Seibel * @author Leonardo Amato * @version 9-27-2021 @@ -57,10 +56,9 @@ public class LodWorld /** * Set up the LodWorld with the given newWorldName.
* This should be done whenever loading a new world.

- * + *

* Note a System.gc() call may be in order after calling this
* since a lot of LOD data is now homeless.
- * * @param newWorldName name of the world */ public void selectWorld(String newWorldName) @@ -85,7 +83,7 @@ public class LodWorld * Set the worldName to "No world loaded" * and clear the lodDimensions Map.
* This should be done whenever unloaded a world.

- * + *

* Note a System.gc() call may be in order after calling this
* since a lot of LOD data is now homeless.
*/ diff --git a/src/main/java/com/seibel/lod/objects/NearFarFogSettings.java b/src/main/java/com/seibel/lod/objects/NearFarFogSettings.java index 3c9de73d6..fb9565c76 100644 --- a/src/main/java/com/seibel/lod/objects/NearFarFogSettings.java +++ b/src/main/java/com/seibel/lod/objects/NearFarFogSettings.java @@ -24,7 +24,6 @@ import com.seibel.lod.enums.FogQuality; /** * This object is just a replacement for an array * to make things easier to understand in the LodRenderer. - * * @author James Seibel * @version 7-03-2021 */ @@ -33,8 +32,10 @@ public class NearFarFogSettings public final NearOrFarSetting near = new NearOrFarSetting(FogDistance.NEAR); public final NearOrFarSetting far = new NearOrFarSetting(FogDistance.FAR); - /** If true that means Minecraft is - * rendering fog alongside us */ + /** + * If true that means Minecraft is + * rendering fog alongside us + */ public boolean vanillaIsRenderingFog = true; public NearFarFogSettings() diff --git a/src/main/java/com/seibel/lod/objects/PosToGenerateContainer.java b/src/main/java/com/seibel/lod/objects/PosToGenerateContainer.java index 66a9d5c3a..735210f1a 100644 --- a/src/main/java/com/seibel/lod/objects/PosToGenerateContainer.java +++ b/src/main/java/com/seibel/lod/objects/PosToGenerateContainer.java @@ -5,7 +5,6 @@ import com.seibel.lod.util.LevelPosUtil; /** * Holds the levelPos that need to be generated. * TODO is that correct? - * * @author Leonardo Amato * @version 9-27-2021 */ diff --git a/src/main/java/com/seibel/lod/objects/PosToRenderContainer.java b/src/main/java/com/seibel/lod/objects/PosToRenderContainer.java index 0ec131584..bfbf30bf2 100644 --- a/src/main/java/com/seibel/lod/objects/PosToRenderContainer.java +++ b/src/main/java/com/seibel/lod/objects/PosToRenderContainer.java @@ -7,7 +7,6 @@ import com.seibel.lod.util.LodUtil; import java.util.Arrays; /** - * * @author Leonardo Amato * @version 9-18-2021 */ @@ -20,7 +19,7 @@ public class PosToRenderContainer private int numberOfPosToRender; private int[] posToRender; /*TODO this population matrix could be converted to boolean to improve memory use - * no since bools are stored as bytes anyway - cola*/ + * no since bools are stored as bytes anyway - cola*/ private byte[][] population; public PosToRenderContainer(byte minDetail, int regionPosX, int regionPosZ) diff --git a/src/main/java/com/seibel/lod/objects/RegionPos.java b/src/main/java/com/seibel/lod/objects/RegionPos.java index 5adf4becb..b586090a0 100644 --- a/src/main/java/com/seibel/lod/objects/RegionPos.java +++ b/src/main/java/com/seibel/lod/objects/RegionPos.java @@ -15,16 +15,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package com.seibel.lod.objects; import com.seibel.lod.util.LodUtil; - import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; /** * This object is similar to ChunkPos or BlockPos. - * * @author James Seibel * @version 8-21-2021 */ @@ -36,7 +35,7 @@ public class RegionPos /** * Default Constructor

- * + *

* Sets x and z to 0 */ public RegionPos() @@ -69,7 +68,7 @@ public class RegionPos public ChunkPos chunkPos() { return new ChunkPos( - (x * LodUtil.REGION_WIDTH_IN_CHUNKS) + LodUtil.REGION_WIDTH_IN_CHUNKS / 2, + (x * LodUtil.REGION_WIDTH_IN_CHUNKS) + LodUtil.REGION_WIDTH_IN_CHUNKS / 2, (z * LodUtil.REGION_WIDTH_IN_CHUNKS) + LodUtil.REGION_WIDTH_IN_CHUNKS / 2); } diff --git a/src/main/java/com/seibel/lod/objects/VerticalLevelContainer.java b/src/main/java/com/seibel/lod/objects/VerticalLevelContainer.java index 2526b5523..fe6777612 100644 --- a/src/main/java/com/seibel/lod/objects/VerticalLevelContainer.java +++ b/src/main/java/com/seibel/lod/objects/VerticalLevelContainer.java @@ -1,22 +1,18 @@ package com.seibel.lod.objects; +import com.seibel.lod.util.*; + import java.util.Arrays; -import com.seibel.lod.util.DataPointUtil; -import com.seibel.lod.util.DetailDistanceUtil; -import com.seibel.lod.util.LevelPosUtil; -import com.seibel.lod.util.LodUtil; -import com.seibel.lod.util.ThreadMapUtil; - public class VerticalLevelContainer implements LevelContainer { - + public final byte detailLevel; public final int size; public final int maxVerticalData; - + public final long[] dataContainer; - + public VerticalLevelContainer(byte detailLevel) { this.detailLevel = detailLevel; @@ -24,65 +20,74 @@ public class VerticalLevelContainer implements LevelContainer maxVerticalData = DetailDistanceUtil.getMaxVerticalData(detailLevel); dataContainer = new long[size * size * DetailDistanceUtil.getMaxVerticalData(detailLevel)]; } - + @Override public byte getDetailLevel() { return detailLevel; } - + @Override - public void clear(int posX, int posZ){ - + public void clear(int posX, int posZ) + { + posX = LevelPosUtil.getRegionModule(detailLevel, posX); posZ = LevelPosUtil.getRegionModule(detailLevel, posZ); - for(int verticalIndex = 0; verticalIndex < maxVerticalData; verticalIndex++){ - dataContainer[posX*size*maxVerticalData + posZ*maxVerticalData + verticalIndex] = DataPointUtil.EMPTY_DATA; + for (int verticalIndex = 0; verticalIndex < maxVerticalData; verticalIndex++) + { + dataContainer[posX * size * maxVerticalData + posZ * maxVerticalData + verticalIndex] = DataPointUtil.EMPTY_DATA; } } - + @Override - public boolean addData(long data, int posX, int posZ, int verticalIndex){ - + public boolean addData(long data, int posX, int posZ, int verticalIndex) + { + posX = LevelPosUtil.getRegionModule(detailLevel, posX); posZ = LevelPosUtil.getRegionModule(detailLevel, posZ); - dataContainer[posX*size*maxVerticalData + posZ*maxVerticalData + verticalIndex] = data; + dataContainer[posX * size * maxVerticalData + posZ * maxVerticalData + verticalIndex] = data; return true; } - + @Override - public boolean addSingleData(long data, int posX, int posZ){ + public boolean addSingleData(long data, int posX, int posZ) + { return addData(data, posX, posZ, 0); } - + @Override - public long getData(int posX, int posZ, int verticalIndex){ + public long getData(int posX, int posZ, int verticalIndex) + { posX = LevelPosUtil.getRegionModule(detailLevel, posX); posZ = LevelPosUtil.getRegionModule(detailLevel, posZ); - return dataContainer[posX*size*maxVerticalData + posZ*maxVerticalData + verticalIndex]; + return dataContainer[posX * size * maxVerticalData + posZ * maxVerticalData + verticalIndex]; } - + @Override - public long getSingleData(int posX, int posZ){ - return getData(posX,posZ,0); + public long getSingleData(int posX, int posZ) + { + return getData(posX, posZ, 0); } - + @Override - public int getMaxVerticalData(){ + public int getMaxVerticalData() + { return maxVerticalData; } - - public int getSize(){ + + public int getSize() + { return size; } - + @Override - public boolean doesItExist(int posX, int posZ){ + public boolean doesItExist(int posX, int posZ) + { posX = LevelPosUtil.getRegionModule(detailLevel, posX); posZ = LevelPosUtil.getRegionModule(detailLevel, posZ); - return DataPointUtil.doesItExist(getSingleData(posX,posZ)); + return DataPointUtil.doesItExist(getSingleData(posX, posZ)); } - + public VerticalLevelContainer(byte[] inputData) { int tempIndex; @@ -97,7 +102,7 @@ public class VerticalLevelContainer implements LevelContainer size = (int) Math.pow(2, LodUtil.REGION_DETAIL_LEVEL - detailLevel); int x = size * size * maxVerticalData; this.dataContainer = new long[x]; - for ( int i = 0; i < x; i++) + for (int i = 0; i < x; i++) { newData = 0; if (counter > -1) @@ -105,15 +110,17 @@ public class VerticalLevelContainer implements LevelContainer dataContainer[i] = last; if (last == 3) { //skip rest of void chunk - for (tempIndex = 1; tempIndex < maxVerticalData; tempIndex++) { + for (tempIndex = 1; tempIndex < maxVerticalData; tempIndex++) + { dataContainer[i + tempIndex] = 0; } i += maxVerticalData - 1; } counter--; - } else if ((inputData[index] & 0x3) == 0 || (inputData[index] & 0x3) == 3) + } + else if ((inputData[index] & 0x3) == 0 || (inputData[index] & 0x3) == 3) { - last = (byte)(inputData[index] & 0x3); + last = (byte) (inputData[index] & 0x3); //recover counter counter = (inputData[index] & 0x7c) >>> 2; tempIndex = 0; @@ -126,9 +133,11 @@ public class VerticalLevelContainer implements LevelContainer index++; //since loop expects from us to put some data in, we just make it rerun it with new counter; i--; - } else if (index + 7 >= inputData.length) + } + else if (index + 7 >= inputData.length) break; - else { + else + { for (tempIndex = 0; tempIndex < 8; tempIndex++) newData += (((long) inputData[index + tempIndex]) & 0xff) << (8 * tempIndex); index = index + 8; @@ -136,19 +145,20 @@ public class VerticalLevelContainer implements LevelContainer } } } - + @Override - public LevelContainer expand(){ + public LevelContainer expand() + { return new VerticalLevelContainer((byte) (getDetailLevel() - 1)); } - + @Override public void updateData(LevelContainer lowerLevelContainer, int posX, int posZ) { //We reset the array long[] dataToMerge = ThreadMapUtil.getVerticalUpdateArray(detailLevel); - - int lowerMaxVertical = dataToMerge.length/4; + + int lowerMaxVertical = dataToMerge.length / 4; int childPosX; int childPosZ; long[] data; @@ -160,13 +170,13 @@ public class VerticalLevelContainer implements LevelContainer { childPosX = 2 * posX + x; childPosZ = 2 * posZ + z; - for(int verticalIndex = 0; verticalIndex < lowerMaxVertical; verticalIndex++) - dataToMerge[(z*2+x)*lowerMaxVertical + verticalIndex] = lowerLevelContainer.getData(childPosX, childPosZ, verticalIndex); + for (int verticalIndex = 0; verticalIndex < lowerMaxVertical; verticalIndex++) + dataToMerge[(z * 2 + x) * lowerMaxVertical + verticalIndex] = lowerLevelContainer.getData(childPosX, childPosZ, verticalIndex); } } data = DataPointUtil.mergeMultiData(dataToMerge, lowerMaxVertical, getMaxVerticalData()); - for(int verticalIndex = 0; (verticalIndex < data.length) && (verticalIndex < maxVerticalData); verticalIndex++) + for (int verticalIndex = 0; (verticalIndex < data.length) && (verticalIndex < maxVerticalData); verticalIndex++) { addData(data[verticalIndex], posX, @@ -174,7 +184,7 @@ public class VerticalLevelContainer implements LevelContainer verticalIndex); } } - + @Override public byte[] toDataString() { @@ -186,12 +196,12 @@ public class VerticalLevelContainer implements LevelContainer long current; byte[] tempData = ThreadMapUtil.getSaveContainer(2 + (x * 8)); - + tempData[index] = detailLevel; index++; tempData[index] = (byte) maxVerticalData; index++; - + for (int i = 0; i < x; i++) { current = dataContainer[i]; @@ -202,21 +212,23 @@ public class VerticalLevelContainer implements LevelContainer if (current == 3) //skip rest of void chunk i += maxVerticalData - 1; counter++; - } else { + } + else + { for (tempIndex = 0; tempIndex < 8; tempIndex++) tempData[index + tempIndex] = (byte) (current >>> (8 * tempIndex)); index += 8; } - if (last != -1 && ( i == x - 1 || last != ((dataContainer[i + 1]) & 0b11))) + if (last != -1 && (i == x - 1 || last != ((dataContainer[i + 1]) & 0b11))) { //save compressed data if next is different or if we reached onf of the data - tempData[index] = (byte)(0x7f & ((counter << 2) + last)); //save 5 bits of counter and compressed block - + tempData[index] = (byte) (0x7f & ((counter << 2) + last)); //save 5 bits of counter and compressed block + tempIndex = 0; while ((counter >>> (5 + 7 * tempIndex)) != 0) //there is more of that counter { - tempData[index] = (byte)(tempData[index] | 0x80); //set overflow bit to true + tempData[index] = (byte) (tempData[index] | 0x80); //set overflow bit to true index++; // after setting overflow bit w can actually index++ - tempData[index] = (byte)(0x7f & (counter >>> (5 + 7 * tempIndex))); // save 7 bits of counter + tempData[index] = (byte) (0x7f & (counter >>> (5 + 7 * tempIndex))); // save 7 bits of counter tempIndex++; } index++; @@ -226,7 +238,7 @@ public class VerticalLevelContainer implements LevelContainer } return Arrays.copyOfRange(tempData, 0, index); } - + @Override public String toString() { @@ -248,14 +260,16 @@ public class VerticalLevelContainer implements LevelContainer */ return " "; } - + @Override - public int getMaxNumberOfLods(){ - return size*size*getMaxVerticalData(); + public int getMaxNumberOfLods() + { + return size * size * getMaxVerticalData(); } - + @Override - public int getMaxMemoryUse(){ + public int getMaxMemoryUse() + { return getMaxNumberOfLods() * 2; //2 byte } } diff --git a/src/main/java/com/seibel/lod/proxy/ClientProxy.java b/src/main/java/com/seibel/lod/proxy/ClientProxy.java index d4728ee01..463fd9baf 100644 --- a/src/main/java/com/seibel/lod/proxy/ClientProxy.java +++ b/src/main/java/com/seibel/lod/proxy/ClientProxy.java @@ -18,10 +18,6 @@ package com.seibel.lod.proxy; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.lwjgl.glfw.GLFW; - import com.mojang.blaze3d.matrix.MatrixStack; import com.seibel.lod.builders.bufferBuilding.LodBufferBuilder; import com.seibel.lod.builders.lodBuilding.LodBuilder; @@ -38,7 +34,6 @@ import com.seibel.lod.util.DetailDistanceUtil; import com.seibel.lod.util.LodUtil; import com.seibel.lod.util.ThreadMapUtil; import com.seibel.lod.wrappers.MinecraftWrapper; - import net.minecraft.profiler.IProfiler; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.client.event.InputEvent; @@ -47,11 +42,13 @@ import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.glfw.GLFW; /** * This handles all events sent to the client, * and is the starting point for most of the mod. - * * @author James_Seibel * @version 9-26-2021 */ diff --git a/src/main/java/com/seibel/lod/proxy/GlProxy.java b/src/main/java/com/seibel/lod/proxy/GlProxy.java index fc9e8200d..bc1bc8b3b 100644 --- a/src/main/java/com/seibel/lod/proxy/GlProxy.java +++ b/src/main/java/com/seibel/lod/proxy/GlProxy.java @@ -12,12 +12,10 @@ import org.lwjgl.opengl.GLCapabilities; * *

* Helpful OpenGL resources:

- * + *

* https://www.seas.upenn.edu/~pcozzi/OpenGLInsights/OpenGLInsights-AsynchronousBufferTransfers.pdf
* https://learnopengl.com/Advanced-OpenGL/Advanced-Data
* https://gamedev.stackexchange.com/questions/91995/edit-vbo-data-or-create-a-new-one

- * - * * @author James Seibel * @version 10-2-2021 */ @@ -35,8 +33,10 @@ public class GlProxy /** the LodBuilder's GL context */ public final GLCapabilities lodBuilderGlCapabilities; - /** This is just used for debugging, hopefully it can be removed once - * the context switching is more stable. */ + /** + * This is just used for debugging, hopefully it can be removed once + * the context switching is more stable. + */ public Thread lodBuilderOwnerThread = null; /** Does this computer's GPU support fancy fog? */ @@ -88,9 +88,7 @@ public class GlProxy fancyFogAvailable = GL.getCapabilities().GL_NV_fog_distance; if (!fancyFogAvailable) - { ClientProxy.LOGGER.info("This GPU does not support GL_NV_fog_distance. This means that the fancy fog option will not be available."); - } } diff --git a/src/main/java/com/seibel/lod/render/LodRenderer.java b/src/main/java/com/seibel/lod/render/LodRenderer.java index 070435c4e..abcf8978d 100644 --- a/src/main/java/com/seibel/lod/render/LodRenderer.java +++ b/src/main/java/com/seibel/lod/render/LodRenderer.java @@ -18,24 +18,13 @@ package com.seibel.lod.render; -import java.util.HashSet; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL15; -import org.lwjgl.opengl.GL15C; -import org.lwjgl.opengl.NVFogDistance; - import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.seibel.lod.builders.bufferBuilding.LodBufferBuilder; import com.seibel.lod.builders.bufferBuilding.LodBufferBuilder.VertexBuffersAndOffset; import com.seibel.lod.config.LodConfig; -import com.seibel.lod.enums.DebugMode; -import com.seibel.lod.enums.DetailDropOff; -import com.seibel.lod.enums.FogDistance; -import com.seibel.lod.enums.FogDrawOverride; -import com.seibel.lod.enums.FogQuality; +import com.seibel.lod.enums.*; import com.seibel.lod.handlers.ReflectionHandler; import com.seibel.lod.objects.LodDimension; import com.seibel.lod.objects.NearFarFogSettings; @@ -46,7 +35,6 @@ import com.seibel.lod.util.DetailDistanceUtil; import com.seibel.lod.util.LevelPosUtil; import com.seibel.lod.util.LodUtil; import com.seibel.lod.wrappers.MinecraftWrapper; - import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.FogRenderer; import net.minecraft.client.renderer.GameRenderer; @@ -57,12 +45,17 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.util.math.vector.Vector3d; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL15; +import org.lwjgl.opengl.GL15C; +import org.lwjgl.opengl.NVFogDistance; + +import java.util.HashSet; /** * This is where all the magic happens.
* This is where LODs are draw to the world. - * * @author James Seibel * @version 10-11-2021 */ @@ -152,10 +145,9 @@ public class LodRenderer /** * Besides drawing the LODs this method also starts * the async process of generating the Buffers that hold those LODs. - * - * @param lodDim The dimension to draw, if null doesn't replace the current dimension. + * @param lodDim The dimension to draw, if null doesn't replace the current dimension. * @param mcMatrixStack This matrix stack should come straight from MC's renderChunkLayer (or future equivalent) method - * @param partialTicks how far into the current tick this method was called. + * @param partialTicks how far into the current tick this method was called. */ @SuppressWarnings("deprecation") public void drawLODs(LodDimension lodDim, MatrixStack mcMatrixStack, float partialTicks, IProfiler newProfiler) @@ -517,9 +509,8 @@ public class LodRenderer /** * create a new projection matrix and send it over to the GPU - * * @param currentProjectionMatrix this is Minecraft's current projection matrix - * @param partialTicks how many ticks into the frame we are + * @param partialTicks how many ticks into the frame we are */ private void setupProjectionMatrix(Matrix4f currentProjectionMatrix, float partialTicks) { diff --git a/src/main/java/com/seibel/lod/render/RenderUtil.java b/src/main/java/com/seibel/lod/render/RenderUtil.java index c571d2bda..3218db85f 100644 --- a/src/main/java/com/seibel/lod/render/RenderUtil.java +++ b/src/main/java/com/seibel/lod/render/RenderUtil.java @@ -20,7 +20,6 @@ package com.seibel.lod.render; import com.seibel.lod.util.LodUtil; import com.seibel.lod.wrappers.MinecraftWrapper; - import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.vector.Vector3d; @@ -28,7 +27,6 @@ import net.minecraft.util.math.vector.Vector3d; /** * This holds miscellaneous helper code * to be used in the rendering process. - * * @author James Seibel * @version 10-10-2021 */ @@ -47,7 +45,7 @@ public class RenderUtil && pos.x <= center.x + mc.getRenderDistance()) && (pos.z >= center.z - mc.getRenderDistance() - && pos.z <= center.z + mc.getRenderDistance()); + && pos.z <= center.z + mc.getRenderDistance()); } /** @@ -60,7 +58,7 @@ public class RenderUtil && x <= centerCoordinate + mc.getRenderDistance()) && (z >= centerCoordinate - mc.getRenderDistance() - && z <= centerCoordinate + mc.getRenderDistance()); + && z <= centerCoordinate + mc.getRenderDistance()); } @@ -76,7 +74,7 @@ public class RenderUtil && i <= lodRadius + halfRadius) && (j >= lodRadius - halfRadius - && j <= lodRadius + halfRadius); + && j <= lodRadius + halfRadius); } diff --git a/src/main/java/com/seibel/lod/util/ColorUtil.java b/src/main/java/com/seibel/lod/util/ColorUtil.java index 3972ee651..ecb6c5990 100644 --- a/src/main/java/com/seibel/lod/util/ColorUtil.java +++ b/src/main/java/com/seibel/lod/util/ColorUtil.java @@ -8,54 +8,56 @@ public class ColorUtil { return (0xFF << 24) | (red << 16) | (green << 8) | blue; } - + public static int rgbToInt(int alpha, int red, int green, int blue) { return (alpha << 24) | (red << 16) | (green << 8) | blue; } - + public static int getAlpha(int color) { return (color >> 24) & 0xFF; } - + public static int getRed(int color) { return (color >> 16) & 0xFF; } - + public static int getGreen(int color) { return (color >> 8) & 0xFF; } - + public static int getBlue(int color) { return color & 0xFF; } - + public static int applyShade(int color, int shade) { if (shade < 0) { return (getAlpha(color) << 24) | (Math.max(getRed(color) + shade, 0) << 16) | (Math.max(getGreen(color) + shade, 0) << 8) | Math.max(getBlue(color) + shade, 0); - } else + } + else { return (getAlpha(color) << 24) | (Math.min(getRed(color) + shade, 255) << 16) | (Math.min(getGreen(color) + shade, 255) << 8) | Math.min(getBlue(color) + shade, 255); } } - + public static int applyShade(int color, float shade) { if (shade < 1) { return (getAlpha(color) << 24) | ((int) Math.max(getRed(color) * shade, 0) << 16) | ((int) Math.max(getGreen(color) * shade, 0) << 8) | (int) Math.max(getBlue(color) * shade, 0); - } else + } + else { return (getAlpha(color) << 24) | ((int) Math.min(getRed(color) * shade, 255) << 16) | ((int) Math.min(getGreen(color) * shade, 255) << 8) | (int) Math.min(getBlue(color) * shade, 255); } } - + /** * Edit the given color as an HSV (Hue Saturation Value) color. */ @@ -67,7 +69,7 @@ public class ColorUtil LodUtil.clamp(0.0f, hsv[1] * saturationMultiplier, 1.0f), LodUtil.clamp(0.0f, hsv[2] * brightnessMultiplier, 1.0f)).getRGB(); } - + /** * Edit the given color as an HSV (Hue Saturation Value) color. */ @@ -79,7 +81,7 @@ public class ColorUtil hsv[1], brightness).getRGB(); } - + /** * Edit the given color as an HSV (Hue Saturation Value) color. */ @@ -92,12 +94,13 @@ public class ColorUtil hsv[1], brightness).getRGB(); } + public static int multiplyRGBcolors(int color1, int color2) { return ((getAlpha(color1) * getAlpha(color2) / 255) << 24) | ((getRed(color1) * getRed(color2) / 255) << 16) | ((getGreen(color1) * getGreen(color2) / 255) << 8) | (getBlue(color1) * getBlue(color2) / 255); } - - + + public static String toString(int color) { return Integer.toHexString(getAlpha(color)) + diff --git a/src/main/java/com/seibel/lod/util/DataPointUtil.java b/src/main/java/com/seibel/lod/util/DataPointUtil.java index d474306b7..67e12b2de 100644 --- a/src/main/java/com/seibel/lod/util/DataPointUtil.java +++ b/src/main/java/com/seibel/lod/util/DataPointUtil.java @@ -173,7 +173,7 @@ public class DataPointUtil { return (int) (((dataPoint >>> COLOR_SHIFT) & COLOR_MASK) | (((dataPoint >>> (ALPHA_SHIFT - ALPHA_DOWNSIZE_SHIFT)) | 0b1111) << 24)); } - + /** This method apply the lightmap to the color to use */ public static int getLightColor(long dataPoint, NativeImage lightMap) { @@ -186,7 +186,7 @@ public class DataPointUtil return ColorUtil.multiplyRGBcolors(getColor(dataPoint), ColorUtil.rgbToInt(red, green, blue)); } - + /** This is used to convert a dataPoint to string (useful for the print function) */ public static String toString(long dataPoint) { @@ -227,7 +227,7 @@ public class DataPointUtil array[start + i] = 0; } } - + /** * This method merge column of multiple data together * @param dataToMerge one or more columns of data @@ -405,7 +405,7 @@ public class DataPointUtil ii = worldHeight; for (i = 0; i < count - 1; i++) { - if (heightAndDepth[i * 2 + 1] - heightAndDepth[(i + 1) * 2]< ii) + if (heightAndDepth[i * 2 + 1] - heightAndDepth[(i + 1) * 2] < ii) { ii = heightAndDepth[i * 2 + 1] - heightAndDepth[(i + 1) * 2]; j = i; @@ -428,7 +428,7 @@ public class DataPointUtil if ((depth == 0 && height == 0) || j >= heightAndDepth.length / 2) break; - + int numberOfChildren = 0; int tempAlpha = 0; int tempRed = 0; @@ -448,7 +448,7 @@ public class DataPointUtil singleData = dataToMerge[index * inputVerticalData + dataIndex]; if (doesItExist(singleData) && !isVoid(singleData)) { - + if ((depth <= getDepth(singleData) && getDepth(singleData) <= height) || (depth <= getHeight(singleData) && getHeight(singleData) <= height)) { @@ -459,7 +459,8 @@ public class DataPointUtil else break; } - if(!doesItExist(data)){ + if (!doesItExist(data)) + { singleData = dataToMerge[index * inputVerticalData]; data = createVoidDataPoint(getGenerationMode(singleData)); } diff --git a/src/main/java/com/seibel/lod/util/LodThreadFactory.java b/src/main/java/com/seibel/lod/util/LodThreadFactory.java index 3d5bc2889..1c861564c 100644 --- a/src/main/java/com/seibel/lod/util/LodThreadFactory.java +++ b/src/main/java/com/seibel/lod/util/LodThreadFactory.java @@ -5,7 +5,6 @@ import java.util.concurrent.ThreadFactory; /** * Just a simple ThreadFactory to name ExecutorService * threads, which can be helpful when debugging. - * * @author James Seibel * @version 8-15-2021 */ @@ -22,7 +21,7 @@ public class LodThreadFactory implements ThreadFactory @Override public Thread newThread(Runnable r) { - return new Thread(r, threadName); + return new Thread(r, threadName); } } diff --git a/src/main/java/com/seibel/lod/util/LodUtil.java b/src/main/java/com/seibel/lod/util/LodUtil.java index 4d02eb5ab..176f690f6 100644 --- a/src/main/java/com/seibel/lod/util/LodUtil.java +++ b/src/main/java/com/seibel/lod/util/LodUtil.java @@ -18,17 +18,12 @@ package com.seibel.lod.util; -import java.awt.Color; -import java.io.File; -import java.util.HashSet; - import com.seibel.lod.builders.bufferBuilding.lodTemplates.Box; import com.seibel.lod.config.LodConfig; import com.seibel.lod.enums.VanillaOverdraw; import com.seibel.lod.objects.LodDimension; import com.seibel.lod.objects.RegionPos; import com.seibel.lod.wrappers.MinecraftWrapper; - import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher.CompiledChunk; @@ -46,9 +41,12 @@ import net.minecraft.world.gen.Heightmap; import net.minecraft.world.server.ServerChunkProvider; import net.minecraft.world.server.ServerWorld; +import java.awt.*; +import java.io.File; +import java.util.HashSet; + /** * This class holds methods and constants that may be used in multiple places. - * * @author James Seibel * @version 10-11-2021 */ @@ -58,7 +56,7 @@ public class LodUtil /** * vanilla render distances less than or equal to this will not allow partial - * overdraw. The VanillaOverdraw with either be ALWAYS or NEVER. + * overdraw. The VanillaOverdraw with either be ALWAYS or NEVER. */ public static final int MINIMUM_RENDER_DISTANCE_FOR_PARTIAL_OVERDRAW = 5; @@ -156,7 +154,6 @@ public class LodUtil /** * Gets the first valid ServerWorld. - * * @return null if there are no ServerWorlds */ public static ServerWorld getFirstValidServerWorld() @@ -174,7 +171,6 @@ public class LodUtil /** * Gets the ServerWorld for the relevant dimension. - * * @return null if there is no ServerWorld for the given dimension */ public static ServerWorld getServerWorldFromDimension(DimensionType dimension) @@ -371,7 +367,7 @@ public class LodUtil VanillaOverdraw overdraw = LodConfig.CLIENT.graphics.vanillaOverdraw.get(); // apply distance based rules for dynamic - if (overdraw == VanillaOverdraw.DYNAMIC + if (overdraw == VanillaOverdraw.DYNAMIC && chunkRenderDist <= MINIMUM_RENDER_DISTANCE_FOR_PARTIAL_OVERDRAW) { // The vanilla render distance isn't far enough @@ -399,13 +395,13 @@ public class LodUtil case ALWAYS: // don't skip any positions return new HashSet(); - + case DYNAMIC: // only skip positions that are greater than // 4/5ths the render distance skipRadius = (int) Math.ceil(chunkRenderDist * (4.0 / 5.0)); break; - + default: case NEVER: // skip chunks in render distance that are rendered @@ -428,8 +424,8 @@ public class LodUtil for (int z = centerChunk.z - chunkRenderDist; z < centerChunk.z + chunkRenderDist; z++) { if (x <= centerChunk.x - skipRadius || x >= centerChunk.x + skipRadius - || - z <= centerChunk.z - skipRadius || z >= centerChunk.z + skipRadius) + || + z <= centerChunk.z - skipRadius || z >= centerChunk.z + skipRadius) { posToSkip.remove(new ChunkPos(x, z)); continue; diff --git a/src/main/java/com/seibel/lod/util/ThreadMapUtil.java b/src/main/java/com/seibel/lod/util/ThreadMapUtil.java index 9225df9b8..ab8516c2d 100644 --- a/src/main/java/com/seibel/lod/util/ThreadMapUtil.java +++ b/src/main/java/com/seibel/lod/util/ThreadMapUtil.java @@ -10,10 +10,9 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; /** - * Holds data used by specific threads so + * Holds data used by specific threads so * the data doesn't have to be recreated every * time it is needed. - * * @author Leonardo Amato * @version 9-25-2021 */ @@ -95,35 +94,6 @@ public class ThreadMapUtil - /** returns the array NOT cleared every time */ - public static long[] getSingleUpdateArray() - { - if (!threadSingleUpdateMap.containsKey(Thread.currentThread().getName()) || (threadSingleUpdateMap.get(Thread.currentThread().getName()) == null)) - { - threadSingleUpdateMap.put(Thread.currentThread().getName(), new long[4]); - } - return threadSingleUpdateMap.get(Thread.currentThread().getName()); - } - - - /** returns the array NOT cleared every time */ - public static long[] getBuilderArray(int detailLevel) - { - if (!threadBuilderArrayMap.containsKey(Thread.currentThread().getName()) || (threadBuilderArrayMap.get(Thread.currentThread().getName()) == null)) - { - long[][] array = new long[5][]; - int size = 1; - for (int i = 0; i < 5; i++) - { - array[i] = new long[size * size]; - size = size << 1; - } - threadBuilderArrayMap.put(Thread.currentThread().getName(), array); - } - return threadBuilderArrayMap.get(Thread.currentThread().getName())[detailLevel]; - } - - /** returns the array filled with 0's */ public static long[] getBuilderVerticalArray(int detailLevel) { diff --git a/src/main/java/com/seibel/lod/wrappers/MinecraftWrapper.java b/src/main/java/com/seibel/lod/wrappers/MinecraftWrapper.java index a8b00f384..a0c32fce1 100644 --- a/src/main/java/com/seibel/lod/wrappers/MinecraftWrapper.java +++ b/src/main/java/com/seibel/lod/wrappers/MinecraftWrapper.java @@ -1,10 +1,6 @@ package com.seibel.lod.wrappers; -import java.awt.Color; -import java.io.File; - import com.seibel.lod.util.LodUtil; - import net.minecraft.client.GameSettings; import net.minecraft.client.MainWindow; import net.minecraft.client.Minecraft; @@ -23,10 +19,12 @@ import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.util.Direction; import net.minecraft.world.DimensionType; +import java.awt.*; +import java.io.File; + /** * A singleton that wraps the Minecraft class * to allow for easier movement between Minecraft versions. - * * @author James Seibel * @version 9-16-2021 */ @@ -36,8 +34,10 @@ public class MinecraftWrapper private final Minecraft mc = Minecraft.getInstance(); - /** The lightmap for the current: - * Time, dimension, brightness setting, etc. */ + /** + * The lightmap for the current: + * Time, dimension, brightness setting, etc. + */ private NativeImage lightMap = null; private MinecraftWrapper() @@ -54,9 +54,9 @@ public class MinecraftWrapper /** * This should be called at the beginning of every frame to * clear any Minecraft data that becomes out of date after a frame.

- * + *

* LightMaps and other time sensitive objects fall in this category.

- * + *

* This doesn't affect OpenGL objects in any way. */ public void clearFrameObjectCache() @@ -90,7 +90,7 @@ public class MinecraftWrapper return LodUtil.getDimensionIDFromWorld(mc.level); } - /** + /** * This texture changes every frame */ public NativeImage getCurrentLightMap() @@ -101,7 +101,7 @@ public class MinecraftWrapper LightTexture tex = mc.gameRenderer.lightTexture(); lightMap = tex.lightPixels; } - + // // hotswap this to true, then back to false to write a file // // (and not write a file every frame) // if (false) @@ -123,7 +123,6 @@ public class MinecraftWrapper /** * Returns the color int at the given pixel coordinates * from the current lightmap. - * * @param u x location in texture space * @param v z location in texture space */ @@ -141,7 +140,6 @@ public class MinecraftWrapper /** * Returns the Color at the given pixel coordinates * from the current lightmap. - * * @param u x location in texture space * @param v z location in texture space */ @@ -166,7 +164,7 @@ public class MinecraftWrapper { return mc.options; } - + public ModelManager getModelManager() { return mc.getModelManager(); @@ -174,9 +172,9 @@ public class MinecraftWrapper public ClientWorld getClientWorld() { - return mc.level; + return mc.level; } - + /** Measured in chunks */ public int getRenderDistance() { From 80edf19b33a57e224464e388361b49470157e1c4 Mon Sep 17 00:00:00 2001 From: cola98765 Date: Wed, 13 Oct 2021 13:24:07 +0200 Subject: [PATCH 4/7] cleaned out some code. --- .../lod/objects/VerticalLevelContainer.java | 1 + .../java/com/seibel/lod/util/ColorUtil.java | 49 +++---------------- .../com/seibel/lod/util/DataPointUtil.java | 3 +- .../seibel/lod/util/DetailDistanceUtil.java | 14 ------ .../com/seibel/lod/util/LevelPosUtil.java | 5 +- 5 files changed, 13 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/seibel/lod/objects/VerticalLevelContainer.java b/src/main/java/com/seibel/lod/objects/VerticalLevelContainer.java index fe6777612..450306c01 100644 --- a/src/main/java/com/seibel/lod/objects/VerticalLevelContainer.java +++ b/src/main/java/com/seibel/lod/objects/VerticalLevelContainer.java @@ -240,6 +240,7 @@ public class VerticalLevelContainer implements LevelContainer } @Override + @SuppressWarnings("unused") public String toString() { /* diff --git a/src/main/java/com/seibel/lod/util/ColorUtil.java b/src/main/java/com/seibel/lod/util/ColorUtil.java index ecb6c5990..2ddfdbaf9 100644 --- a/src/main/java/com/seibel/lod/util/ColorUtil.java +++ b/src/main/java/com/seibel/lod/util/ColorUtil.java @@ -37,30 +37,20 @@ public class ColorUtil public static int applyShade(int color, int shade) { if (shade < 0) - { return (getAlpha(color) << 24) | (Math.max(getRed(color) + shade, 0) << 16) | (Math.max(getGreen(color) + shade, 0) << 8) | Math.max(getBlue(color) + shade, 0); - } else - { return (getAlpha(color) << 24) | (Math.min(getRed(color) + shade, 255) << 16) | (Math.min(getGreen(color) + shade, 255) << 8) | Math.min(getBlue(color) + shade, 255); - } } public static int applyShade(int color, float shade) { if (shade < 1) - { return (getAlpha(color) << 24) | ((int) Math.max(getRed(color) * shade, 0) << 16) | ((int) Math.max(getGreen(color) * shade, 0) << 8) | (int) Math.max(getBlue(color) * shade, 0); - } else - { return (getAlpha(color) << 24) | ((int) Math.min(getRed(color) * shade, 255) << 16) | ((int) Math.min(getGreen(color) * shade, 255) << 8) | (int) Math.min(getBlue(color) * shade, 255); - } } - /** - * Edit the given color as an HSV (Hue Saturation Value) color. - */ + /** Edit the given color as an HSV (Hue Saturation Value) color */ public static int applySaturationAndBrightnessMultipliers(int color, float saturationMultiplier, float brightnessMultiplier) { float[] hsv = Color.RGBtoHSB(getRed(color), getGreen(color), getBlue(color), null); @@ -70,45 +60,18 @@ public class ColorUtil LodUtil.clamp(0.0f, hsv[2] * brightnessMultiplier, 1.0f)).getRGB(); } - /** - * Edit the given color as an HSV (Hue Saturation Value) color. - */ - public static int changeBrightness(int color, float brightness) - { - float[] hsv = Color.RGBtoHSB(getRed(color), getGreen(color), getBlue(color), null); - return Color.getHSBColor( - hsv[0], // hue - hsv[1], - brightness).getRGB(); - } - - /** - * Edit the given color as an HSV (Hue Saturation Value) color. - */ - public static int changeBrightnessValue(int color, int brightnessColor) - { - float[] hsv = Color.RGBtoHSB(getRed(color), getGreen(color), getBlue(color), null); - float brightness = Color.RGBtoHSB(getRed(brightnessColor), getGreen(brightnessColor), getBlue(brightnessColor), null)[2]; - return Color.getHSBColor( - hsv[0], // hue - hsv[1], - brightness).getRGB(); - } - + /** Multiply 2 RGB colors */ public static int multiplyRGBcolors(int color1, int color2) { return ((getAlpha(color1) * getAlpha(color2) / 255) << 24) | ((getRed(color1) * getRed(color2) / 255) << 16) | ((getGreen(color1) * getGreen(color2) / 255) << 8) | (getBlue(color1) * getBlue(color2) / 255); } - + @SuppressWarnings("unused") public static String toString(int color) { - return Integer.toHexString(getAlpha(color)) + - " " + - Integer.toHexString(getRed(color)) + - " " + - Integer.toHexString(getGreen(color)) + - " " + + return Integer.toHexString(getAlpha(color)) + " " + + Integer.toHexString(getRed(color)) + " " + + Integer.toHexString(getGreen(color)) + " " + Integer.toHexString(getBlue(color)); } } diff --git a/src/main/java/com/seibel/lod/util/DataPointUtil.java b/src/main/java/com/seibel/lod/util/DataPointUtil.java index 67e12b2de..8f91b693b 100644 --- a/src/main/java/com/seibel/lod/util/DataPointUtil.java +++ b/src/main/java/com/seibel/lod/util/DataPointUtil.java @@ -188,6 +188,7 @@ public class DataPointUtil } /** This is used to convert a dataPoint to string (useful for the print function) */ + @SuppressWarnings("unused") public static String toString(long dataPoint) { return getHeight(dataPoint) + " " + @@ -233,7 +234,7 @@ public class DataPointUtil * @param dataToMerge one or more columns of data * @param inputVerticalData vertical size of an input data * @param maxVerticalData max vertical size of the merged data - * @return 1 column of correctly parsed data + * @return one column of correctly parsed data */ public static long[] mergeMultiData(long[] dataToMerge, int inputVerticalData, int maxVerticalData) { diff --git a/src/main/java/com/seibel/lod/util/DetailDistanceUtil.java b/src/main/java/com/seibel/lod/util/DetailDistanceUtil.java index f1dd9a255..28dee6a21 100644 --- a/src/main/java/com/seibel/lod/util/DetailDistanceUtil.java +++ b/src/main/java/com/seibel/lod/util/DetailDistanceUtil.java @@ -17,20 +17,6 @@ public class DetailDistanceUtil private static int maxDistance = LodConfig.CLIENT.graphics.lodChunkRenderDistance.get() * 16 * 2; - private static final int[] maxVerticalData = { - 4, - 4, - 4, - 2, - 2, - 1, - 1, - 1, - 1, - 1, - 1 }; - - private static final HorizontalResolution[] lodGenDetails = { HorizontalResolution.BLOCK, HorizontalResolution.TWO_BLOCKS, diff --git a/src/main/java/com/seibel/lod/util/LevelPosUtil.java b/src/main/java/com/seibel/lod/util/LevelPosUtil.java index b7f5b7958..4f67c36d1 100644 --- a/src/main/java/com/seibel/lod/util/LevelPosUtil.java +++ b/src/main/java/com/seibel/lod/util/LevelPosUtil.java @@ -221,9 +221,12 @@ public class LevelPosUtil return compareResult; } + @SuppressWarnings("unused") public static String toString(int[] levelPos) { - return (getDetailLevel(levelPos) + " " + getPosX(levelPos) + " " + getPosZ(levelPos)); + return (getDetailLevel(levelPos) + " " + + getPosX(levelPos) + " " + + getPosZ(levelPos)); } public static String toString(byte detailLevel, int posX, int posZ) From ef4ba7208ed38347ad6be08ec5ecb8743c5e3808 Mon Sep 17 00:00:00 2001 From: cola98765 Date: Wed, 13 Oct 2021 13:31:47 +0200 Subject: [PATCH 5/7] cleaned out some code. --- .../lod/builders/bufferBuilding/LodBufferBuilder.java | 4 +--- src/main/java/com/seibel/lod/util/LodUtil.java | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java index 755b0f4aa..3b7b9f836 100644 --- a/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java +++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java @@ -180,9 +180,7 @@ public class LodBufferBuilder Thread thread = new Thread(() -> - { - generateLodBuffersThread(renderer, lodDim, playerBlockPos, fullRegen); - }); + generateLodBuffersThread(renderer, lodDim, playerBlockPos, fullRegen)); mainGenThread.execute(thread); } diff --git a/src/main/java/com/seibel/lod/util/LodUtil.java b/src/main/java/com/seibel/lod/util/LodUtil.java index 176f690f6..955d63e6a 100644 --- a/src/main/java/com/seibel/lod/util/LodUtil.java +++ b/src/main/java/com/seibel/lod/util/LodUtil.java @@ -394,7 +394,7 @@ public class LodUtil { case ALWAYS: // don't skip any positions - return new HashSet(); + return new HashSet<>(); case DYNAMIC: // only skip positions that are greater than @@ -424,11 +424,9 @@ public class LodUtil for (int z = centerChunk.z - chunkRenderDist; z < centerChunk.z + chunkRenderDist; z++) { if (x <= centerChunk.x - skipRadius || x >= centerChunk.x + skipRadius - || - z <= centerChunk.z - skipRadius || z >= centerChunk.z + skipRadius) + || z <= centerChunk.z - skipRadius || z >= centerChunk.z + skipRadius) { posToSkip.remove(new ChunkPos(x, z)); - continue; } } } From 5f9f20a0641c5b343f337ecd81a680a8d27b551c Mon Sep 17 00:00:00 2001 From: cola98765 Date: Wed, 13 Oct 2021 13:45:23 +0200 Subject: [PATCH 6/7] cleaned out some code. --- .../lod/builders/bufferBuilding/LodBufferBuilder.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java index 3b7b9f836..cdf72c067 100644 --- a/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java +++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/LodBufferBuilder.java @@ -767,13 +767,13 @@ public class LodBufferBuilder - if (printExpansionLog) + /*if (printExpansionLog) { // NOTE: this will display twice because we are double buffering // (using 1 buffer to generate into and one to draw) -// ClientProxy.LOGGER.info("vbo (" + xVboIndex + "," + zVboIndex + ") expanded: " + bufferPreviousCapacity[xVboIndex][zVboIndex][iVboIndex] + " -> " + (int)(uploadBuffer.capacity() * BUFFER_EXPANSION_MULTIPLIER)); -// bufferPreviousCapacity[xVboIndex][zVboIndex][iVboIndex] = (int) (uploadBuffer.capacity() * BUFFER_EXPANSION_MULTIPLIER); - } + ClientProxy.LOGGER.info("vbo (" + xVboIndex + "," + zVboIndex + ") expanded: " + bufferPreviousCapacity[xVboIndex][zVboIndex][iVboIndex] + " -> " + (int)(uploadBuffer.capacity() * BUFFER_EXPANSION_MULTIPLIER)); + bufferPreviousCapacity[xVboIndex][zVboIndex][iVboIndex] = (int) (uploadBuffer.capacity() * BUFFER_EXPANSION_MULTIPLIER); + }*/ } } else From 4a0640a2196f8ce1844227c42561211aaa6207c5 Mon Sep 17 00:00:00 2001 From: cola98765 Date: Wed, 13 Oct 2021 14:27:27 +0200 Subject: [PATCH 7/7] cleaned out some code. --- .../lodTemplates/CubicLodTemplate.java | 2 - .../lod/builders/lodBuilding/LodBuilder.java | 16 ++---- .../lod/handlers/ReflectionHandler.java | 6 +-- .../java/com/seibel/lod/objects/LodWorld.java | 4 +- .../lod/objects/PosToRenderContainer.java | 4 -- .../com/seibel/lod/proxy/ClientProxy.java | 4 +- .../com/seibel/lod/render/LodRenderer.java | 8 --- .../com/seibel/lod/util/LevelPosUtil.java | 2 - .../java/com/seibel/lod/util/LodUtil.java | 51 ++++++------------- .../com/seibel/lod/util/ThreadMapUtil.java | 6 ++- 10 files changed, 30 insertions(+), 73 deletions(-) diff --git a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java index 15d3a1c9f..a15344653 100644 --- a/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java +++ b/src/main/java/com/seibel/lod/builders/bufferBuilding/lodTemplates/CubicLodTemplate.java @@ -85,11 +85,9 @@ public class CubicLodTemplate extends AbstractLodTemplate return; if (depth == height) - { // if the top and bottom points are at the same height // render this LOD as 1 block thick height++; - } // offset the AABB by its x/z position in the world since // it uses doubles to specify its location, unlike the model view matrix diff --git a/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java b/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java index 718df8af2..c1dcbd18e 100644 --- a/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java +++ b/src/main/java/com/seibel/lod/builders/lodBuilding/LodBuilder.java @@ -44,7 +44,6 @@ import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.ChunkSection; import net.minecraft.world.chunk.IChunk; -import net.minecraft.world.gen.Heightmap; import net.minecraftforge.client.model.data.ModelDataMap; import java.awt.*; @@ -71,7 +70,6 @@ public class LodBuilder public static final Direction[] directions = new Direction[] { Direction.UP, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, Direction.DOWN }; public static final int CHUNK_DATA_WIDTH = LodUtil.CHUNK_WIDTH; public static final int CHUNK_SECTION_HEIGHT = CHUNK_DATA_WIDTH; - public static final Heightmap.Type DEFAULT_HEIGHTMAP = Heightmap.Type.WORLD_SURFACE_WG; public static final ConcurrentMap colorMap = new ConcurrentHashMap<>(); public static final ConcurrentMap tintColor = new ConcurrentHashMap<>(); public static final ConcurrentMap toTint = new ConcurrentHashMap<>(); @@ -112,7 +110,7 @@ public class LodBuilder public void generateLodNodeAsync(IChunk chunk, LodWorld lodWorld, IWorld world, DistanceGenerationMode generationMode) { - if (lodWorld == null || !lodWorld.getIsWorldLoaded()) + if (lodWorld == null || lodWorld.getIsWorldNotLoaded()) return; // don't try to create an LOD object @@ -235,9 +233,7 @@ public class LodBuilder lodDim.updateData(LodUtil.CHUNK_DETAIL_LEVEL, chunk.getPos().x, chunk.getPos().z); } - /** - * creates a vertical DataPoint - */ + /** creates a vertical DataPoint */ private long[] createVerticalDataToMerge(HorizontalResolution detail, IChunk chunk, LodBuilderConfig config, int startX, int startZ, int endX, int endZ) { // equivalent to 2^detailLevel @@ -359,9 +355,7 @@ public class LodBuilder return depth; } - /** - * Find the highest valid point from the Top - */ + /** Find the highest valid point from the Top */ private short determineHeightPointFrom(IChunk chunk, LodBuilderConfig config, int xRel, int zRel, int yAbs, BlockPos.Mutable blockPos) { short height = DEFAULT_HEIGHT; @@ -431,9 +425,7 @@ public class LodBuilder return colorInt; } - /** - * Gets the light value for the given block position - */ + /** Gets the light value for the given block position */ private int getLightValue(IChunk chunk, BlockPos.Mutable blockPos, boolean hasCeiling, boolean hasSkyLight, boolean topBlock) { int skyLight; diff --git a/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java b/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java index 9c2f6eafd..45606b781 100644 --- a/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java +++ b/src/main/java/com/seibel/lod/handlers/ReflectionHandler.java @@ -105,10 +105,8 @@ public class ReflectionHandler case 0: // optifine's "default" option, // it should never be called in this case - return FogQuality.FAST; - - - // normal options + + // normal options case 1: return FogQuality.FAST; case 2: diff --git a/src/main/java/com/seibel/lod/objects/LodWorld.java b/src/main/java/com/seibel/lod/objects/LodWorld.java index 6c38ef78c..1e3d2d26c 100644 --- a/src/main/java/com/seibel/lod/objects/LodWorld.java +++ b/src/main/java/com/seibel/lod/objects/LodWorld.java @@ -150,9 +150,9 @@ public class LodWorld } - public boolean getIsWorldLoaded() + public boolean getIsWorldNotLoaded() { - return isWorldLoaded; + return !isWorldLoaded; } public String getWorldName() diff --git a/src/main/java/com/seibel/lod/objects/PosToRenderContainer.java b/src/main/java/com/seibel/lod/objects/PosToRenderContainer.java index bfbf30bf2..16b21fc4e 100644 --- a/src/main/java/com/seibel/lod/objects/PosToRenderContainer.java +++ b/src/main/java/com/seibel/lod/objects/PosToRenderContainer.java @@ -60,14 +60,10 @@ public class PosToRenderContainer public boolean contains(byte detailLevel, int posX, int posZ) { if (LevelPosUtil.getRegion(detailLevel, posX) == regionPosX && LevelPosUtil.getRegion(detailLevel, posZ) == regionPosZ) - { return (population[LevelPosUtil.getRegionModule(minDetail, LevelPosUtil.convert(detailLevel, posX, minDetail))] [LevelPosUtil.getRegionModule(minDetail, LevelPosUtil.convert(detailLevel, posZ, minDetail))] == (detailLevel + 1)); - } else - { return false; - } } public void clear(byte minDetail, int regionPosX, int regionPosZ) diff --git a/src/main/java/com/seibel/lod/proxy/ClientProxy.java b/src/main/java/com/seibel/lod/proxy/ClientProxy.java index 463fd9baf..fc1e4dee2 100644 --- a/src/main/java/com/seibel/lod/proxy/ClientProxy.java +++ b/src/main/java/com/seibel/lod/proxy/ClientProxy.java @@ -110,7 +110,7 @@ public class ClientProxy firstFrameSetup(); - if (mc == null || mc.getPlayer() == null || !lodWorld.getIsWorldLoaded()) + if (mc == null || mc.getPlayer() == null || lodWorld.getIsWorldNotLoaded()) return; LodDimension lodDim = lodWorld.getLodDimension(mc.getCurrentDimension()); @@ -195,7 +195,7 @@ public class ClientProxy @SubscribeEvent public void serverTickEvent(TickEvent.ServerTickEvent event) { - if (mc == null || mc.getPlayer() == null || !lodWorld.getIsWorldLoaded()) + if (mc == null || mc.getPlayer() == null || lodWorld.getIsWorldNotLoaded()) return; LodDimension lodDim = lodWorld.getLodDimension(mc.getPlayer().level.dimensionType()); diff --git a/src/main/java/com/seibel/lod/render/LodRenderer.java b/src/main/java/com/seibel/lod/render/LodRenderer.java index abcf8978d..2954fd6f4 100644 --- a/src/main/java/com/seibel/lod/render/LodRenderer.java +++ b/src/main/java/com/seibel/lod/render/LodRenderer.java @@ -722,10 +722,6 @@ public class LodRenderer switch (LodConfig.CLIENT.graphics.fogDistance.get()) { case NEAR_AND_FAR: - fogSettings.near.distance = FogDistance.NEAR; - fogSettings.far.distance = FogDistance.NEAR; - break; - case NEAR: fogSettings.near.distance = FogDistance.NEAR; fogSettings.far.distance = FogDistance.NEAR; @@ -739,14 +735,10 @@ public class LodRenderer break; case OFF: - fogSettings.near.quality = FogQuality.OFF; fogSettings.far.quality = FogQuality.OFF; break; - } - - return fogSettings; } diff --git a/src/main/java/com/seibel/lod/util/LevelPosUtil.java b/src/main/java/com/seibel/lod/util/LevelPosUtil.java index 4f67c36d1..142c9c6f9 100644 --- a/src/main/java/com/seibel/lod/util/LevelPosUtil.java +++ b/src/main/java/com/seibel/lod/util/LevelPosUtil.java @@ -164,9 +164,7 @@ public class LevelPosUtil boolean inXArea = playerPosX >= startPosX && playerPosX <= endPosX; boolean inZArea = playerPosZ >= startPosZ && playerPosZ <= endPosZ; if (inXArea && inZArea) - { return 0; - } else if (inXArea) { return Math.min( diff --git a/src/main/java/com/seibel/lod/util/LodUtil.java b/src/main/java/com/seibel/lod/util/LodUtil.java index 955d63e6a..9781c5f5f 100644 --- a/src/main/java/com/seibel/lod/util/LodUtil.java +++ b/src/main/java/com/seibel/lod/util/LodUtil.java @@ -80,29 +80,22 @@ public class LodUtil public static final Color[] DEBUG_DETAIL_LEVEL_COLORS = new Color[] { Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA, Color.WHITE, Color.GRAY, Color.BLACK }; - /** - * 512 blocks wide - */ - public static final byte REGION_DETAIL_LEVEL = 9; - /** - * 16 blocks wide - */ - public static final byte CHUNK_DETAIL_LEVEL = 4; - /** - * 1 block wide - */ - public static final byte BLOCK_DETAIL_LEVEL = 0; - - public static final byte DETAIL_OPTIONS = 10; + /** 512 blocks wide */ + public static final byte REGION_DETAIL_LEVEL = DETAIL_OPTIONS - 1; + /** 16 blocks wide */ + public static final byte CHUNK_DETAIL_LEVEL = 4; + /** 1 block wide */ + public static final byte BLOCK_DETAIL_LEVEL = 0; + public static final short MAX_VERTICAL_DATA = 4; /** * measured in Blocks
- * detail level 9 + * detail level max - 1 */ - public static final short REGION_WIDTH = 512; + public static final short REGION_WIDTH = 1 << REGION_DETAIL_LEVEL; /** * measured in Blocks
* detail level 4 @@ -115,10 +108,8 @@ public class LodUtil public static final short BLOCK_WIDTH = 1; - /** - * number of chunks wide - */ - public static final int REGION_WIDTH_IN_CHUNKS = 32; + /** number of chunks wide */ + public static final int REGION_WIDTH_IN_CHUNKS = REGION_WIDTH / CHUNK_WIDTH; /** @@ -194,9 +185,7 @@ public class LodUtil return returnWorld; } - /** - * Convert a 2D absolute position into a quad tree relative position. - */ + /** Convert a 2D absolute position into a quad tree relative position. */ public static RegionPos convertGenericPosToRegionPos(int x, int z, int detailLevel) { int relativePosX = Math.floorDiv(x, (int) Math.pow(2, LodUtil.REGION_DETAIL_LEVEL - detailLevel)); @@ -205,9 +194,7 @@ public class LodUtil return new RegionPos(relativePosX, relativePosZ); } - /** - * Convert a 2D absolute position into a quad tree relative position. - */ + /** Convert a 2D absolute position into a quad tree relative position. */ public static int convertLevelPos(int pos, int currentDetailLevel, int targetDetailLevel) { return Math.floorDiv(pos, (int) Math.pow(2, targetDetailLevel - currentDetailLevel)); @@ -289,9 +276,7 @@ public class LodUtil } } - /** - * returns the server name, IP and game version. - */ + /** returns the server name, IP and game version. */ public static String getServerId() { ServerData server = mc.getCurrentServer(); @@ -304,9 +289,7 @@ public class LodUtil } - /** - * Convert a BlockColors int into a Color object. - */ + /** Convert a BlockColors int into a Color object */ public static Color intToColor(int num) { int filter = 0b11111111; @@ -318,9 +301,7 @@ public class LodUtil return new Color(red, green, blue); } - /** - * Convert a Color into a BlockColors object. - */ + /** Convert a Color into a BlockColors object. */ public static int colorToInt(Color color) { return color.getRGB(); diff --git a/src/main/java/com/seibel/lod/util/ThreadMapUtil.java b/src/main/java/com/seibel/lod/util/ThreadMapUtil.java index ab8516c2d..b8e389990 100644 --- a/src/main/java/com/seibel/lod/util/ThreadMapUtil.java +++ b/src/main/java/com/seibel/lod/util/ThreadMapUtil.java @@ -9,6 +9,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import static com.seibel.lod.util.LodUtil.DETAIL_OPTIONS; + /** * Holds data used by specific threads so * the data doesn't have to be recreated every @@ -163,8 +165,8 @@ public class ThreadMapUtil { if (!verticalUpdate.containsKey(Thread.currentThread().getName()) || (verticalUpdate.get(Thread.currentThread().getName()) == null)) { - long[][] array = new long[10][]; - for (int i = 1; i < 10; i++) + long[][] array = new long[DETAIL_OPTIONS][]; + for (int i = 1; i < DETAIL_OPTIONS; i++) array[i] = new long[DetailDistanceUtil.getMaxVerticalData(i - 1) * 4]; verticalUpdate.put(Thread.currentThread().getName(), array); }