Jump to content

Adding buttons to main menu 1.16.5


TheKralGame

Recommended Posts

hello i want to add a button to main menu.

Screen myevent = event.getGui();
if (myevent instanceof MainMenuScreen){
	myevent.addButton(new Button(20, 20, 20, 20, new StringTextComponent("Text"), (e)->{

		System.out.println("Sa");
				
	}));
}

It says addButton is protected. I tried accesstransformers thing.

and i wrote this

protected net.minecraft.client.gui.screen.Screen addButton(Lnet/minecraft/client/gui/IGuiEventListener;)Lnet/minecraft/client/gui/IGuiEventListener;
protected net.minecraft.client.gui.screen.Screen addListener(Lnet/minecraft/client/gui/IGuiEventListener;)Lnet/minecraft/client/gui/IGuiEventListener;

 

but it is not working.

 

The code of addButton and addListener

protected <T extends Widget> T addButton(T button) {
    this.buttons.add(button);
	return this.addListener(button);
}

protected <T extends IGuiEventListener> T addListener(T listener) {
	this.children.add(listener);
    return listener;
}

 

Please help me

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.