From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: hayanesuru Date: Wed, 4 Jun 2025 20:54:03 +0900 Subject: [PATCH] throttle mob spawning diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java index 38a6a11c05c0a0a2f59c1477e516431263dce101..a55abb08093847a8bfec446659f9af5fb1df2824 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java @@ -154,6 +154,17 @@ public final class NaturalSpawner { // Paper start - Optional per player mob spawns final boolean canSpawn; int maxSpawns = Integer.MAX_VALUE; + // Leaf start - throttle mob spawning + if (org.dreeam.leaf.config.modules.opt.ThrottleNaturalMobSpawning.enabled) { + int spawnChance = org.dreeam.leaf.config.modules.opt.ThrottleNaturalMobSpawning.spawnChance[mobCategory.ordinal()]; + long failedAttempt = org.dreeam.leaf.config.modules.opt.ThrottleNaturalMobSpawning.failedAttempts[mobCategory.ordinal()]; + if (failedAttempt >= 0L + && chunk.failedSpawnAttempts[mobCategory.ordinal()] >= failedAttempt + && (level.random.nextInt() & 1023) > spawnChance) { + continue; + } + } + // Leaf end - throttle mob spawning if (level.paperConfig().entities.spawning.perPlayerMobSpawns) { // Copied from getFilteredSpawningCategories int limit = mobCategory.getMaxInstancesPerChunk();