mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-22 00:19:33 +00:00
Update Paper
This commit is contained in:
40
patches/server/0078-Store-mob-counts-in-an-array.patch
Normal file
40
patches/server/0078-Store-mob-counts-in-an-array.patch
Normal file
@@ -0,0 +1,40 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Date: Tue, 18 Jul 2023 14:54:36 +0800
|
||||
Subject: [PATCH] Store mob counts in an array
|
||||
|
||||
This patch is Powered by Gale(https://github.com/GaleMC/Gale)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java b/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java
|
||||
index 2039b16e5e9bc0797b3f31081d221bb8b34a4dc7..ed3ef016bf22772f30c9f02d574405948e68d2af 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java
|
||||
@@ -43,13 +43,26 @@ public class LocalMobCapCalculator {
|
||||
|
||||
static class MobCounts {
|
||||
private final Object2IntMap<MobCategory> counts = new Object2IntOpenHashMap<>(MobCategory.values().length);
|
||||
+ public final int[] arrCounts = new int[MobCategory.values().length]; // Leaves - store mob counts in an array
|
||||
|
||||
public void add(MobCategory spawnGroup) {
|
||||
- this.counts.computeInt(spawnGroup, (group, density) -> density == null ? 1 : density + 1);
|
||||
+ // Leaves start - store mob counts in an array
|
||||
+ if (!org.leavesmc.leaves.LeavesConfig.storeMobCountsInArray) {
|
||||
+ this.counts.computeInt(spawnGroup, (group, density) -> density == null ? 1 : density + 1);
|
||||
+ } else {
|
||||
+ this.arrCounts[spawnGroup.ordinal()]++;
|
||||
+ }
|
||||
+ // Leaves end - store mob counts in an array
|
||||
}
|
||||
|
||||
public boolean canSpawn(MobCategory spawnGroup) {
|
||||
- return this.counts.getOrDefault(spawnGroup, 0) < spawnGroup.getMaxInstancesPerChunk();
|
||||
+ // Leaves start - store mob counts in an array
|
||||
+ if (!org.leavesmc.leaves.LeavesConfig.storeMobCountsInArray) {
|
||||
+ return this.counts.getOrDefault(spawnGroup, 0) < spawnGroup.getMaxInstancesPerChunk();
|
||||
+ } else {
|
||||
+ return this.arrCounts[spawnGroup.ordinal()] < spawnGroup.getMaxInstancesPerChunk();
|
||||
+ }
|
||||
+ // Leaves end - store mob counts in an array
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user