Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[Solved] [1.17.1] Add Config GUI


OutCraft
 Share

Recommended Posts

Hi!

I want to add my own buttons to the "Options" side of Minecraft "ESCAPE>Options" but I don't know how to do this

Thanks for any help :D

Edited by OutCraft

Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can :D

Also: PLEASE use SPOILERS for logs!

Link to comment
Share on other sites

You should strongly consider using the ConfigGuiHandler.ConfigGuiFactory extension point (ModLoadingContext.get().registerExtensionPoint in FMLCommonSetupEvent). Then you will use the already present Config button on the mods screen. If every mod adds to the Options screen, it will become unusual. No, you are not a special bunny.

Link to comment
Share on other sites

Hi,

thank you for the quick reply!

I didn't know, that you really can use these Buttons, I exactly wanted to do something like this!

Again learned something new :)

Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can :D

Also: PLEASE use SPOILERS for logs!

Link to comment
Share on other sites

Hi again!

I have another question:

I searched online how to do this, because I didn't get it to work and I saw this:

ModLoadingContext.get().registerExtensionPoint(
                ExtensionPoint.CONFIGGUIFACTORY,
                () -> (mc, screen) -> new ConfigScreen()
        );

My problem is, that I can't find the class ExtensionPoint, but on the website it says it's there:

import net.minecraftforge.fml.ExtensionPoint;

The only thing what I found was IExtensionPoint in

net.minecraftforge.fml.IExtensionPoint;

but it only has DisplayTest and also, IExtensionPoint.DisplayTest gives an Error there:

ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest (<- Error: "IExtensionPoint.DisplayTest cannot be resolved to a variable"), extension);

Thank you for any help!

 

Ps: I like bunnies xD

On 11/19/2021 at 9:23 PM, diesieben07 said:

No, you are not a special bunny.

Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can :D

Also: PLEASE use SPOILERS for logs!

Link to comment
Share on other sites

  • OutCraft changed the title to [1.17.1] Add buttons to Screen

The first parameter needs to be a Class that extends IExtensionPoint. This specifies which extension point you want to register. In your case this is ConfigGuiHandler.ConfigGuiFactory.

The 2nd parameter is a supplier that creates a instance of this class that specifies your desired behavior. In the case of ConfigGuiHandler.ConfigGuiFactory you need to give it a factory function for your screen.

Link to comment
Share on other sites

Now I did this:

public class MyClientConfigGuiScreen extends Screen {

	public MyClientConfigGuiScreen() {
		super(new TextComponent("My Mod Config"));
	}

}

and

ModLoadingContext.get().registerExtensionPoint(() -> ConfigGuiHandler.ConfigGuiFactory,
				MyClientConfigGuiScreen::new (<- Error: "The constructed object of type MyClientConfigGuiScreen is incompatible with the descriptor's return type: T"));

but there is an error at MyClientConfigGuiScreen: "The constructed object of type MyClientConfigGuiScreen is incompatible with the descriptor's return type: T"

Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can :D

Also: PLEASE use SPOILERS for logs!

Link to comment
Share on other sites

Hi! I know Java, but I didn't know what parameters to pass in. I eventually found that out by my own (by looking at ConfigGuiHandler.ConfigGuiFactory) and thanks of your replies (I read them again), but it's very buggy and when I click on "Mods" on the title screen the game crashes

Edited by OutCraft
Forgot something

Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can :D

Also: PLEASE use SPOILERS for logs!

Link to comment
Share on other sites

  • 3 weeks later...

I solved it:

ModLoadingContext.get().registerExtensionPoint(ConfigGuiHandler.ConfigGuiFactory.class,
		() -> new ConfigGuiHandler.ConfigGuiFactory(new BiFunction<Minecraft, Screen, Screen>() {
			@Override
			public Screen apply(Minecraft mc, Screen screen) {
				return new MyConfigGuiScreen();
			}
		}));

(Sorry for all that needed this, I forgot to post the answer)

Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can :D

Also: PLEASE use SPOILERS for logs!

Link to comment
Share on other sites

  • OutCraft changed the title to [Solved] [1.17.1] Add Config GUI

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.