diff --git a/leaf-server/minecraft-patches/features/0187-throttle-mob-spawning.patch b/leaf-server/minecraft-patches/features/0187-throttle-mob-spawning.patch index c2e3ab5a..171c3123 100644 --- a/leaf-server/minecraft-patches/features/0187-throttle-mob-spawning.patch +++ b/leaf-server/minecraft-patches/features/0187-throttle-mob-spawning.patch @@ -5,10 +5,10 @@ Subject: [PATCH] throttle mob spawning diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index 450f17badaa3f6c8f1cdb9e6dc76828b70afe6fc..8db4fd335e661111c52721be2f5ffc65a2c843d2 100644 +index 450f17badaa3f6c8f1cdb9e6dc76828b70afe6fc..2f709cca7180e2f4874a7f80ed32498aba6dcac0 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -160,6 +160,18 @@ public final class NaturalSpawner { +@@ -160,6 +160,17 @@ public final class NaturalSpawner { // Paper start - Optional per player mob spawns final boolean canSpawn; int maxSpawns = Integer.MAX_VALUE; @@ -17,7 +17,6 @@ index 450f17badaa3f6c8f1cdb9e6dc76828b70afe6fc..8db4fd335e661111c52721be2f5ffc65 + int spawnChance = org.dreeam.leaf.config.modules.opt.ThrottleNaturalSpawnMob.spawnChance[mobCategory.ordinal()]; + long failedAttempt = org.dreeam.leaf.config.modules.opt.ThrottleNaturalSpawnMob.failedAttempts[mobCategory.ordinal()]; + if (failedAttempt >= 0L -+ && spawnChance >= 0 + && chunk.failedSpawnAttempts[mobCategory.ordinal()] >= failedAttempt + && (level.random.nextInt() & 1023) > spawnChance) { + continue; diff --git a/leaf-server/minecraft-patches/features/0188-delay-to-next-tick-when-mob-spawning-not-ready.patch b/leaf-server/minecraft-patches/features/0188-delay-to-next-tick-when-mob-spawning-not-ready.patch index 7349ecb8..ce40d12e 100644 --- a/leaf-server/minecraft-patches/features/0188-delay-to-next-tick-when-mob-spawning-not-ready.patch +++ b/leaf-server/minecraft-patches/features/0188-delay-to-next-tick-when-mob-spawning-not-ready.patch @@ -55,7 +55,7 @@ index d61da0fbe7f6c181e4084ce60bfe7dab86f361ad..d9f74ac79e67ed7b9619041cce763b60 this.level.tickChunk(levelChunk, _int); } diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index 8db4fd335e661111c52721be2f5ffc65a2c843d2..336bb6dd39a4678ea5d992b8857e79d69d673dd8 100644 +index 2f709cca7180e2f4874a7f80ed32498aba6dcac0..32c9106b70ef7ab85077d6ec4bd7d7b84d9f8c00 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java @@ -156,6 +156,11 @@ public final class NaturalSpawner { @@ -70,7 +70,7 @@ index 8db4fd335e661111c52721be2f5ffc65a2c843d2..336bb6dd39a4678ea5d992b8857e79d6 for (MobCategory mobCategory : categories) { // Paper start - Optional per player mob spawns final boolean canSpawn; -@@ -186,7 +191,7 @@ public final class NaturalSpawner { +@@ -185,7 +190,7 @@ public final class NaturalSpawner { } // Paper end - throttle failed spawn attempts if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { diff --git a/leaf-server/src/main/java/org/dreeam/leaf/config/modules/opt/ThrottleNaturalSpawnMob.java b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/opt/ThrottleNaturalSpawnMob.java index 2be54108..73bb8eb7 100644 --- a/leaf-server/src/main/java/org/dreeam/leaf/config/modules/opt/ThrottleNaturalSpawnMob.java +++ b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/opt/ThrottleNaturalSpawnMob.java @@ -21,8 +21,11 @@ public class ThrottleNaturalSpawnMob extends ConfigModules { spawnChance = new int[categories.length]; for (int i = 0; i < categories.length; i++) { String category = getBasePath() + "." + categories[i].getSerializedName(); - failedAttempts[i] = config.getLong(category + ".failed-attempts", -1); - spawnChance[i] = (int) Math.round(config.getDouble(category + ".spawn-chance", 100.0) * 10.24); + long attempts = config.getLong(category + ".min-failed-attempts", 8); + double chance = config.getDouble(category + ".spawn-chance", 25.0); + + failedAttempts[i] = Math.max(-1, attempts); + spawnChance[i] = Math.clamp(0, (int) Math.round(chance * 10.24), 1024); } } }