A simple API for adding (debug) text to the game HUD.
@EventListener
private static void renderHudText(HudTextRenderEvent event) {
// The position will change based on whether the debug HUD is enabled
event.left.add(new HudTextLine("This text displays regardless of whether the debug HUD is enabled!"));
if (event.debug) {
event.left.add(new HudTextLine("This text only displays on the debug HUD!", 0xE0E0E0));
} else {
// This will only succeed if the priority exceeds other mods with version text or other mods' version texts are disabled
event.setVersion(new HudTextLine("StationAPI v2.0-alpha.3"));
Collections.addAll(event.right,
new HudTextLine("Hello " + event.minecraft.player.name + "!"),
new HudTextLine("This line is doubly offset from the last. Perchance.", 0xFFFFFF, 20)
);
}
}
A simple API for adding (debug) text to the game HUD.