Interface ScreenFactory


public interface ScreenFactory
A mod's menu: builds the menu's first screen each time the player opens it. This is what a mod passes to MultiversionUi.register(String, Text, ScreenFactory).
final class MyMenu implements ScreenFactory {
    public Screen create(UiHost host) {
        return MenuScreen.builder("main")
                .title(Text.translatable("mymod.title", "My Mod"))
                .add(Label.builder("hello").text(Text.literal("Hello!")).build())
                .footer(Button.builder("done").label(UiTexts.DONE).onPress(host::back).build())
                .build();
    }

    public Text buttonLabel() {
        return Text.translatable("mymod.button", "My Mod...");
    }
}

Implementations should be cheap and side-effect free apart from building the screen: create(UiHost) runs on every opening (and buttonLabel() whenever the Options screen is built), always on the game's main thread. If either throws, or create returns null, the mod's menu turns off for the rest of the session and opens as a screen saying so (Failsafe); other mods' menus are unaffected.