Skip to content

[Feature] Added FMJ Entrypoint For Mod Settings Registry#838

Open
amiralimollaei wants to merge 2 commits into
xCollateral:devfrom
amiralimollaei:dev
Open

[Feature] Added FMJ Entrypoint For Mod Settings Registry#838
amiralimollaei wants to merge 2 commits into
xCollateral:devfrom
amiralimollaei:dev

Conversation

@amiralimollaei
Copy link
Copy Markdown

I've added a very simple API for other mods to implement and a custom entrypoint that other mods can add to their fabric.mod.json that allows for them to register their own configuration pages to the ModSettingsRegistry without having a hard dependency on VulkanMod, here is an example:

  1. implement the VkModSettingsFactory:
package net.vulkanmod.config.api.test;

import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;
import net.vulkanmod.config.api.VkModSettingsEntryBuilder;
import net.vulkanmod.config.api.VkModSettingsFactory;
import net.vulkanmod.config.gui.ModSettingsEntry;
import net.vulkanmod.config.option.CyclingOption;
import net.vulkanmod.config.option.RangeOption;
import net.vulkanmod.config.option.SwitchOption;

public class VkModSettingsFactoryImpl implements VkModSettingsFactory {
    @Override
    public ModSettingsEntry build(VkModSettingsEntryBuilder builder) {
        return builder
                .setModName(Component.literal("Test Mod").withStyle(ChatFormatting.RED))
                .setIcon(Identifier.fromNamespaceAndPath("test-mod", "icon.png"))
                .withPage("Test Page")
                    .withOptionBlock("Test Block")
                        .addOption(new SwitchOption(
                                Component.literal("Test SwitchOption"),
                                (v) -> {},
                                () -> false
                        ))
                        .addOption(
                                new CyclingOption<ChatFormatting>(
                                        Component.literal("Test CyclingOption"),
                                        ChatFormatting.values(),
                                        (v) -> {},
                                        () -> ChatFormatting.RESET
                                ).setTranslator((v) -> Component.literal(v.name()).withStyle(v))
                        )
                        .addOption(new RangeOption(
                                Component.literal("Test RangeOption"),
                                0,
                                100,
                                1,
                                (v) -> {},
                                () -> 0
                        ))
                        .finish()
                    .withOptionBlock("Test Empty Block")
                        .finish()
                .finish()
                .withPage("Test Page 2")
                    .withOptionBlock("Test Empty Block")
                        .finish()
                .finish()
                .setOnApply(() -> {
                    // save configuration
                })
                .build();
    }
}
  1. add the class VkModSettingsFactoryImpl to the fabric.mod.json:
... other fields
"entrypoints": {
    "vulkanmod:mod_settings_registry": [
        "net.vulkanmod.config.api.test.VkModSettingsFactoryImpl"
    ]
}
... other fields

it will be loaded and added to the mod registry automatically (when VulkanMod exists) and will not do anything when VulkanMod is not present, allowing other mods to register their own ModSettingsEntry without having a hard dependency on VulkanMod.

@amiralimollaei amiralimollaei marked this pull request as ready for review June 7, 2026 16:56
@amiralimollaei
Copy link
Copy Markdown
Author

amiralimollaei commented Jun 7, 2026

I've migrated NEV's configuration to this VkModSettingsFactory to find potential bugs with the implementation and to provide an example:

https://github.com/amiralimollaei/not-enough-vulkan/blob/vulkanmod-pr/fmj-settings-entrypoint/src/client/java/io/github/amiralimollaei/mods/notenoughvulkan/config/NEVSettingsFactory.java

amiralimollaei/not-enough-vulkan@b62e39c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant