Skip to content

Instantly share code, notes, and snippets.

@Haven-King
Created October 5, 2020 03:22
Show Gist options
  • Save Haven-King/0452f59a9fe70cb46f33ffd48aa61eba to your computer and use it in GitHub Desktop.
Save Haven-King/0452f59a9fe70cb46f33ffd48aa61eba to your computer and use it in GitHub Desktop.
@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