aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0432-Update-itemstack-legacy-name-and-lore.patch
diff options
context:
space:
mode:
authorTomTom <[email protected]>2023-11-03 15:05:57 +0100
committerGitHub <[email protected]>2023-11-03 14:05:57 +0000
commit487109fddc74813b81bf17dfe8ec7be443963d9d (patch)
tree8fbfe1ec07553dc9149882389257d948b0486e02 /patches/server/0432-Update-itemstack-legacy-name-and-lore.patch
parent8493340be4fa69fa9369719272e5dff1b7a2f455 (diff)
downloadPaper-487109fddc74813b81bf17dfe8ec7be443963d9d.tar.gz
Paper-487109fddc74813b81bf17dfe8ec7be443963d9d.zip
Readd 0414 use distance map to optimise entity tracker (#9868)
Diffstat (limited to 'patches/server/0432-Update-itemstack-legacy-name-and-lore.patch')
-rw-r--r--patches/server/0432-Update-itemstack-legacy-name-and-lore.patch63
1 files changed, 63 insertions, 0 deletions
diff --git a/patches/server/0432-Update-itemstack-legacy-name-and-lore.patch b/patches/server/0432-Update-itemstack-legacy-name-and-lore.patch
new file mode 100644
index 0000000000..2c58b8b314
--- /dev/null
+++ b/patches/server/0432-Update-itemstack-legacy-name-and-lore.patch
@@ -0,0 +1,63 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: William Blake Galbreath <[email protected]>
+Date: Wed, 1 Jul 2020 11:57:40 -0500
+Subject: [PATCH] Update itemstack legacy name and lore
+
+
+diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
+index 877951fd07dece86fa59aee6f38a787722756688..abaafcff3f7a5e710319c93313a4ecf9874b7ef8 100644
+--- a/src/main/java/net/minecraft/world/item/ItemStack.java
++++ b/src/main/java/net/minecraft/world/item/ItemStack.java
+@@ -172,6 +172,44 @@ public final class ItemStack {
+ list.sort((java.util.Comparator<? super net.minecraft.nbt.Tag>) enchantSorter); // Paper
+ } catch (Exception ignored) {}
+ }
++
++ private void processText() {
++ CompoundTag display = getTagElement("display");
++ if (display != null) {
++ if (display.contains("Name", 8)) {
++ String json = display.getString("Name");
++ if (json != null && json.contains("\u00A7")) {
++ try {
++ display.put("Name", convert(json));
++ } catch (com.google.gson.JsonParseException jsonparseexception) {
++ display.remove("Name");
++ }
++ }
++ }
++ if (display.contains("Lore", 9)) {
++ ListTag list = display.getList("Lore", 8);
++ for (int index = 0; index < list.size(); index++) {
++ String json = list.getString(index);
++ if (json != null && json.contains("\u00A7")) { // Only try if it has legacy in the unparsed json
++ try {
++ list.set(index, convert(json));
++ } catch (com.google.gson.JsonParseException e) {
++ list.set(index, net.minecraft.nbt.StringTag.valueOf(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(net.minecraft.network.chat.Component.literal(""))));
++ }
++ }
++ }
++ }
++ }
++ }
++
++ private net.minecraft.nbt.StringTag convert(String json) {
++ Component component = Component.Serializer.fromJson(json);
++ if (component.getContents() instanceof net.minecraft.network.chat.contents.LiteralContents literalContents && literalContents.text().contains("\u00A7") && component.getSiblings().isEmpty()) {
++ // Only convert if the root component is a single comp with legacy in it, don't convert already normal components
++ component = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(literalContents.text())[0];
++ }
++ return net.minecraft.nbt.StringTag.valueOf(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(component));
++ }
+ // Paper end
+
+ public ItemStack(ItemLike item) {
+@@ -223,6 +261,7 @@ public final class ItemStack {
+ this.tag = nbttagcompound.getCompound("tag").copy();
+ // CraftBukkit end
+ this.processEnchantOrder(this.tag); // Paper
++ this.processText(); // Paper
+ this.getItem().verifyTagAfterLoad(this.tag);
+ }
+