From a98917a288dbcbccd71317f0ba578c933eb3b50f Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Fri, 2 Feb 2024 12:46:21 +0100 Subject: [PATCH] Fix cave detection --- .../bluemap/common/config/BlueMapConfigManager.java | 9 +++++---- .../core/map/hires/blockmodel/LiquidModelBuilder.java | 10 ++++++++-- .../map/hires/blockmodel/ResourceModelBuilder.java | 5 ++++- .../bluemap/core/world/block/ExtendedBlock.java | 8 +++++--- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/BlueMapConfigManager.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/BlueMapConfigManager.java index 74e92b18..c08bc70b 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/BlueMapConfigManager.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/BlueMapConfigManager.java @@ -31,6 +31,7 @@ import de.bluecolored.bluemap.core.BlueMap; import de.bluecolored.bluemap.core.MinecraftVersion; import de.bluecolored.bluemap.core.logger.Logger; +import de.bluecolored.bluemap.core.resources.datapack.DataPack; import de.bluecolored.bluemap.core.util.FileHelper; import de.bluecolored.bluemap.core.util.Key; import lombok.Builder; @@ -222,19 +223,19 @@ private Map loadMapConfigs(Collection autoConfig Files.writeString( mapConfigFolder.resolve("overworld.conf"), createOverworldMapTemplate("Overworld", worldFolder, - new Key("minecraft", "overworld"), 0).build(), + DataPack.DIMENSION_OVERWORLD, 0).build(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING ); Files.writeString( mapConfigFolder.resolve("nether.conf"), createNetherMapTemplate("Nether", worldFolder, - new Key("minecraft", "the_nether"), 0).build(), + DataPack.DIMENSION_THE_NETHER, 0).build(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING ); Files.writeString( mapConfigFolder.resolve("end.conf"), createEndMapTemplate("End", worldFolder, - new Key("minecraft", "the_end"), 0).build(), + DataPack.DIMENSION_THE_END, 0).build(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING ); } else { @@ -252,7 +253,7 @@ private Map loadMapConfigs(Collection autoConfig configFile = mapConfigFolder.resolve(id + '_' + (++i) + ".conf"); } - String name = worldFolder.getFileName() + " - " + dimensionName; + String name = worldFolder.getFileName() + " (" + dimensionName + ")"; if (i > 1) name = name + " (" + i + ")"; ConfigTemplate template; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/blockmodel/LiquidModelBuilder.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/blockmodel/LiquidModelBuilder.java index 0c05a6ca..c9929aa3 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/blockmodel/LiquidModelBuilder.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/blockmodel/LiquidModelBuilder.java @@ -104,8 +104,14 @@ public void build(BlockNeighborhood block, BlockState blockState, Variant var private final Color tintcolor = new Color(); private void build() { + int blockLight = block.getBlockLightLevel(); + int sunLight = block.getSunLightLevel(); + // filter out blocks that are in a "cave" that should not be rendered - if (this.block.isCave() && (renderSettings.isCaveDetectionUsesBlockLight() ? block.getBlockLightLevel() : block.getSunLightLevel()) == 0f) return; + if ( + this.block.isRemoveIfCave() && + (renderSettings.isCaveDetectionUsesBlockLight() ? Math.max(blockLight, sunLight) : sunLight) == 0f + ) return; int level = blockState.getLiquidLevel(); if (level < 8 && !(level == 0 && isSameLiquid(block.getNeighborBlock(0, 1, 0)))){ @@ -160,7 +166,7 @@ private void build() { blockColor.multiply(tintcolor); // apply light - float combinedLight = Math.max(block.getSunLightLevel() / 15f, block.getBlockLightLevel() / 15f); + float combinedLight = Math.max(sunLight, blockLight) / 15f; combinedLight = (renderSettings.getAmbientLight() + combinedLight) / (renderSettings.getAmbientLight() + 1f); blockColor.r *= combinedLight; blockColor.g *= combinedLight; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/blockmodel/ResourceModelBuilder.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/blockmodel/ResourceModelBuilder.java index b015c458..8396d051 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/blockmodel/ResourceModelBuilder.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/blockmodel/ResourceModelBuilder.java @@ -196,7 +196,10 @@ private void createElementFace(Element element, Direction faceDir, VectorM3f c0, int blockLight = Math.max(blockLightData.getBlockLight(), facedLightData.getBlockLight()); // filter out faces that are in a "cave" that should not be rendered - if (block.isCave() && (renderSettings.isCaveDetectionUsesBlockLight() ? Math.max(blockLight, sunLight) : sunLight) == 0f) return; + if ( + block.isRemoveIfCave() && + (renderSettings.isCaveDetectionUsesBlockLight() ? Math.max(blockLight, sunLight) : sunLight) == 0f + ) return; // initialize the faces blockModel.initialize(); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/block/ExtendedBlock.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/block/ExtendedBlock.java index 8870d50d..50e1b181 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/block/ExtendedBlock.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/block/ExtendedBlock.java @@ -109,12 +109,14 @@ public boolean isInsideRenderBounds() { return insideRenderBounds; } - public boolean isCave() { + public boolean isRemoveIfCave() { if (!isCaveCalculated) { isCave = getY() < renderSettings.getRemoveCavesBelowY() && - !getChunk().hasOceanFloorHeights() || + ( + !getChunk().hasOceanFloorHeights() || getY() < getChunk().getOceanFloorY(getX(), getZ()) + - renderSettings.getCaveDetectionOceanFloor(); + renderSettings.getCaveDetectionOceanFloor() + ); isCaveCalculated = true; }