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 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 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 } } }