9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0266-throttle-mob-spawning.patch
hayanesuru 34d9673f3e backport from dev/1.21.6
73ffcb09fa optimize mob spawning
333373d204 fix async mob spawning data race
7c9f88e4f8 [ci skip] cleanup
bf9486f0f0 remove hash lookup in optimize random tick
915ac01cd3 cleanup
b90c1cd527 fix playermobcaps command
fd34d9f626 cleanup
5d663b4d36 optimize collectSpawningChunks (#382)
2025-06-29 23:58:26 +09:00

29 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: hayanesuru <hayanesuru@outlook.jp>
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 ab6fa7ed111ef16a0b6774c21988589ee2110c66..f3bed4b372f858656dbf51fb0140260bad4a41be 100644
--- a/net/minecraft/world/level/NaturalSpawner.java
+++ b/net/minecraft/world/level/NaturalSpawner.java
@@ -215,6 +215,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();