mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 11:06:29 +01:00
5c7081fecc
* Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories CraftBukkit Changes:4090d01f
SPIGOT-5047: Correct slot types for 1.14 inventoriese8c08362
SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.d445af3b
SPIGOT-5067: Add item meta for 1.14 spawn eggs * Bring Chunk load checks in-line with spigot As of the last upstream merge spigot now checks ticket level status when returning loaded chunks for a world from api. Now our checks will respect that decision. * Fix spawn ticket levels Vanilla would keep the inner chunks of spawn available for ticking, however my changes made all chunks non-ticking. Resolve by changing ticket levels for spawn chunks inside the border to respect this behavior. * Make World#getChunkIfLoadedImmediately return only entity ticking chunks Mojang appears to be using chunks with level > 33 (non-ticking chunks) as cached chunks and not actually loaded chunks. * Bring all loaded checks in line with spigot Loaded chunks must be at least border chunks, or level <= 33
67 lines
3.5 KiB
Diff
67 lines
3.5 KiB
Diff
From d92da3d8dc171241aaf1f35a495e450c7e2550bf Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Thu, 4 Apr 2019 17:55:05 -0700
|
|
Subject: [PATCH] Optimize GameRules to use LinkedHashMap
|
|
|
|
Previously TreeMap was used which has poor get(K) performance.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/GameRules.java b/src/main/java/net/minecraft/server/GameRules.java
|
|
index 3de9d264db..c6a8004745 100644
|
|
--- a/src/main/java/net/minecraft/server/GameRules.java
|
|
+++ b/src/main/java/net/minecraft/server/GameRules.java
|
|
@@ -17,7 +17,17 @@ import javax.annotation.Nullable;
|
|
|
|
public class GameRules {
|
|
|
|
- private static final TreeMap<String, GameRules.GameRuleDefinition> a = SystemUtils.a(new TreeMap(), (treemap) -> { // Paper - decompile fix
|
|
+ // Paper start - Optimize GameRules
|
|
+ private static final int RULES_SIZE = 256;
|
|
+
|
|
+ private static <K, V> java.util.LinkedHashMap<K, V> linkedMapOf(final int capacity, final TreeMap<K, V> map) {
|
|
+ final java.util.LinkedHashMap<K, V> ret = new java.util.LinkedHashMap<>(capacity);
|
|
+ ret.putAll(map);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ private static final java.util.LinkedHashMap<String, GameRuleDefinition> a = GameRules.linkedMapOf(RULES_SIZE, SystemUtils.a(new TreeMap(), (treemap) -> { // Paper - decompile fix
|
|
+ // Paper end
|
|
treemap.put("doFireTick", new GameRules.GameRuleDefinition("true", GameRules.EnumGameRuleType.BOOLEAN_VALUE));
|
|
treemap.put("mobGriefing", new GameRules.GameRuleDefinition("true", GameRules.EnumGameRuleType.BOOLEAN_VALUE));
|
|
treemap.put("keepInventory", new GameRules.GameRuleDefinition("false", GameRules.EnumGameRuleType.BOOLEAN_VALUE));
|
|
@@ -51,8 +61,8 @@ public class GameRules {
|
|
treemap.put("doLimitedCrafting", new GameRules.GameRuleDefinition("false", GameRules.EnumGameRuleType.BOOLEAN_VALUE));
|
|
treemap.put("maxCommandChainLength", new GameRules.GameRuleDefinition("65536", GameRules.EnumGameRuleType.NUMERICAL_VALUE));
|
|
treemap.put("announceAdvancements", new GameRules.GameRuleDefinition("true", GameRules.EnumGameRuleType.BOOLEAN_VALUE));
|
|
- });
|
|
- private final TreeMap<String, GameRules.GameRuleValue> b = new TreeMap();
|
|
+ })); // Paper - Optimize GameRules
|
|
+ private final java.util.LinkedHashMap<String, GameRuleValue> b = new java.util.LinkedHashMap<>(RULES_SIZE); // Paper - Optimize GameRules
|
|
|
|
public GameRules() {
|
|
Iterator iterator = GameRules.a.entrySet().iterator();
|
|
@@ -116,7 +126,7 @@ public class GameRules {
|
|
return (GameRules.GameRuleValue) this.b.get(s);
|
|
}
|
|
|
|
- public static TreeMap<String, GameRules.GameRuleDefinition> getGameRules() {
|
|
+ public static java.util.LinkedHashMap<String, GameRuleDefinition> getGameRules() { // Paper - Optimize GameRules
|
|
return GameRules.a;
|
|
}
|
|
|
|
diff --git a/src/test/java/org/bukkit/GameRuleTest.java b/src/test/java/org/bukkit/GameRuleTest.java
|
|
index 1ed0f4cf2b..40edb8d668 100644
|
|
--- a/src/test/java/org/bukkit/GameRuleTest.java
|
|
+++ b/src/test/java/org/bukkit/GameRuleTest.java
|
|
@@ -21,7 +21,7 @@ public class GameRuleTest {
|
|
|
|
@Test
|
|
public void testMinecraftRules() {
|
|
- TreeMap<String, GameRules.GameRuleDefinition> minecraftRules = GameRules.getGameRules();
|
|
+ Map<String, GameRules.GameRuleDefinition> minecraftRules = GameRules.getGameRules(); // Paper - Optimize GameRules
|
|
|
|
for (Map.Entry<String, GameRules.GameRuleDefinition> entry : minecraftRules.entrySet()) {
|
|
GameRule<?> bukkitRule = GameRule.getByName(entry.getKey());
|
|
--
|
|
2.21.0
|
|
|