Skip to content

Add checks for missing @At opcode on fields targeted with @WrapOperation #2530

@PaintNinja

Description

@PaintNinja

Minecraft Development for IntelliJ plugin version

2025.2-1.8.6

Description of the feature request

When targeting the field get of this.splash in TitleScreen without including the opcode...

@Override
protected void init() {
    if (this.splash == null) {
        this.splash = this.minecraft.getSplashManager().getSplash();
    }
@Mixin(TitleScreen.class)
public abstract class MixinExampleMod {
    @Shadow
    @Final
    private static Logger LOGGER;

    @WrapOperation(
            method = "init",
            at = @At(
                    value = "FIELD",
                    target = "Lnet/minecraft/client/gui/screens/TitleScreen;splash:Lnet/minecraft/client/gui/components/SplashRenderer;"
            )
    )
    private static SplashRenderer wrapSplashField(TitleScreen instance, Operation<SplashRenderer> original) {
        LOGGER.info("HELLO FROM MIXINEXTRAS");
        return original.call(instance);
    }
}

...MixinExtras 0.5.0 gives misleading errors suggesting to change the method signature to void:

Caused by: org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException: @WrapOperation operation wrapper method net/minecraft/client/gui/screens/TitleScreen::wrapSplashField from examplemod.mixins.json:MixinExampleMod has an invalid signature. Found unexpected return type net.minecraft.client.gui.components.SplashRenderer, expected void. Handler signature: (Lnet/minecraft/client/gui/screens/TitleScreen;Lcom/llamalad7/mixinextras/injector/wrapoperation/Operation;)Lnet/minecraft/client/gui/components/SplashRenderer; Expected signature: (Lnet/minecraft/client/gui/screens/TitleScreen;Lnet/minecraft/client/gui/components/SplashRenderer;Lcom/llamalad7/mixinextras/injector/wrapoperation/Operation;)V
    at SECURE-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.injection.code.Injector.validateParams(Injector.java:623)

Changing it to void gives an error that suggests changing it back to SplashRenderer.

Turns out MixinExtras requires the opcode in this case, otherwise it attempts to target both the get and set simultaneously and fails on one or the other.

I would like to request that the MCDev plugin detects this case and shows a warning in the IDE suggesting to add opcode = Opcodes.GETFIELD to the @At.

Additional context: https://discord.com/channels/1129059589325852724/1129095235889270844/1431612653847056446

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions