Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TranslatableComponent not working on Sign blocks #10643

Open
Sergio-Luis20 opened this issue May 1, 2024 · 1 comment
Open

TranslatableComponent not working on Sign blocks #10643

Sergio-Luis20 opened this issue May 1, 2024 · 1 comment
Labels
priority: low This issue only describes a minor inconvenience. status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.20.4 Game version 1.20.4

Comments

@Sergio-Luis20
Copy link

Expected behavior

I expected using Component.translatable(...) would work on Sign blocks. Using server-side translations with GlobalTranslator should show the translated text to the client in a line of a Sign that uses that implementation of Component.

Observed/Actual behavior

In lines that uses TranslatableComponent, it only shows the translation key as text instead of the actual translation from ResourceBundle. I've checked the keys and they're all correct. Styles as color and decorations work well, only the text shown is the problem.
imagem_2024-05-01_174404945

Steps/models to reproduce

Just get a Sign block from a World and try to use Component.translatable(...) to write some of its lines. Update the Sign using the SignSide method.

Here is my code:

MinigameInfo info = minigame.getInfo();
Component[] lines = new Component[4];
lines[0] = Component.text(info.name() + " " + index);
switch(state) {
case AVAILABLE -> {
lines[1] = Component.translatable("minigame.sign.available", NamedTextColor.GREEN);
lines[2] = Component.text(minigame.getWorld().getPlayerCount() + "/"
+ info.maxPlayers(), NamedTextColor.WHITE, TextDecoration.BOLD);
lines[3] = Component.text("» ONLINE «", NamedTextColor.AQUA, TextDecoration.BOLD);
}
case RUNNING -> {
lines[1] = Component.translatable("minigame.sign.running", NamedTextColor.RED);
lines[2] = Component.text(minigame.getWorld().getPlayerCount() + "/"
+ info.maxPlayers(), NamedTextColor.WHITE, TextDecoration.BOLD);
lines[3] = Component.text("» ONLINE «", NamedTextColor.AQUA, TextDecoration.BOLD);
}
case WAITING -> {
lines[1] = Component.empty();
lines[2] = Component.text("-/-", NamedTextColor.WHITE, TextDecoration.BOLD);
lines[3] = Component.translatable("minigame.sign.waiting", NamedTextColor.BLUE, TextDecoration.BOLD);
}
}
SignSide side = sign.getSide(Side.FRONT);
for(int i = 0; i < lines.length; i++) {
side.line(i, lines[i]);
}
sign.update();

Plugin and Datapack List

Plugins:
imagem_2024-05-01_174957415
Datapacks:
imagem_2024-05-01_175100237

Paper version

This server is running Paper version git-Paper-459 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 88419b2)
You are 37 version(s) behind
Download the new version at: https://papermc.io/downloads/paper

Other

No response

@Sergio-Luis20 Sergio-Luis20 added status: needs triage type: bug Something doesn't work as it was intended to. labels May 1, 2024
@papermc-sniffer papermc-sniffer bot added the version: 1.20.4 Game version 1.20.4 label May 1, 2024
@Machine-Maker Machine-Maker added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. priority: low This issue only describes a minor inconvenience. and removed status: needs triage labels May 3, 2024
@Machine-Maker
Copy link
Member

I marked this as low priority, because the fix for this is currently pretty ugly as it would require re-creating specific packets for each player instead of using the same packet data for all players it's being sent to. The reason this same problem doesn't apply to other areas, is that the text is "translated" as it's written to the bytebuf, so after the packet has been created. It's very possible mojang will also change block entities to a similar system in the future, and this is more feasible then. You can see where I got to on this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low This issue only describes a minor inconvenience. status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.20.4 Game version 1.20.4
Projects
Status: ✅ Accepted
Development

No branches or pull requests

2 participants