Vary sapling species by succession stage for realistic forest growth

Pioneer species (oak, birch) dominate at YOUNG_WOODLAND (intensity ~0.5).
Spruce and dark oak join at mid intensity. At MATURE_FOREST (intensity ~1.0)
the full mix includes cherry and jungle saplings for a diverse canopy.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
George
2026-06-07 19:12:25 +01:00
parent 773fb0223f
commit 2350c27374
@@ -131,9 +131,37 @@ public final class NeoForgeWorldEffectExecutor implements WorldEffectConsumer {
if (!state.is(Blocks.GRASS_BLOCK) && !state.is(Blocks.DIRT)) continue; if (!state.is(Blocks.GRASS_BLOCK) && !state.is(Blocks.DIRT)) continue;
BlockPos above = pos.above(); BlockPos above = pos.above();
if (!level.isLoaded(above) || !level.getBlockState(above).isAir()) continue; if (!level.isLoaded(above) || !level.getBlockState(above).isAir()) continue;
level.setBlock(above, Blocks.OAK_SAPLING.defaultBlockState(), Block.UPDATE_ALL); Block sapling = pickSapling(intensity);
level.setBlock(above, sapling.defaultBlockState(), Block.UPDATE_ALL);
LivingWorldLogger.info(DiagnosticCategory.SIMULATION, LivingWorldLogger.info(DiagnosticCategory.SIMULATION,
"WorldEffect SAPLING_GROWTH_BOOSTED at " + pos); "WorldEffect SAPLING_GROWTH_BOOSTED (" + sapling + ") at " + pos);
}
}
/**
* Selects a sapling species weighted by succession intensity.
* Low intensity (young woodland, ~0.5): pioneer species — oak and birch dominate.
* High intensity (mature forest, ~1.0): diverse canopy — spruce, dark oak, cherry join in.
*/
private Block pickSapling(double intensity) {
int r = random.nextInt(100);
if (intensity < 0.7) {
// Young woodland: pioneer species only
return r < 55 ? Blocks.OAK_SAPLING : Blocks.BIRCH_SAPLING;
} else if (intensity < 0.9) {
// Developing forest: conifers begin to establish
if (r < 35) return Blocks.OAK_SAPLING;
if (r < 65) return Blocks.BIRCH_SAPLING;
if (r < 85) return Blocks.SPRUCE_SAPLING;
return Blocks.DARK_OAK_SAPLING;
} else {
// Mature forest: full species diversity
if (r < 25) return Blocks.OAK_SAPLING;
if (r < 45) return Blocks.BIRCH_SAPLING;
if (r < 62) return Blocks.SPRUCE_SAPLING;
if (r < 77) return Blocks.DARK_OAK_SAPLING;
if (r < 90) return Blocks.CHERRY_SAPLING;
return Blocks.JUNGLE_SAPLING;
} }
} }