From 569742e034d2a2900e5ad8e5a508e439ce285f27 Mon Sep 17 00:00:00 2001 From: Etil <81570777+etil2jz@users.noreply.github.com> Date: Tue, 21 Dec 2021 19:15:20 +0100 Subject: [PATCH] lithium: store gamerules in fastutil hashmap --- ...-store-gamerules-in-fastutil-hashmap.patch | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 patches/server/0083-lithium-store-gamerules-in-fastutil-hashmap.patch diff --git a/patches/server/0083-lithium-store-gamerules-in-fastutil-hashmap.patch b/patches/server/0083-lithium-store-gamerules-in-fastutil-hashmap.patch new file mode 100644 index 0000000..b4fc55e --- /dev/null +++ b/patches/server/0083-lithium-store-gamerules-in-fastutil-hashmap.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Etil <81570777+etil2jz@users.noreply.github.com> +Date: Tue, 21 Dec 2021 19:14:46 +0100 +Subject: [PATCH] lithium: store gamerules in fastutil hashmap + +Original code by CaffeineMC, licensed under GNU Lesser General Public License v3.0 +You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) + +diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java +index 6c9e574851b518242dbbee9bce954b44dbaeecb6..e7bbbff4ef230b3df1e72ed1705e1b74483e76ac 100644 +--- a/src/main/java/net/minecraft/world/level/GameRules.java ++++ b/src/main/java/net/minecraft/world/level/GameRules.java +@@ -27,6 +27,7 @@ import net.minecraft.server.MinecraftServer; + import net.minecraft.server.level.ServerPlayer; + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; ++import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; // JettPack + + public class GameRules { + +@@ -110,14 +111,16 @@ public class GameRules { + + public GameRules() { + // Pufferfish start - use this to ensure gameruleArray is initialized +- this((Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> { ++ // JettPack start - lithium: store gamerules in fastutil hashmap ++ this(new Object2ObjectOpenHashMap<>((Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> { + return ((GameRules.Type) entry.getValue()).createRule(); +- }))); ++ })))); ++ // JettPack end + // Pufferfish end + } + + private GameRules(Map, GameRules.Value> rules) { +- this.rules = rules; ++ this.rules = new Object2ObjectOpenHashMap<>(rules); // JettPack - lithium: store gamerules in fastutil hashmap + + // Pufferfish start + int arraySize = rules.keySet().stream().mapToInt(key -> key.gameRuleIndex).max().orElse(-1) + 1;