Skip to content

Commit ea24fc5

Browse files
committed
Improve the deep dark generation
1 parent cb89871 commit ea24fc5

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

src/main/java/world/bentobox/stranger/generator/NetherBiomeProvider.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package world.bentobox.stranger.generator;
22

33
import java.util.List;
4+
import java.util.Random;
45

56
import org.bukkit.block.Biome;
67
import org.bukkit.generator.BiomeProvider;
@@ -11,10 +12,13 @@
1112
* Makes the deep dark biome
1213
*/
1314
public class NetherBiomeProvider extends BiomeProvider {
15+
16+
private Random random = new Random();
1417

1518
@Override
1619
public @NotNull Biome getBiome(@NotNull WorldInfo worldInfo, int x, int y, int z) {
17-
if (y < worldInfo.getMinHeight() + 30) {
20+
final int top = worldInfo.getMinHeight() + 30 - random.nextInt(5);
21+
if (y < top) {
1822
return Biome.DEEP_DARK;
1923
}
2024

src/main/java/world/bentobox/stranger/generator/NetherChunks.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,39 @@ public void generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random,
3737
// Define the Y-range for cave generation
3838
final int minCaveY = worldInfo.getMinHeight() + 7;
3939
final int maxCaveY = minCaveY + 30;
40-
40+
final double caveRange = (double)(maxCaveY - minCaveY);
41+
4142
for (int x = 0; x < 16; x++) {
4243
for (int z = 0; z < 16; z++) {
4344

4445
// Calculate absolute world X and Z once per column
4546
final int worldX = chunkX * 16 + x;
4647
final int worldZ = chunkZ * 16 + z;
47-
for (int y = minCaveY; y < maxCaveY; y++) {
48+
final int top = maxCaveY - random.nextInt(5);
49+
for (int y = minCaveY; y < top ; y++) {
4850
// Check the noise value
4951
final int worldY = y;
5052
double noise = this.caveGenerator.noise(worldX, worldY, worldZ);
51-
52-
if (noise < CAVE_THRESHOLD + 0.1) {
53+
54+
// --- DYNAMIC THRESHOLD LOGIC ---
55+
56+
// 1. Get Y's progress (0.0 to 1.0) through the cave range.
57+
double yProgress = (y - minCaveY) / caveRange;
58+
59+
// 2. Map this progress to a sine wave (0 to PI).
60+
// Math.sin(0) = 0 (at minCaveY)
61+
// Math.sin(PI / 2) = 1 (at the midpoint)
62+
// Math.sin(PI) = 0 (at maxCaveY)
63+
double swellFactor = Math.sin(yProgress * Math.PI);
64+
65+
// 3. Multiply by our max threshold.
66+
double yDependentThreshold = CAVE_THRESHOLD * swellFactor;
67+
68+
if (noise < yDependentThreshold + 0.1) {
5369
// Coat with Sculk
5470
chunkData.setBlock(x, y, z, Material.SCULK);
5571
}
56-
if (noise < CAVE_THRESHOLD) {
72+
if (noise < yDependentThreshold) {
5773
// Noise value is low enough, carve a cave block
5874
chunkData.setBlock(x, y, z, Material.AIR);
5975
}

src/main/java/world/bentobox/stranger/listeners/NetherChunkMaker.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,12 @@ private void convertBlocks(ChunkLoadEvent e) {
310310
for (int y = e.getWorld().getMinHeight() + NETHER_FLOOR; y < ROOF_HEIGHT; y++) {
311311
for (int x = 0; x < 16; x++) {
312312
for (int z = 0; z < 16; z++) {
313+
if (y == e.getWorld().getMinHeight() + NETHER_FLOOR) {
314+
// Bleed some netherrack into the deep dark
315+
for (int bleed = y - rand.nextInt(5); bleed < y; bleed++ ) {
316+
e.getChunk().getBlock(x, bleed, z).setType(Material.NETHERRACK, false);
317+
}
318+
}
313319
Block overworldBlock = overworldChunk.getBlock(x, y, z);
314320
Block newBlock = e.getChunk().getBlock(x, y, z);
315321
newBlock.setBiome(BIOME_MAPPING.getOrDefault(overworldBlock.getBiome(), Biome.NETHER_WASTES)); // Set biome for the new block
@@ -333,8 +339,7 @@ private void convertBlocks(ChunkLoadEvent e) {
333339

334340
// Biome
335341
if (overworldBlock.getBiome() == Biome.DEEP_DARK) {
336-
// Replicate the creepy deep dark
337-
342+
// Replicate the creepy deep dark
338343
} else
339344
// --- Tag-Based Conversion ---
340345

0 commit comments

Comments
 (0)