diff --git a/CHANGELOG.md b/CHANGELOG.md index c03f265..1355411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,6 @@ +# 2.0.10 +- Read `biomesMerging.fromCavesGeneration.enabled` correctly from config. +- Fix cave biome that where over surface on eroded biome. + # 2.0.9 - Config: Aera values will be swap if min > max. \ No newline at end of file diff --git a/Underilla-Spigot/build.gradle.kts b/Underilla-Spigot/build.gradle.kts index 4ce459c..ca3d4c3 100644 --- a/Underilla-Spigot/build.gradle.kts +++ b/Underilla-Spigot/build.gradle.kts @@ -11,7 +11,7 @@ plugins { } group = "com.jkantrell.mc.underilla" -version = "2.0.9" +version = "2.0.10" description="Generate vanilla cave in custom world." val mainMinecraftVersion = "1.21.4" val supportedMinecraftVersions = "1.21.3 - 1.21.4" diff --git a/Underilla-Spigot/src/main/java/com/jkantrell/mc/underilla/spigot/impl/CustomBiomeSource.java b/Underilla-Spigot/src/main/java/com/jkantrell/mc/underilla/spigot/impl/CustomBiomeSource.java index db64b23..0f8fd53 100644 --- a/Underilla-Spigot/src/main/java/com/jkantrell/mc/underilla/spigot/impl/CustomBiomeSource.java +++ b/Underilla-Spigot/src/main/java/com/jkantrell/mc/underilla/spigot/impl/CustomBiomeSource.java @@ -64,7 +64,7 @@ public Biome getBiome(@NotNull WorldInfo worldInfo, int x, int y, int z) { // If is a cave biome that we should preserve & is below the surface of surface world. if (vanillaBiomeName != null && Underilla.getUnderillaConfig() .isBiomeInSet(SetBiomeStringKeys.BIOME_MERGING_FROM_CAVES_GENERATION_ONLY_ON_BIOMES, vanillaBiomeName) - && y < topYOfSurfaceWorld(worldSurfaceReader, x, z)) { + && isUnderSurface(worldSurfaceReader, x, y, z)) { String key = "cavesGeneration:" + vanillaBiomeName; debug("Use vanillaBiome because it's a cavesGeneration biome: " + vanillaBiomeName + " at " + x + " " + y + " " + z); biomesPlaced.put(key, biomesPlaced.getOrDefault(key, 0L) + 1); @@ -105,6 +105,24 @@ && y < topYOfSurfaceWorld(worldSurfaceReader, x, z)) { return BukkitBiome.DEFAULT.getBiome(); } + private boolean isUnderSurface(BukkitWorldReader worldSurfaceReader, int x, int y, int z) { + if(Underilla.getUnderillaConfig().getBoolean(BooleanKeys.BIOME_MERGING_FROM_CAVES_GENERATION_ONLY_UNDER_SURFACE)) { + // Merging biome below the surface only. + x = x - x % 4; + z = z - z % 4; + for(int i=0; i<4; i++) { + for(int j=0; j<4; j++) { + // If the block is over the merge limit, it's not under the surface. + if(y >= topYOfSurfaceWorld(worldSurfaceReader, x+i, z+j)){ + return false; + } + } + } + } + // All blocks are under the surface (or it's configured not to check). + return true; + } + private int topYOfSurfaceWorld(BukkitWorldReader worldSurfaceReader, int x, int z) { return worldSurfaceReader.getLowerBlockOfSurfaceWorldYLevel(x, z); } diff --git a/Underilla-Spigot/src/main/java/com/jkantrell/mc/underilla/spigot/io/UnderillaConfig.java b/Underilla-Spigot/src/main/java/com/jkantrell/mc/underilla/spigot/io/UnderillaConfig.java index 5ede833..03683a5 100644 --- a/Underilla-Spigot/src/main/java/com/jkantrell/mc/underilla/spigot/io/UnderillaConfig.java +++ b/Underilla-Spigot/src/main/java/com/jkantrell/mc/underilla/spigot/io/UnderillaConfig.java @@ -380,6 +380,7 @@ public enum BooleanKeys { PRESERVE_SURFACE_WORLD_FROM_CAVERS("carvers.preserveSurfaceWorldFromCavers", true), PRESERVE_LIQUID_FROM_CAVERS("carvers.preserveLiquidFromCavers", true), BIOME_MERGING_FROM_CAVES_GENERATION_ENABLED("biomesMerging.fromCavesGeneration.enabled", true), + BIOME_MERGING_FROM_CAVES_GENERATION_ONLY_UNDER_SURFACE("biomesMerging.fromCavesGeneration.onlyUnderSurface", true), CLEAN_BLOCKS_ENABLED("clean.blocks.enabled", true), CLEAN_BLOCKS_REMOVE_UNSTABLE_BLOCKS("clean.blocks.removeUnstableBlocks", true), CLEAN_ENTITIES_ENABLED("clean.entities.enabled", true); diff --git a/Underilla-Spigot/src/main/resources/config.yml b/Underilla-Spigot/src/main/resources/config.yml index ffcff95..29a8c85 100644 --- a/Underilla-Spigot/src/main/resources/config.yml +++ b/Underilla-Spigot/src/main/resources/config.yml @@ -175,6 +175,9 @@ biomesMerging: - "minecraft:dripstone_caves" - "minecraft:deep_dark" exceptOn: [] + # If true, the biome generated by the caves generator will be used only under the surface world. + # You probably want to keep this to true to avoid for example having dripstones on the surface. + onlyUnderSurface: true # Cleaning after generation ------------------------------------------------------------------------------------------- clean: