Created
October 5, 2020 03:22
-
-
Save Haven-King/0452f59a9fe70cb46f33ffd48aa61eba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Mixin(ControlsOptionsScreen.class) | |
public class ControlOptionsScreenMixin { | |
@Redirect( | |
/* This is the method we're injecting into. We want to use the full method descriptor | |
so we don't get confused with <init>. */ | |
method = "init()V", | |
at = @At( | |
// We're redirecting the INVOKE opcode to call our method instead of `addButton`. | |
value = "INVOKE", | |
// Method descriptor for `addButton` | |
target = "Lnet/minecraft/client/gui/screen/Screen;addButton(Lnet/minecraft/client/gui/widget/AbstractButtonWidget;)Lnet/minecraft/client/gui/widget/AbstractButtonWidget;", | |
// We want to redirect the second call to `addButton`, so we use the ordinal 1. | |
ordinal = 1 | |
) | |
) | |
private <T extends AbstractButtonWidget> T dontAddJumpButton(Screen screen, T button) { | |
/* We need to return a button to match the original method signature, but it won't actually be | |
added to the screen. */ | |
return button; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment