Translations and Integration
SSGL uses Minecraft's native Component system for user-visible text.
This means you can use translated components throughout your GUI instead of hardcoding strings.
Translatable components
Example:
Gui gui = SSGL.create(
Component.translatable("mymod.gui.title")
);
gui.add(
GuiElement.label(
Component.translatable("mymod.gui.general")
)
);
gui.add(
GuiElement.button(
Component.translatable("mymod.gui.apply"),
this::applySettings
)
);
Language file
Create:
src/main/resources/assets/mymod/lang/en_us.json
Example:
{
"mymod.gui.title": "Camera Settings",
"mymod.gui.general": "General",
"mymod.gui.apply": "Apply",
"mymod.gui.enabled": "Enabled",
"mymod.gui.volume": "Volume",
"mymod.gui.username": "Username",
"mymod.gui.username.placeholder": "Enter username",
"mymod.gui.camera.tooltip": "Open camera"
}
You can add additional language files to support more languages.
SSGL identifiers
SSGL also provides a convenience method for creating identifiers in its own namespace:
Identifier identifier = SSGL.id("example");
This is equivalent to:
Identifier identifier =
Identifier.fromNamespaceAndPath("ssgl", "example");
For your own mod's resources, use your own namespace:
Identifier cameraTexture =
Identifier.fromNamespaceAndPath(
"mymod",
"textures/gui/camera.png"
);
Client-thread operations
SSGL is a client-side library.
Create and open GUIs, rebuild widgets, and update GUI-bound values on Minecraft's client thread.
When working with asynchronous tasks, use:
Minecraft.getInstance().execute(() -> {
guiValue.set(newValue);
});
Do not perform Minecraft GUI rendering or widget operations from background threads.