mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 17:01:56 +01:00
pr changes, flat array
This commit is contained in:
parent
2e90c00a95
commit
67fb7e9f66
1 changed files with 5 additions and 9 deletions
|
@ -52,7 +52,7 @@ index f525fd1b4..494759a1c 100644
|
||||||
|
|
||||||
if (k <= l1) {
|
if (k <= l1) {
|
||||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||||
index 004c3ec47..dc301c6f4 100644
|
index 004c3ec47..e2d591f8f 100644
|
||||||
--- a/src/main/java/net/minecraft/server/World.java
|
--- a/src/main/java/net/minecraft/server/World.java
|
||||||
+++ b/src/main/java/net/minecraft/server/World.java
|
+++ b/src/main/java/net/minecraft/server/World.java
|
||||||
@@ -0,0 +0,0 @@ import java.util.Iterator;
|
@@ -0,0 +0,0 @@ import java.util.Iterator;
|
||||||
|
@ -118,18 +118,14 @@ index 004c3ec47..dc301c6f4 100644
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start - entity count cache
|
+ // Paper start - entity count cache
|
||||||
+ private Map<EnumCreatureType, Integer> countCache = new EnumMap(EnumCreatureType.class);
|
+ private final int[] countCache = new int[EnumCreatureType.values().length];
|
||||||
+
|
+
|
||||||
+ public int getCreatureCount(EnumCreatureType type) {
|
+ public int getCreatureCount(EnumCreatureType type) {
|
||||||
+ Integer count = countCache.get(type);
|
+ return countCache[type.ordinal()];
|
||||||
+
|
|
||||||
+ return count == null ? 0 : count;
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ protected void updateEntityCount(EnumCreatureType type, boolean incr) {
|
+ protected void updateEntityCount(EnumCreatureType type, boolean incr) {
|
||||||
+ Integer countObject = countCache.get(type);
|
+ int count = countCache[type.ordinal()];
|
||||||
+
|
|
||||||
+ int count = countObject == null ? 0 : countObject;
|
|
||||||
+
|
+
|
||||||
+ if (incr) count++;
|
+ if (incr) count++;
|
||||||
+ else count--;
|
+ else count--;
|
||||||
|
@ -139,7 +135,7 @@ index 004c3ec47..dc301c6f4 100644
|
||||||
+ count = 0;
|
+ count = 0;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ countCache.put(type, count);
|
+ countCache[type.ordinal()] = count;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ protected void updateEntityCount(Entity entity, boolean incr) {
|
+ protected void updateEntityCount(Entity entity, boolean incr) {
|
||||||
|
|
Loading…
Reference in a new issue