Fix BlockToAvoid and TintWithAvoidedBlocks

This commit is contained in:
James Seibel
2023-06-11 21:24:34 -05:00
parent 5a33a4511b
commit f785e75622
7 changed files with 94 additions and 73 deletions
@@ -21,12 +21,7 @@ package com.seibel.lod.api.enums.config;
/**
* NONE, <br>
* NON_FULL, <br>
* NO_COLLISION, <br>
* BOTH, <br>
*
* @author Leonardo Amato
* @version 2022-7-1
* NON_COLLIDING, <br>
*/
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; }
}
@@ -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();
}
@@ -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. <br><br>
@@ -55,12 +54,12 @@ public class DhApiWorldGenerationConfig implements IDhApiWorldGenerationConfig
@Deprecated
@Override
public IDhApiConfigValue<EBlocksToAvoid> getBlocksToAvoid()
{ return new DhApiConfigValue<>(WorldGenerator.blocksToAvoid); }
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Quality.blocksToIgnore); }
@Deprecated
@Override
public IDhApiConfigValue<Boolean> getTintWithAvoidedBlocks()
{ return new DhApiConfigValue<>(WorldGenerator.tintWithAvoidedBlocks); }
{ return new DhApiConfigValue<>(Config.Client.Advanced.Graphics.Quality.tintWithAvoidedBlocks); }
}
@@ -203,6 +203,30 @@ public class Config
.setPerformance(EConfigEntryPerformance.MEDIUM)
.build();
public static ConfigEntry<EBlocksToAvoid> blocksToIgnore = new ConfigEntry.Builder<EBlocksToAvoid>()
.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<Boolean> tintWithAvoidedBlocks = new ConfigEntry.Builder<Boolean>()
.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<Integer> lodBiomeBlending = new ConfigEntry.Builder<Integer>()
// .setMinDefaultMax(0,1,7)
@@ -647,30 +671,6 @@ public class Config
.setPerformance(EConfigEntryPerformance.NONE)
.build();
// TODO fixme
public static ConfigEntry<EBlocksToAvoid> blocksToAvoid = new ConfigEntry.Builder<EBlocksToAvoid>()
.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<Boolean> tintWithAvoidedBlocks = new ConfigEntry.Builder<Boolean>()
.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
@@ -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));
@@ -12,8 +12,4 @@ public interface IBlockStateWrapper extends IDhApiBlockStateWrapper
{
String serialize();
// TODO:
// boolean hasFaceCullingFor(ELodDirection dir);
// boolean hasNoCollision();
// boolean noFaceIsFullFace();
}
@@ -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",