Back to 9Minecraft
Wiki 9Minecraft Wiki 9Minecraft
Preloading Tricks Wiki › Guides › Modify Another Mod's Classes at Load Time

Modify Another Mod's Classes at Load Time

Identify the Target Class

Determine which class from another mod you need to transform. You'll need its fully qualified class name (e.g., com.example.othermod.SomeClass).

Create a Custom Transformer

Write a transformer class that receives the bytecode of your target class. Using Java Instrumentation tools, inspect and modify the class bytecode before it's loaded into memory. This happens at the JVM level, far earlier than mixins.

Configure and Register

Add your transformer to your classtransform.json configuration file under the transformers array. Ensure the package field points to where your transformer class is located.

Update your mod manifest with the ClassTransformConfig attribute.

Test the Transformation

Launch the game and verify that your bytecode modifications are applied. Since transformations happen during class loading, the modified behavior will be active from the moment that class is first used—before the target mod's initialization code even runs.