promotional bannermobile promotional banner

MCFA

A simple library mod that allows other mods to easily do low level bytecode modifications.

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);
}
)
)
);
}
}

The MCFA Team

profile avatar
Owner
  • 8
    Followers
  • 33
    Projects
  • 2.5M
    Downloads

More from gudenauView all

  • Paradise Lost project image

    Paradise Lost

    • 7.8M
    • Mods

    The hostile paradise of yore, bask in a new light, bleeding with new tales to be told.

    • 7.8M
    • April 25, 2026
    • Mods
    • +4
  • WootingCraft project image

    WootingCraft

    • 1
    • Mods

    Adds analog keyboard support to Minecraft

    • 1
    • November 23, 2024
    • Mods
  • Multihead project image

    Multihead

    • 72
    • Mods

    Minecraft on three monitors!

    • 72
    • August 31, 2023
    • Mods
  • gudArrows project image

    gudArrows

    • 647
    • Mods

    Adds a few more arrows to Minecraft

    • 647
    • June 20, 2023
    • Mods
  • Paradise Lost project image

    Paradise Lost

    • 7.8M
    • Mods

    The hostile paradise of yore, bask in a new light, bleeding with new tales to be told.

    • 7.8M
    • April 25, 2026
    • Mods
    • +4
  • WootingCraft project image

    WootingCraft

    • 1
    • Mods

    Adds analog keyboard support to Minecraft

    • 1
    • November 23, 2024
    • Mods
  • Multihead project image

    Multihead

    • 72
    • Mods

    Minecraft on three monitors!

    • 72
    • August 31, 2023
    • Mods
  • gudArrows project image

    gudArrows

    • 647
    • Mods

    Adds a few more arrows to Minecraft

    • 647
    • June 20, 2023
    • Mods