diff --git a/api/src/main/java/com/seibel/lod/api/enums/config/EBlocksToAvoid.java b/api/src/main/java/com/seibel/lod/api/enums/config/EBlocksToAvoid.java index b57c26195..5120cd751 100644 --- a/api/src/main/java/com/seibel/lod/api/enums/config/EBlocksToAvoid.java +++ b/api/src/main/java/com/seibel/lod/api/enums/config/EBlocksToAvoid.java @@ -21,12 +21,7 @@ package com.seibel.lod.api.enums.config; /** * NONE,
- * NON_FULL,
- * NO_COLLISION,
- * BOTH,
- * - * @author Leonardo Amato - * @version 2022-7-1 + * NON_COLLIDING,
*/ public enum EBlocksToAvoid { @@ -34,20 +29,11 @@ public enum EBlocksToAvoid // when adding items up the API minor version // when removing items up the API major version - NONE(false, false), + NONE(false), + NON_COLLIDING(true); - NON_FULL(true, false), - - NO_COLLISION(false, true), - - BOTH(true, true); - - public final boolean nonFull; public final boolean noCollision; - EBlocksToAvoid(boolean nonFull, boolean noCollision) - { - this.nonFull = nonFull; - this.noCollision = noCollision; - } + EBlocksToAvoid(boolean noCollision) { this.noCollision = noCollision; } + } \ No newline at end of file diff --git a/api/src/main/java/com/seibel/lod/api/interfaces/block/IDhApiBlockStateWrapper.java b/api/src/main/java/com/seibel/lod/api/interfaces/block/IDhApiBlockStateWrapper.java index d2660249c..4de6ed862 100644 --- a/api/src/main/java/com/seibel/lod/api/interfaces/block/IDhApiBlockStateWrapper.java +++ b/api/src/main/java/com/seibel/lod/api/interfaces/block/IDhApiBlockStateWrapper.java @@ -6,10 +6,16 @@ import com.seibel.lod.api.interfaces.IDhApiUnsafeWrapper; * A Minecraft version independent way of handling Blocks. * * @author James Seibel - * @version 2022-11-12 + * @version 2023-6-11 */ public interface IDhApiBlockStateWrapper extends IDhApiUnsafeWrapper { boolean isAir(); + boolean isSolid(); + boolean isLiquid(); + + // TODO: + // boolean hasNoCollision(); + // boolean noFaceIsFullFace(); } diff --git a/core/src/main/java/com/seibel/lod/core/api/external/methods/config/both/DhApiWorldGenerationConfig.java b/core/src/main/java/com/seibel/lod/core/api/external/methods/config/both/DhApiWorldGenerationConfig.java index f88dc0aee..7b0a112b8 100644 --- a/core/src/main/java/com/seibel/lod/core/api/external/methods/config/both/DhApiWorldGenerationConfig.java +++ b/core/src/main/java/com/seibel/lod/core/api/external/methods/config/both/DhApiWorldGenerationConfig.java @@ -22,11 +22,10 @@ package com.seibel.lod.core.api.external.methods.config.both; import com.seibel.lod.api.interfaces.config.IDhApiConfigValue; import com.seibel.lod.api.interfaces.config.both.IDhApiWorldGenerationConfig; import com.seibel.lod.api.objects.config.DhApiConfigValue; +import com.seibel.lod.core.config.Config; import com.seibel.lod.core.config.Config.Client.Advanced.WorldGenerator; import com.seibel.lod.api.enums.config.EBlocksToAvoid; import com.seibel.lod.api.enums.worldGeneration.EDhApiDistantGeneratorMode; -import com.seibel.lod.api.enums.config.EGenerationPriority; -import com.seibel.lod.api.enums.config.ELightGenerationMode; /** * Distant Horizons' world generation configuration.

@@ -55,12 +54,12 @@ public class DhApiWorldGenerationConfig implements IDhApiWorldGenerationConfig @Deprecated @Override public IDhApiConfigValue getBlocksToAvoid() - { return new DhApiConfigValue<>(WorldGenerator.blocksToAvoid); } + { return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Quality.blocksToIgnore); } @Deprecated @Override public IDhApiConfigValue getTintWithAvoidedBlocks() - { return new DhApiConfigValue<>(WorldGenerator.tintWithAvoidedBlocks); } + { return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Quality.tintWithAvoidedBlocks); } } diff --git a/core/src/main/java/com/seibel/lod/core/config/Config.java b/core/src/main/java/com/seibel/lod/core/config/Config.java index fb0d3667c..e7aa5f769 100644 --- a/core/src/main/java/com/seibel/lod/core/config/Config.java +++ b/core/src/main/java/com/seibel/lod/core/config/Config.java @@ -203,6 +203,30 @@ public class Config .setPerformance(EConfigEntryPerformance.MEDIUM) .build(); + public static ConfigEntry blocksToIgnore = new ConfigEntry.Builder() + .set(EBlocksToAvoid.NON_COLLIDING) + .comment("" + + "What blocks shouldn't be rendered as LODs? \n" + + "\n" + + EBlocksToAvoid.NONE + ": Represent all blocks in the LODs \n" + + EBlocksToAvoid.NON_COLLIDING + ": Only represent solid blocks in the LODs (tall grass, torches, etc. won't count for a LOD's height) \n" + + "") + .setPerformance(EConfigEntryPerformance.NONE) + .addListener(RenderCacheConfigEventHandler.INSTANCE) + .build(); + + public static ConfigEntry tintWithAvoidedBlocks = new ConfigEntry.Builder() + .set(true) + .comment("" + + "Should the blocks underneath avoided blocks gain the color of the avoided block? \n" + + "\n" + + "True: a red flower will tint the grass below it red. \n" + + "False: skipped blocks will not change color of surface below them. " + +"") + .setPerformance(EConfigEntryPerformance.NONE) + .addListener(RenderCacheConfigEventHandler.INSTANCE) + .build(); + // TODO fixme // public static ConfigEntry lodBiomeBlending = new ConfigEntry.Builder() // .setMinDefaultMax(0,1,7) @@ -647,30 +671,6 @@ public class Config .setPerformance(EConfigEntryPerformance.NONE) .build(); - // TODO fixme - public static ConfigEntry blocksToAvoid = new ConfigEntry.Builder() - .set(EBlocksToAvoid.BOTH) - .comment("" - + "When generating fake chunks, what blocks should be ignored? \n" - + "Ignored blocks don't affect the height of the fake chunk, but might affect the color. \n" - + "So using " + EBlocksToAvoid.BOTH + " will prevent snow covered blocks from appearing one block too tall, \n" - + " but will still show the snow's color.\n" - + "\n" - + EBlocksToAvoid.NONE + ": Use all blocks when generating fake chunks \n" - + EBlocksToAvoid.NON_FULL + ": Only use full blocks when generating fake chunks (ignores slabs, lanterns, torches, tall grass, etc.) \n" - + EBlocksToAvoid.NO_COLLISION + ": Only use solid blocks when generating fake chunks (ignores tall grass, torches, etc.) \n" - + EBlocksToAvoid.BOTH + ": Only use full solid blocks when generating fake chunks") - .setPerformance(EConfigEntryPerformance.NONE) - .build(); - - // TODO fixme - public static ConfigEntry tintWithAvoidedBlocks = new ConfigEntry.Builder() - .set(true) - .comment("" - + "Should the blocks underneath avoided blocks gain the color of the avoided block? \n" - + " True: a red flower on grass will tint the grass below it red" - + " False: skipped blocks will not change color of surface below them") - .build(); } public static class Multiplayer diff --git a/core/src/main/java/com/seibel/lod/core/dataObjects/transformers/FullDataToRenderDataTransformer.java b/core/src/main/java/com/seibel/lod/core/dataObjects/transformers/FullDataToRenderDataTransformer.java index 5da53e500..c3ddac932 100644 --- a/core/src/main/java/com/seibel/lod/core/dataObjects/transformers/FullDataToRenderDataTransformer.java +++ b/core/src/main/java/com/seibel/lod/core/dataObjects/transformers/FullDataToRenderDataTransformer.java @@ -1,5 +1,6 @@ package com.seibel.lod.core.dataObjects.transformers; +import com.seibel.lod.api.enums.config.EBlocksToAvoid; import com.seibel.lod.core.dataObjects.fullData.FullDataPointIdMap; import com.seibel.lod.core.dataObjects.fullData.accessor.SingleColumnFullDataAccessor; import com.seibel.lod.core.dataObjects.fullData.sources.CompleteFullDataSource; @@ -235,9 +236,16 @@ public class FullDataToRenderDataTransformer private static void iterateAndConvert(IDhClientLevel level, int blockX, int blockZ, int genMode, ColumnArrayView column, SingleColumnFullDataAccessor data) { - FullDataPointIdMap mapping = data.getMapping(); + boolean avoidSolidBlocks = (Config.Client.Advanced.Graphics.Quality.blocksToIgnore.get() == EBlocksToAvoid.NON_COLLIDING); + boolean colorBelowWithAvoidedBlocks = Config.Client.Advanced.Graphics.Quality.tintWithAvoidedBlocks.get(); + + FullDataPointIdMap fullDataMapping = data.getMapping(); + boolean isVoid = true; - int offset = 0; + int colorToApplyToNextBlock = -1; + int columnOffset = 0; + + // goes from the top down for (int i = 0; i < data.getSingleLength(); i++) { long fullData = data.getSingle(i); @@ -245,20 +253,50 @@ public class FullDataToRenderDataTransformer int blockHeight = FullDataPointUtil.getHeight(fullData); int id = FullDataPointUtil.getId(fullData); int light = FullDataPointUtil.getLight(fullData); - IBiomeWrapper biome = mapping.getBiomeWrapper(id); - IBlockStateWrapper block = mapping.getBlockStateWrapper(id); + IBiomeWrapper biome = fullDataMapping.getBiomeWrapper(id); + IBlockStateWrapper block = fullDataMapping.getBlockStateWrapper(id); if (block.equals(AIR)) { + // we don't render air continue; } + + // solid block check + if (avoidSolidBlocks && !block.isSolid() && !block.isLiquid()) + { + if (colorBelowWithAvoidedBlocks) + { + colorToApplyToNextBlock = level.computeBaseColor(new DhBlockPos(blockX, bottomY + level.getMinY(), blockZ), biome, block); + } + + // don't add this block + continue; + } + + + int color; + if (colorToApplyToNextBlock == -1) + { + // use this block's color + color = level.computeBaseColor(new DhBlockPos(blockX, bottomY + level.getMinY(), blockZ), biome, block); + } + else + { + // use the previous block's color + color = colorToApplyToNextBlock; + colorToApplyToNextBlock = -1; + } + + + // add the block isVoid = false; - int color = level.computeBaseColor(new DhBlockPos(blockX, bottomY + level.getMinY(), blockZ), biome, block); long columnData = RenderDataPointUtil.createDataPoint(bottomY + blockHeight, bottomY, color, light, genMode); - column.set(offset, columnData); - offset++; + column.set(columnOffset, columnData); + columnOffset++; } + if (isVoid) { column.set(0, RenderDataPointUtil.createVoidDataPoint((byte) genMode)); diff --git a/core/src/main/java/com/seibel/lod/core/wrapperInterfaces/block/IBlockStateWrapper.java b/core/src/main/java/com/seibel/lod/core/wrapperInterfaces/block/IBlockStateWrapper.java index ae784fb80..92f745388 100644 --- a/core/src/main/java/com/seibel/lod/core/wrapperInterfaces/block/IBlockStateWrapper.java +++ b/core/src/main/java/com/seibel/lod/core/wrapperInterfaces/block/IBlockStateWrapper.java @@ -12,8 +12,4 @@ public interface IBlockStateWrapper extends IDhApiBlockStateWrapper { String serialize(); -// TODO: -// boolean hasFaceCullingFor(ELodDirection dir); -// boolean hasNoCollision(); -// boolean noFaceIsFullFace(); } diff --git a/core/src/main/resources/assets/lod/lang/en_us.json b/core/src/main/resources/assets/lod/lang/en_us.json index ab24dba5c..43934928e 100644 --- a/core/src/main/resources/assets/lod/lang/en_us.json +++ b/core/src/main/resources/assets/lod/lang/en_us.json @@ -96,6 +96,14 @@ "How far apart drops in quality are.\n\nHigher settings will increase the distance between drops\nbut will increase memory and GPU usage.", "lod.config.client.advanced.graphics.quality.transparency": "Transparency", + "lod.config.client.advanced.graphics.quality.blocksToIgnore": + "Blocks To Ignore", + "lod.config.client.advanced.graphics.quality.blocksToIgnore.@tooltip": + "Defines the types of blocks to ignore when generating LODs.", + "lod.config.client.advanced.graphics.quality.tintWithAvoidedBlocks": + "Tint With Avoided Blocks", + "lod.config.client.advanced.graphics.quality.tintWithAvoidedBlocks.@tooltip": + "§4Note: makes snow, carpet, and trapdoors look really bad§r\nShould the blocks underneath avoided blocks gain the color of the avoided block?\n§6True:§r a red flower on grass will tint the grass below it red\n§6False:§r skipped blocks will not change color of surface below them", "lod.config.client.advanced.graphics.quality.lodBiomeBlending": "Biome Blending", "lod.config.client.advanced.graphics.quality.lodBiomeBlending.@tooltip": @@ -266,14 +274,6 @@ "Generation Priority", "lod.config.client.advanced.worldGenerator.generationPriority.@tooltip": "The priority for chunks being generated around the player.", - "lod.config.client.advanced.worldGenerator.blocksToAvoid": - "Blocks To Avoid", - "lod.config.client.advanced.worldGenerator.blocksToAvoid.@tooltip": - "Defines the types of blocks to ignore when generating LODs.", - "lod.config.client.advanced.worldGenerator.tintWithAvoidedBlocks": - "Tint With Avoided Blocks", - "lod.config.client.advanced.worldGenerator.tintWithAvoidedBlocks.@tooltip": - "§4Note: makes snow, carpet, and trapdoors look really bad§r\nShould the blocks underneath avoided blocks gain the color of the avoided block?\n§6True:§r a red flower on grass will tint the grass below it red\n§6False:§r skipped blocks will not change color of surface below them", "lod.config.client.advanced.multiplayer": @@ -595,12 +595,8 @@ "lod.config.enum.EBlocksToAvoid.NONE": "None", - "lod.config.enum.EBlocksToAvoid.NON_FULL": - "Non full", - "lod.config.enum.EBlocksToAvoid.NO_COLLISION": - "No collision", - "lod.config.enum.EBlocksToAvoid.BOTH": - "Both", + "lod.config.enum.EBlocksToAvoid.NON_COLLIDING": + "Non-Colliding", "lod.config.enum.EServerFolderNameMode.NAME_ONLY": "Name Only",