Skip to content

Commit

Permalink
Fix cave biome that where over surface on eroded biome. #23
Browse files Browse the repository at this point in the history
It's done by checking each surface min y level for the 4*4 area of the biome.
(Haven't been tested yet.)
HydrolienF committed Jan 15, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 0315b26 commit d0fe416
Showing 5 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion Underilla-Spigot/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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);
3 changes: 3 additions & 0 deletions Underilla-Spigot/src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -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:

0 comments on commit d0fe416

Please sign in to comment.