aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcaramel <[email protected]>2023-10-29 08:13:33 +0900
committerGitHub <[email protected]>2023-10-28 16:13:33 -0700
commitc6fac381ed94219deb569345add7fcdbeb70f060 (patch)
treeb588f5759ca531399c3e998ae96230f76f3962bc
parent8b1ac39e89097545d8836e2706a2e1b6ba732645 (diff)
downloadPaper-c6fac381ed94219deb569345add7fcdbeb70f060.tar.gz
Paper-c6fac381ed94219deb569345add7fcdbeb70f060.zip
fix UnsafeValues#loadAdvancement doesn't recalculate position (#9846)
-rw-r--r--patches/server/1037-Fix-UnsafeValues-loadAdvancement.patch14
1 files changed, 12 insertions, 2 deletions
diff --git a/patches/server/1037-Fix-UnsafeValues-loadAdvancement.patch b/patches/server/1037-Fix-UnsafeValues-loadAdvancement.patch
index 4149d87617..0aecd72d28 100644
--- a/patches/server/1037-Fix-UnsafeValues-loadAdvancement.patch
+++ b/patches/server/1037-Fix-UnsafeValues-loadAdvancement.patch
@@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/
index 4d66a9f24d718de4c6862b20ccb7240332523db4..6b31f88803041c75023a2c99bdc1efd902f0205c 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
-@@ -319,7 +319,17 @@ public final class CraftMagicNumbers implements UnsafeValues {
+@@ -319,7 +319,27 @@ public final class CraftMagicNumbers implements UnsafeValues {
JsonObject jsonobject = GsonHelper.convertToJsonObject(jsonelement, "advancement");
net.minecraft.advancements.Advancement nms = net.minecraft.advancements.Advancement.fromJson(jsonobject, new DeserializationContext(minecraftkey, MinecraftServer.getServer().getLootData()));
if (nms != null) {
@@ -22,7 +22,17 @@ index 4d66a9f24d718de4c6862b20ccb7240332523db4..6b31f88803041c75023a2c99bdc1efd9
+ mapBuilder.put(minecraftkey, holder);
+
+ MinecraftServer.getServer().getAdvancements().advancements = mapBuilder.build();
-+ MinecraftServer.getServer().getAdvancements().tree().addAll(List.of(holder));
++ final net.minecraft.advancements.AdvancementTree tree = MinecraftServer.getServer().getAdvancements().tree();
++ tree.addAll(List.of(holder));
++
++ // recalculate advancement position
++ final net.minecraft.advancements.AdvancementNode node = tree.get(minecraftkey);
++ if (node != null) {
++ final net.minecraft.advancements.AdvancementNode root = node.root();
++ if (root.holder().value().display().isPresent()) {
++ net.minecraft.advancements.TreeNodePosition.run(root);
++ }
++ }
+ // Paper end - Fix throw UnsupportedOperationException
Advancement bukkit = Bukkit.getAdvancement(key);