mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-03 23:07:40 +01:00
fix adventure translations
This commit is contained in:
parent
8cb49c8d67
commit
6ba0e1048f
@ -2207,10 +2207,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
public static final int DEFAULT_NBT_QUOTA = 2097152;
|
public static final int DEFAULT_NBT_QUOTA = 2097152;
|
||||||
private final ByteBuf source;
|
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 short MAX_STRING_LENGTH = Short.MAX_VALUE;
|
||||||
public static final int MAX_COMPONENT_STRING_LENGTH = 262144;
|
public static final int MAX_COMPONENT_STRING_LENGTH = 262144;
|
||||||
private static final int PUBLIC_KEY_SIZE = 256;
|
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 {
|
@@ -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
|
--- a/src/main/java/net/minecraft/network/PacketEncoder.java
|
||||||
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
|
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
|
||||||
@@ -0,0 +0,0 @@ public class PacketEncoder<T extends PacketListener> extends MessageToByteEncode
|
@@ -0,0 +0,0 @@ public class PacketEncoder<T extends PacketListener> extends MessageToByteEncode
|
||||||
|
this.protocolInfo = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ static final ThreadLocal<java.util.Locale> ADVENTURE_LOCALE = ThreadLocal.withInitial(() -> null); // Paper - adventure; set player's locale
|
||||||
protected void encode(ChannelHandlerContext channelHandlerContext, Packet<T> packet, ByteBuf byteBuf) throws Exception {
|
protected void encode(ChannelHandlerContext channelHandlerContext, Packet<T> packet, ByteBuf byteBuf) throws Exception {
|
||||||
PacketType<? extends Packet<? super T>> packetType = packet.type();
|
PacketType<? extends Packet<? super T>> 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 {
|
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);
|
this.protocolInfo.codec().encode(byteBuf, packet);
|
||||||
int i = byteBuf.readableBytes();
|
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
|
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
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/network/chat/ChatDecorator.java
|
--- 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
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||||
+++ b/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 {
|
@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder {
|
||||||
return ItemStack.EMPTY;
|
CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
|
||||||
} else {
|
// Spigot end
|
||||||
Holder<Item> holder = (Holder) ITEM_STREAM_CODEC.decode(registryfriendlybytebuf); // CraftBukkit - decompile error
|
ITEM_STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.getItemHolder()); // CraftBukkit - decompile error
|
||||||
- DataComponentPatch datacomponentpatch = (DataComponentPatch) DataComponentPatch.STREAM_CODEC.decode(registryfriendlybytebuf);
|
|
||||||
+ // Paper start - adventure; conditionally render translatable components
|
+ // Paper start - adventure; conditionally render translatable components
|
||||||
+ DataComponentPatch datacomponentpatch;
|
|
||||||
+ boolean prev = net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.get();
|
+ boolean prev = net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.get();
|
||||||
+ try {
|
+ try {
|
||||||
+ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(true);
|
+ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(true);
|
||||||
+ datacomponentpatch = (DataComponentPatch) DataComponentPatch.STREAM_CODEC.decode(registryfriendlybytebuf);
|
DataComponentPatch.STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.components.asPatch());
|
||||||
+ } finally {
|
+ } finally {
|
||||||
+ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(prev);
|
+ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(prev);
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - adventure; conditionally render translatable components
|
+ // 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
|
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
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||||
|
@ -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
|
+ // CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); // Paper - This is no longer with raw NBT being handled in metadata
|
||||||
// Spigot end
|
// Spigot end
|
||||||
ITEM_STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.getItemHolder()); // CraftBukkit - decompile error
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user