Skip to main content

ClassTweaker, Mixins & Known Quirks

Access Wideners, ClassTweakers & Access Transformers​

One of Cloche's biggest quality-of-life wins over traditional multi-loader setups is that you write one Fabric-format Access Widener / ClassTweaker file in common, and Cloche automatically:

  1. Applies it to Minecraft classes for compilation (via the AccessWiden task).
  2. Merges and packages it for Fabric targets (via MergeAccessWideners).
  3. Converts it into a NeoForge META-INF/accesstransformer.cfg (via GenerateAccessTransformer).
cloche {
common {
accessWideners.from(file("src/main/resources/mymod.ct"))
mixins.from(file("src/main/resources/mymod.mixins.json"))
}
}

You can also attach version-specific or loader-specific ClassTweakers and Mixin configs to any intermediate common("...") or leaf target.

Mod metadata: generated vs. static​

By default, Cloche generates fabric.mod.json and META-INF/neoforge.mods.toml from its cloche.metadata { ... } DSL block.

If you prefer maintaining your own src/fabric/resources/fabric.mod.json and src/neoforge/resources/META-INF/neoforge.mods.toml files (for example, to use custom Fabric custom entries, complex NeoForge dependency blocks, or custom placeholders), you must disable Cloche's metadata generator tasks (generate*ModJson and generate*ModsToml) — otherwise Gradle fails on duplicate resource files.

Graft disables these generators by default (staticMetadata = true) and wires ProcessResources expansion automatically.

Known Cloche 0.19.13 ClassTweaker quirks (and how Graft fixes them)​

While migrating real-world Minecraft 26.x mods (Emotecraft and PlayerAnimationLibrary) to Cloche 0.19.13, we ran into four subtle limitations in Cloche's underlying minecraft-codev-access-widener:0.6.3 library.

If you use raw Cloche, you need to work around these yourself. If you use Graft, all four are fixed automatically using Fabric's official net.fabricmc:class-tweaker library.

1. .classtweaker file extension is silently ignored​

minecraft-codev-access-widener hardcodes accepted extensions as setOf("accesswidener", "ct"). Passing a .classtweaker file (Fabric Loom's modern default extension) compiles without errors, silently skips widening, and leaves private Minecraft fields inaccessible.

  • Raw Cloche workaround: Rename the file to .ct or .accesswidener.
  • With Graft: Keep .classtweaker untouched. Graft transparently stages normalized .ct copies in build/graft/classtweaker/ for Cloche's tasks.

2. classTweaker v1 official header fails on unobfuscated MC 26.x​

Starting in Minecraft 26.1, Minecraft is shipped unobfuscated under the official namespace, so modern Fabric projects write:

classTweaker v1 official

However, Cloche's AccessWiden task still expects named on input files (even when named and official are identical on 26.x) and maps named → official during MergeAccessWideners.

  • Raw Cloche workaround: Use classTweaker v1 named in source files.
  • With Graft: Both official and named headers work seamlessly; Graft normalizes the staged copy for Cloche and preserves official in the final JAR.

3. inject-interface and transitive-inject-interface are ignored​

minecraft-codev-access-widener parses Access Widener lines only and skips Fabric ClassTweaker's inject-interface / transitive-inject-interface directives (as well as legacy custom."loom:injected_interfaces" metadata from dependency JARs). In addition, Cloche's MergeAccessWideners strips injected-interface directives when mapping namespaces.

  • Raw Cloche workaround: Cast every target class to your accessor interface manually (((MyAccessor) entity).getFoo()).
  • With Graft: Graft hooks Cloche's AccessWiden and MergeAccessWideners tasks using Fabric's official net.fabricmc:class-tweaker API (ClassTweaker.createClassVisitor), applying interface injection at compile time, picking up transitive loom:injected_interfaces from dependency JARs, and preserving all directives in the merged ClassTweaker output.

4. extendable class downgraded to ACC_PROTECTED​

When widening a package-private or final class with extendable class net/minecraft/..., minecraft-codev-access-widener can emit protected visibility on inner/nested classes instead of public, breaking cross-package subclassing.

  • With Graft: Fabric's ClassTweaker.createClassVisitor runs over the widened target classes and applies standard Fabric public / non-final widening rules, fixing extendable class automatically.

See ClassTweaker & Interface Injection for full details and opt-out options.