Wiki 9Minecraft Wiki 9Minecraft

Set Up Class Transformers for Your Mod

Java EditionModGuides 4FAQ 10Related mods 60
DownloadPreloading Tricks Mod

Get the files on 9Minecraft

Contents (3)
  1. Create the Transformer Configuration File
  2. Register in Your Mod Manifest
  3. Implement Your Transformer

Create the Transformer Configuration File

Class transformers allow you to modify bytecode of classes before they load into the JVM. Start by creating a JSON configuration file in your mod's resources directory (e.g., xxxx.classtransform.json).

Structure your file with a package field pointing to your transformer classes and a transformers array listing each transformer class name:

`json

{"package": "your.package.name.transformer","transformers": ["YourTransformerClass"]}

`

Register in Your Mod Manifest

Add the ClassTransformConfig attribute to your mod's manifest file, pointing to your JSON configuration:

`

ClassTransformConfig: xxxx.classtransform.json

`

Replace xxxx.classtransform.json with your actual file path.

Implement Your Transformer

Create transformer classes in the package you specified. These classes receive class bytecode during the early loading phase, before the mod loader fully initializes. You can now inspect and modify class behavior at the bytecode level—much earlier than standard mixin transformations allow.

More guides for this mod