vmp: spawn_density_cap
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: ishland <ishlandmc@yeah.net>
|
||||
Date: Mon, 1 Jan 2022 11:05:22 +0100
|
||||
Date: Sat, 1 Jan 2022 11:05:22 +0100
|
||||
Subject: [PATCH] vmp: entity.iteration
|
||||
|
||||
Original code by RelativityMC, licensed under MIT
|
||||
|
||||
43
patches/server/0091-vmp-spawn_density_cap.patch
Normal file
43
patches/server/0091-vmp-spawn_density_cap.patch
Normal file
@@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: ishland <ishlandmc@yeah.net>
|
||||
Date: Sat, 4 Dec 2021 12:09:59 +0100
|
||||
Subject: [PATCH] vmp: spawn_density_cap
|
||||
|
||||
Original code by RelativityMC, licensed under MIT
|
||||
You can find the original code on https://github.com/RelativityMC/VMP-fabric (Yarn mappings)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java b/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java
|
||||
index 84c766e09898cfc07d6e07e80f4b9aa318050a62..9cb1acdfe2a514099e9517118c7cd448bd3c2d68 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java
|
||||
@@ -47,16 +47,25 @@ public class LocalMobCapCalculator {
|
||||
}
|
||||
|
||||
static class MobCounts {
|
||||
- private final Object2IntMap<MobCategory> counts = new Object2IntOpenHashMap<>(MobCategory.values().length);
|
||||
+ // private final Object2IntMap<MobCategory> counts = new Object2IntOpenHashMap<>(MobCategory.values().length); // Mirai
|
||||
+ private final int[] spawnGroupDensities = new int[MobCategory.values().length]; // Mirai
|
||||
|
||||
+ // Mirai start
|
||||
+ /**
|
||||
+ * @author ishland
|
||||
+ * @reason opt: replace with array access
|
||||
+ */
|
||||
public void add(MobCategory spawnGroup) {
|
||||
- this.counts.computeInt(spawnGroup, (group, density) -> {
|
||||
- return density == null ? 1 : density + 1;
|
||||
- });
|
||||
+ this.spawnGroupDensities[spawnGroup.ordinal()] ++;
|
||||
}
|
||||
|
||||
+ /**
|
||||
+ * @author ishland
|
||||
+ * @reason opt: replace with array access
|
||||
+ */
|
||||
public boolean canSpawn(MobCategory spawnGroup) {
|
||||
- return this.counts.getOrDefault(spawnGroup, 0) < spawnGroup.getMaxInstancesPerChunk();
|
||||
+ return this.spawnGroupDensities[spawnGroup.ordinal()] < spawnGroup.getMaxInstancesPerChunk();
|
||||
}
|
||||
+ // Mirai end
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user