From 00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Wed, 17 Jul 2024 10:24:53 -0700 Subject: Remove Moonrise utils to MCUtils, remove duplicated/unused utils --- ...-Lazily-create-LootContext-for-criterions.patch | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 patches/server/0912-Lazily-create-LootContext-for-criterions.patch (limited to 'patches/server/0912-Lazily-create-LootContext-for-criterions.patch') diff --git a/patches/server/0912-Lazily-create-LootContext-for-criterions.patch b/patches/server/0912-Lazily-create-LootContext-for-criterions.patch new file mode 100644 index 0000000000..d1033bf7e7 --- /dev/null +++ b/patches/server/0912-Lazily-create-LootContext-for-criterions.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrPowerGamerBR +Date: Tue, 21 Nov 2023 12:16:39 -0300 +Subject: [PATCH] Lazily create LootContext for criterions + +For each player on each tick, enter block triggers are invoked, and these create loot contexts that are promptly thrown away since the trigger doesn't pass the predicate + +To avoid this, we now lazily create the LootContext if the criterion passes the predicate AND if any of the listener triggers require a loot context instance + +diff --git a/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java b/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java +index f43053ba082f9772b6ec02828fa2d6f387c32d26..35772110e9318df46a2729dbc0b5879b290011b7 100644 +--- a/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java ++++ b/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java +@@ -42,14 +42,14 @@ public abstract class SimpleCriterionTrigger> set = (Set) playerAdvancements.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak + if (set != null && !set.isEmpty()) { +- LootContext lootContext = EntityPredicate.createContext(player, player); ++ LootContext lootContext = null; // EntityPredicate.createContext(player, player); // Paper - Perf: lazily create LootContext for criterions + List> list = null; + + for (CriterionTrigger.Listener listener : set) { + T simpleInstance = listener.trigger(); + if (predicate.test(simpleInstance)) { + Optional optional = simpleInstance.player(); +- if (optional.isEmpty() || optional.get().matches(lootContext)) { ++ if (optional.isEmpty() || optional.get().matches(lootContext = (lootContext == null ? EntityPredicate.createContext(player, player) : lootContext))) { // Paper - Perf: lazily create LootContext for criterions + if (list == null) { + list = Lists.newArrayList(); + } -- cgit v1.2.3