diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 6a9f49e81a..1908259a8d 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -2207,10 +2207,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static final int DEFAULT_NBT_QUOTA = 2097152; private final ByteBuf source; -+ public java.util.Locale adventure$locale; // Paper - track player's locale for server-side translations ++ @Nullable public final java.util.Locale adventure$locale; // Paper - track player's locale for server-side translations public static final short MAX_STRING_LENGTH = Short.MAX_VALUE; public static final int MAX_COMPONENT_STRING_LENGTH = 262144; private static final int PUBLIC_KEY_SIZE = 256; +@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf { + private static final Gson GSON = new Gson(); + + public FriendlyByteBuf(ByteBuf parent) { ++ this.adventure$locale = PacketEncoder.ADVENTURE_LOCALE.get(); // Paper - track player's locale for server-side translations + this.source = parent; + } + @@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf { } @@ -2234,13 +2242,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/network/PacketEncoder.java +++ b/src/main/java/net/minecraft/network/PacketEncoder.java @@ -0,0 +0,0 @@ public class PacketEncoder extends MessageToByteEncode + this.protocolInfo = state; + } + ++ static final ThreadLocal ADVENTURE_LOCALE = ThreadLocal.withInitial(() -> null); // Paper - adventure; set player's locale protected void encode(ChannelHandlerContext channelHandlerContext, Packet packet, ByteBuf byteBuf) throws Exception { PacketType> packetType = packet.type(); -+ if (byteBuf instanceof FriendlyByteBuf friendlyByteBuf) friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper - adventure; set player's locale try { ++ ADVENTURE_LOCALE.set(channelHandlerContext.channel().attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).get()); // Paper - adventure; set player's locale this.protocolInfo.codec().encode(byteBuf, packet); int i = byteBuf.readableBytes(); + if (LOGGER.isDebugEnabled()) { diff --git a/src/main/java/net/minecraft/network/chat/ChatDecorator.java b/src/main/java/net/minecraft/network/chat/ChatDecorator.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/network/chat/ChatDecorator.java @@ -3212,23 +3225,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder { - return ItemStack.EMPTY; - } else { - Holder holder = (Holder) ITEM_STREAM_CODEC.decode(registryfriendlybytebuf); // CraftBukkit - decompile error -- DataComponentPatch datacomponentpatch = (DataComponentPatch) DataComponentPatch.STREAM_CODEC.decode(registryfriendlybytebuf); + CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); + // Spigot end + ITEM_STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.getItemHolder()); // CraftBukkit - decompile error + // Paper start - adventure; conditionally render translatable components -+ DataComponentPatch datacomponentpatch; + boolean prev = net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.get(); + try { -+ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(true); -+ datacomponentpatch = (DataComponentPatch) DataComponentPatch.STREAM_CODEC.decode(registryfriendlybytebuf); ++ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(true); + DataComponentPatch.STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.components.asPatch()); + } finally { + net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(prev); + } + // Paper end - adventure; conditionally render translatable components - - // CraftBukkit start - ItemStack itemstack = new ItemStack(holder, i, datacomponentpatch); + } + } + }; diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java diff --git a/patches/server/Remove-unnecessary-itemmeta-handling.patch b/patches/server/Remove-unnecessary-itemmeta-handling.patch index 6ee3aacfdb..27a43a27ea 100644 --- a/patches/server/Remove-unnecessary-itemmeta-handling.patch +++ b/patches/server/Remove-unnecessary-itemmeta-handling.patch @@ -25,4 +25,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); // Paper - This is no longer with raw NBT being handled in metadata // Spigot end ITEM_STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.getItemHolder()); // CraftBukkit - decompile error - DataComponentPatch.STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.components.asPatch()); + // Paper start - adventure; conditionally render translatable components