Skip to content

Screen Builder

Lortseam edited this page Sep 2, 2023 · 11 revisions

To build a config screen, a ConfigScreenBuilder is needed. CompleteConfig provides different screen builders, each one in a seperate GUI module. If you didn't add one of the GUI modules yet, check out the setup page.

Cloth Config (gui-cloth)

ConfigScreenBuilder screenBuilder = new ClothConfigScreenBuilder();

YetAnotherConfigLib (gui-yacl)

ConfigScreenBuilder screenBuilder = new YaclScreenBuilder();

Build and display

The build method takes the parent screen and your config as arguments and returns the generated screen.

Screen configScreen = screenBuilder.build(parentScreen, config);

Mod Menu

public class ModMenuIntegration implements ModMenuApi {

    private static final ClothConfigScreenBuilder configScreenBuilder = new ClothConfigScreenBuilder();

    @Override
    public ConfigScreenFactory<?> getModConfigScreenFactory() {
        return parent -> configScreenBuilder.build(parent, MyMod.getConfig());
    }

}

Remember to add the modmenu entrypoint to your fabric.mod.json file.

Open screen manually

MinecraftClient.getInstance().setScreen(configScreen);

NEXT: Localization

Clone this wiki locally