9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-23 17:09:29 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0178-throttle-mob-spawning.patch
Taiyou cc98f4982e backport 1.21.8 async mob spawn (#479)
* backport: 1.21.8 async mob spawn

* Move into patch

* fix

* fix build

---------

Co-authored-by: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Co-authored-by: hayanesuru <hayanesuru@outlook.jp>
2025-08-27 20:00:46 +02: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 6e911df433013480c2688c086a7ff1de321001bc..7764fcca95cef9f0aa46683f41d3a6805507f80a 100644
--- a/net/minecraft/world/level/NaturalSpawner.java
+++ b/net/minecraft/world/level/NaturalSpawner.java
@@ -223,6 +223,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();