Mineuniverse
Mods
MCFA

MCFA

MOD
A simple library mod that allows other mods to easily do low level bytecode modifications.
by gudenau
Download Claim this project
66 downloads
0 likes
Updated Oct 14, 2026
0 hypes
API and Library
Advertisement Remove ads with Premium →

A small library mod that allows other mods to use the Java 24 ClassFile API to directly edit the code of classes as they are loaded.

 

A simple example implementation could be:

public class Example implements McfaInitializer {
@Override
public void initializeTransformers(@NotNull Mcfa registry) {
registry.registerTransformer(
"net.minecraft.class_310",
ClassTransform.transformingMethods(
MethodTransform.transformingCode(
(builder, element) -> {
var result = switch(element) {
case ConstantInstruction instruction -> switch(instruction.typeKind()) {
case REFERENCE -> {
var value = instruction.constantValue();
if(value.equals("Setting user: {}")) {
builder.ldc("This got changed via the ClassFile API :-) {}");
yield true;
}

yield false;
}

default -> false;
};

default -> false;
};
if(result) {
return;
}

builder.with(element);
}
)
)
);
}
}
gud_mcfa-1.0.0.jar
MC 1.21.2-Snapshot, 1.21, 1.21.5, Fabric, Client, 1.21.1-Snapshot, 1.21.4, 1.21.5-Snapshot, 1.21-Snapshot, 1.21.3, 1.21.1, Server, 1.21.4-Snapshot, 1.21.2
Release 2025-03-30 Get

More from gudenau

Advertisement Remove ads with Premium →

You Might Also Like