9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-23 16:59:24 +00:00
Files
DivineMC/divinemc-server/minecraft-patches/features/0030-VMP-store-mob-counts-in-an-array.patch
2025-07-06 03:10:05 +03:00

34 lines
1.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sun, 6 Jul 2025 02:33:29 +0300
Subject: [PATCH] VMP: store mob counts in an array
This patch is based on the following mixin:
"com/ishland/vmp/mixins/general/spawn_density_cap/MixinSpawnDensityCapperDensityCap.java"
By: ishland <ishlandmc@yeah.net>
As part of: VMP (https://github.com/RelativityMC/VMP-fabric)
Licensed under: MIT (https://opensource.org/licenses/MIT)
diff --git a/net/minecraft/world/level/LocalMobCapCalculator.java b/net/minecraft/world/level/LocalMobCapCalculator.java
index 9641219c190261dea0db5f95f040a705ba0a3ff9..d9fe183dbf072f82afae63792967d6e7953d7151 100644
--- a/net/minecraft/world/level/LocalMobCapCalculator.java
+++ b/net/minecraft/world/level/LocalMobCapCalculator.java
@@ -42,14 +42,14 @@ public class LocalMobCapCalculator {
}
static class MobCounts {
- private final Object2IntMap<MobCategory> counts = new Object2IntOpenHashMap<>(MobCategory.values().length);
+ private final int[] counts = new int[MobCategory.values().length]; // DivineMC - VMP: store mob counts in an array
public void add(MobCategory category) {
- this.counts.computeInt(category, (key, value) -> value == null ? 1 : value + 1);
+ this.counts[category.ordinal()]++; // DivineMC - VMP: store mob counts in an array
}
public boolean canSpawn(MobCategory category) {
- return this.counts.getOrDefault(category, 0) < category.getMaxInstancesPerChunk();
+ return this.counts[category.ordinal()] < category.getMaxInstancesPerChunk(); // DivineMC - VMP: store mob counts in an array
}
}
}