diff options
author | maxcom1 <[email protected]> | 2024-03-23 22:26:17 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-03-23 17:26:17 -0400 |
commit | b6001403e9703cadaa6e8c8558e732b91c3c6d6e (patch) | |
tree | a8c57bbc334a8ad48d4ad2b43db335667b142bee /patches/server/0399-Update-itemstack-legacy-name-and-lore.patch | |
parent | 9ec7dfcbc41c6e625de0050b6997160a75df9f44 (diff) | |
download | Paper-b6001403e9703cadaa6e8c8558e732b91c3c6d6e.tar.gz Paper-b6001403e9703cadaa6e8c8558e732b91c3c6d6e.zip |
Add methods to change entity physics (#10334)
Diffstat (limited to 'patches/server/0399-Update-itemstack-legacy-name-and-lore.patch')
-rw-r--r-- | patches/server/0399-Update-itemstack-legacy-name-and-lore.patch | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/patches/server/0399-Update-itemstack-legacy-name-and-lore.patch b/patches/server/0399-Update-itemstack-legacy-name-and-lore.patch new file mode 100644 index 0000000000..49a60bd241 --- /dev/null +++ b/patches/server/0399-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 0a3fec9b82a4d744f9046aebe30f80bb6e56c500..4a6e128c62c890c34b62f826d586ae6a424e7f01 100644 +--- a/src/main/java/net/minecraft/world/item/ItemStack.java ++++ b/src/main/java/net/minecraft/world/item/ItemStack.java +@@ -196,6 +196,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", net.minecraft.nbt.Tag.TAG_STRING)) { ++ 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", net.minecraft.nbt.Tag.TAG_LIST)) { ++ ListTag list = display.getList("Lore", net.minecraft.nbt.Tag.TAG_STRING); ++ 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 final net.minecraft.network.chat.contents.PlainTextContents plainTextContents && plainTextContents.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(plainTextContents.text())[0]; ++ } ++ return net.minecraft.nbt.StringTag.valueOf(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(component)); ++ } + // Paper end + + public ItemStack(ItemLike item) { +@@ -245,6 +283,7 @@ public final class ItemStack { + if (nbttagcompound.contains("tag", 10)) { + this.tag = nbttagcompound.getCompound("tag").copy(); + this.processEnchantOrder(this.tag); // Paper ++ this.processText(); // Paper - Update itemstack legacy name and lore + this.getItem().verifyTagAfterLoad(this.tag); + } + |