简体   繁体   中英

How can i remove a title screen element with fabric in Minecraft 1.18.1

I am currently able to add elements to the title screen:

public abstract class MCEMixin extends Screen {

    protected MCEMixin(Text title) {
        super(title);
    }

    @Inject(at = @At("RETURN"), method = "initWidgetsNormal")
    private void addCustomButton(int y, int spacingY, CallbackInfo cI) {
        this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, y, 200, 20, Text.of("MCEssentials | Singleplayer"), (button) -> {
            MinecraftClient.getInstance().setScreen(new SelectWorldScreen(this));
        }));
    }
}

I want to replace the singleplayer button with mine tho and I can't figure out how.

Maybe you could use ci.cancel() (requires you to include CallbackInfo ci in your injected method) and copy/paste the fabric mc source to the function but just change the Singleplayer button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM