mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-22 08:19:31 +00:00
Try to optimize ClassInstanceMultiMap
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
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 2039b16e5e9bc0797b3f31081d221bb8b34a4dc7..ceab64ea37f69c254680a8bdd6d2a596d94cb7dc 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java
|
||||
+++ b/src/main/java/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);
|
||||
+ 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) -> 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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user