Cloth Config API (Fabric/Forge/NeoForge)

Cloth Config API (Fabric/Forge/NeoForge)

169M Downloads

[docs] incorrect code on autoconfig + modmenu snippet

rmobis opened this issue ยท 2 comments

commented

On Generating a Cloth Config Screen, the following snippet is present:

@Environment(EnvType.CLIENT)
class ModMenuIntegration implements ModMenuApi {

    @Override
    public ConfigScreenFactory<?> getModConfigScreenFactory() {
        return parent -> AutoConfig.getConfigScreen(ModConfig.class, parent);
    }
}

However, this produces the error Bad return type in lambda expression: Supplier<Screen> cannot be converted to Screen. Adding a .get() at the end fixes it. Here is the complete snippet with the added fix:

@Environment(EnvType.CLIENT)
class ModMenuIntegration implements ModMenuApi {

    @Override
    public ConfigScreenFactory<?> getModConfigScreenFactory() {
-        return parent -> AutoConfig.getConfigScreen(ModConfig.class, parent);
+        return parent -> AutoConfig.getConfigScreen(ModConfig.class, parent).get();
    }
}

PS: not sure if this is the correct place to open an issue; also would've liked to send a PR, but couldn't find the repo for the docs. sorry

commented

Thanks for reporting.

commented

Was about to post the same issue :P.