9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-20 15:29:30 +00:00
Files
Gale/patches/server/0088-Store-mob-counts-in-an-array.patch
2022-12-13 14:28:30 +01:00

39 lines
1.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Nov 2022 17:46:23 +0100
Subject: [PATCH] Store mob counts in an array
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
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/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java b/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java
index 84c766e09898cfc07d6e07e80f4b9aa318050a62..8357b1e16b2fb1b84c7d14da577e95d91450b53e 100644
--- a/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java
+++ b/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java
@@ -47,16 +47,14 @@ public class LocalMobCapCalculator {
}
static class MobCounts {
- private final Object2IntMap<MobCategory> counts = new Object2IntOpenHashMap<>(MobCategory.values().length);
+ public final int[] counts = new int[MobCategory.values().length]; // Gale - VMP - store mob counts in an array
public void add(MobCategory spawnGroup) {
- this.counts.computeInt(spawnGroup, (group, density) -> {
- return density == null ? 1 : density + 1;
- });
+ this.counts[spawnGroup.ordinal()]++; // Gale - VMP - store mob counts in an array
}
public boolean canSpawn(MobCategory spawnGroup) {
- return this.counts.getOrDefault(spawnGroup, 0) < spawnGroup.getMaxInstancesPerChunk();
+ return this.counts[spawnGroup.ordinal()] < spawnGroup.getMaxInstancesPerChunk(); // Gale - VMP - store mob counts in an array
}
}
}