Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModifyArg index is broken by instance Redirects #544

Closed
LlamaLad7 opened this issue Dec 11, 2021 · 0 comments · Fixed by aaaapai/Mixin#1 or FabricMC/Mixin#128
Closed

ModifyArg index is broken by instance Redirects #544

LlamaLad7 opened this issue Dec 11, 2021 · 0 comments · Fixed by aaaapai/Mixin#1 or FabricMC/Mixin#128

Comments

@LlamaLad7
Copy link
Contributor

LlamaLad7 commented Dec 11, 2021

Given the following example case:

@Redirect(method = "updateWindowTitle", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;setTitle(Ljava/lang/String;)V"))
private void modifyTitle(Window instance, String title) {
    instance.setTitle(title);
}

@ModifyArg(method = "updateWindowTitle", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;setTitle(Ljava/lang/String;)V"), index = 0)
private String modifyTitle(String title) {
    return title;
}

I am greeted with the following error:

Specified index 0 for @ModifyArg is invalid for args (Lnet/minecraft/client/util/Window;Ljava/lang/String;), expected Ljava/lang/String;

Originally the target method has only a single argument of type String, however when the Redirect is injected at the desired instruction, there is now an instance parameter as well.
It seems that index does not take into account the instance parameter in the redirector which replaced the original instruction, and as such tries to target the wrong thing.
It works fine when they apply the other way round, as there is only one parameter for the ModifyArg to look at at that point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment