The Bug
While playing Minecraft, if Minecraft runs out of memory, it sometimes pops up some message reminding this. However, it is not translated into other languages. The text is even not available in Crowdin as you can see in the second screenshot.
The first screenshot was taken in 1.16.2, in which version I set my language as Chinese.
Expected Result
"Out of memory!" message should be translated.
Code analysis
The "Out of memory!" message is hardcoded in the OutOfMemoryScreen
class instead of using translatable text. See this comment for a full analysis.
Linked issues
relates to 2
Attachments
Comments 6
Can also confirm this in 1.17.1 and 1.18 Pre-release 7. As stated above, this issue is occurring because the text is hardcoded in the OutOfMemoryScreen
class.
Here's a code analysis of this issue. The following is based on a decompiled version of Minecraft 1.17.1 using MCP-Reborn.
net.minecraft.client.gui.screens.OutOfMemoryScreen.java
public class OutOfMemoryScreen extends Screen {
public OutOfMemoryScreen() {
super(new TextComponent("Out of memory!"));
}
...
public boolean shouldCloseOnEsc() {
return false;
}
public void render(PoseStack $$0, int $$1, int $$2, float $$3) {
this.renderBackground($$0);
drawCenteredString($$0, this.font, this.title, this.width / 2, this.height / 4 - 60 + 20, 16777215);
drawString($$0, this.font, "Minecraft has run out of memory.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 0, 10526880);
drawString($$0, this.font, "This could be caused by a bug in the game or by the", this.width / 2 - 140, this.height / 4 - 60 + 60 + 18, 10526880);
drawString($$0, this.font, "Java Virtual Machine not being allocated enough", this.width / 2 - 140, this.height / 4 - 60 + 60 + 27, 10526880);
drawString($$0, this.font, "memory.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 36, 10526880);
drawString($$0, this.font, "To prevent level corruption, the current game has quit.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 54, 10526880);
drawString($$0, this.font, "We've tried to free up enough memory to let you go back to", this.width / 2 - 140, this.height / 4 - 60 + 60 + 63, 10526880);
drawString($$0, this.font, "the main menu and back to playing, but this may not have worked.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 72, 10526880);
drawString($$0, this.font, "Please restart the game if you see this message again.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 81, 10526880);
super.render($$0, $$1, $$2, $$3);
}
}
Can confirm in 1.18 Pre-release 2. This is because the text is hardcoded in the
OutOfMemoryScreen
class.