mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
37 lines
1.8 KiB
Diff
37 lines
1.8 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/net/minecraft/world/level/LocalMobCapCalculator.java b/net/minecraft/world/level/LocalMobCapCalculator.java
|
|
index 9641219c190261dea0db5f95f040a705ba0a3ff9..635afc61ee441924e1d64dbcf6dbab057d80c740 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]; // Gale - 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()]++; // Gale - 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(); // Gale - VMP - store mob counts in an array
|
|
}
|
|
}
|
|
}
|