{"id":28386973,"url":"https://github.com/caffeinemc/mixin-config","last_synced_at":"2025-10-09T20:06:43.362Z","repository":{"id":104230617,"uuid":"438331106","full_name":"CaffeineMC/mixin-config","owner":"CaffeineMC","description":"Mixin config system for CaffeineMC's fabric mods","archived":false,"fork":false,"pushed_at":"2022-05-18T19:59:22.000Z","size":87,"stargazers_count":11,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-29T04:03:13.467Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CaffeineMC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-12-14T16:52:34.000Z","updated_at":"2025-03-20T12:17:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"9afdb43d-73ab-46f8-8906-01e2e9c70b1f","html_url":"https://github.com/CaffeineMC/mixin-config","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CaffeineMC/mixin-config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaffeineMC%2Fmixin-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaffeineMC%2Fmixin-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaffeineMC%2Fmixin-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaffeineMC%2Fmixin-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CaffeineMC","download_url":"https://codeload.github.com/CaffeineMC/mixin-config/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CaffeineMC%2Fmixin-config/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002016,"owners_count":26083258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-30T16:11:18.521Z","updated_at":"2025-10-09T20:06:43.052Z","avatar_url":"https://github.com/CaffeineMC.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CaffeineConfig\n\nCaffeineConfig is a mixin configuration manager that allows both the user and other mods to configure what mixins should\napply and which shouldn't in a simple manner, and without the mods having to depend on each other. It is used in \nthe [Sodium](https://github.com/CaffeineMC/sodium-fabric) and [Lithium](https://github.com/CaffeineMC/lithium-fabric) mods.\n\n## Usage\n\n### Adding CaffeineConfig as a dependency to your project\n\nTo use `CaffeineConfig` you'll first need to add the CaffeineMC maven to the repositories block of your `build.gradle` file, and then add\nCaffeineConfig as a dependency. You should include CaffeineConfig as Jar-in-Jar with your mod.\n\nAdding the CaffeineMC maven to your `build.gradle`:\n\n```groovy\nrepositories {\n    ...\n    // TODO this when I know the url\n}\n```\n\nAdding CaffeineConfig as a dependency and as a Jar-in-Jar in your mod:\n\n```groovy\ndependencies {\n    ...\n    modImplementation 'net.caffeinemc:CaffeineConfig:1.0.0'\n    include 'net.caffeinemc:CaffeineConfig:1.0.0'\n}\n```\n\nWhile not strictly necessary, you should also declare the dependency in your `fabric.mod.json`:\n\n```json\n{\n    ...\n    \"depends\": {\n        ...\n        \"caffeineconfig\": \"\u003e=1.0.0\"\n    }\n}\n```\n\n### Extending AbstractCaffeineConfigMixinPlugin\n\nIn order to use the core functionality, you'll need a class that extends `AbstractCaffeineConfigMixinPlugin`,\nwhere you'll need to implement the `createConfig()` and `mixinPackageRoot()` methods.\n\nThe mixin package root is the deepest common package between all mixins, ending with a dot. For example, if the mod has mixins \nin `org.example.mod.mixin.feature` and `org.example.mod.mixin.bugfixes`, the package root would be `org.example.mod.mixin.`.\n\nNote that while `createConfig()` will only be called once, the `mixinPackageRoot()` method will be called each time\nmixin asks the config plugin whether it should apply a mixin.\n\nAn example implementation of the `AbstractCaffeineConfigMixinPlugin` is the following:\n\n```java\npublic class ExampleModMixinConfigPlugin extends AbstractCaffeineConfigMixinPlugin {\n\n    @Override\n    protected CaffeineConfig createConfig() {\n        // see next section\n    }\n    \n    @Override\n    protected String mixinPackageRoot() {\n        return \"org.example.mod.mixin.\";\n    }\n}\n\n```\n\n### Creating a CaffeineConfig object\n\nIn order to create a `CaffeineConfig` object you'll first need to get a `Builder` by using the `CaffeineConfig.builder(modName)`\nmethod. By default, this will get a logger with the mod's name and `Config` appended to it and use it as its logger,\nand set the JSON key for other mods to disable settings as `lowercase(modName):options`. You can override those by calling the\n`withLogger(Logger)` and `withSettingsKey(String)` methods of the builder.\n\nYou can also provide a url to a resource with more information about your config file by calling the `withInfoUrl(String)` method.\n\nThen you have to add your various mixin options, using `addMixinOption(name, default)`. The options don't have to point directly to a\nmixin file, but can point to a package instead, and that will make disabling the rule disable all mixins in the package. You have to skip the\nmixin package root from before when defining options. You can provide multiple options for a package and subpackages if desired, where disabling the\ntop packet will disable all children.\n\nIf one of the options depends on another option to be enabled/disabled, you can define dependencies between options by calling\n`addOptionDependency(optionThatDepends, dependency, requiredValue)`. Doing that, if any of the dependencies of an option is not\nthe required value, the option will be disabled.\n\nOnce you're ready to build your `CaffeineConfig`, you'll need to pass the `Path` to the config file to create or read in the `build()` method. \nDoing that will already populate option overrides.\n\nAn example for creating a `CaffeineConfig` instance for use in a class extending `AbstractCaffeineConfigMixinPlugin` is the following:\n\n```java\n    @Override\n    protected CaffeineConfig createConfig() {\n        return CaffeineConfig.builder(\"ExampleMod\")\n                .addMixinOption(\"ai\", true) // ai can be disabled and it will disable all subpackages\n                .addMixinOption(\"ai.brain\", true)\n                .addMixinOption(\"ai.goal\", true)\n                .addMixinOption(\"block.hopper\", true)\n                .addOptionDependency(\"block.hopper\", \"ai\", true) // block.hopper will be disabled if ai is disabled\n                .withInfoUrl(\"https://example.org\")\n                .build(FabricLoader.getInstance().getConfigDir().resolve(\"examplemod.properties\"));\n    }\n\n```\n\n### Using your MixinConfigPlugin\n\nIn order for mixin to use your class that extends `AbstractCaffeineConfigMixinPlugin`, you'll need to reference it in your\nmixins json file by mapping a field named `plugin` to a string being the fully-qualified name of your class.\n\nAn example is the following:\n\n```json\n{\n  \"package\": \"org.example.mod.mixin\",\n  \"required\": true,\n  \"compatibilityLevel\": \"JAVA_16\",\n  \"plugin\": \"org.example.mod.mixin.ExampleModMixinConfigPlugin\",\n  \"injectors\": {\n    \"defaultRequire\": 1\n  },\n  \"mixins\": [\n    ...\n  ]\n}\n```\n\n### Notes\n\nAny mixin added to the config (the config being the mixins JSON file) must have a valid option related to it, else the mixin plugin\nwill throw an `IllegalStateException` when applying it. This is to ensure mixins are added to the config and to prevent hard to\ndebug problems where mixins silently don't apply because they weren't assigned to any option.\n\nIf you want to add mixins that are not configurable, you should add them to a different mixin config, that is, a different mixin json\nfile that is therefore another entry in your `fabric.mod.json`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaffeinemc%2Fmixin-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaffeinemc%2Fmixin-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaffeinemc%2Fmixin-config/lists"}