Getting started
Learn the structure of YACL to understand how it works.
This wiki is currently a work-in-progress and is incomplete!
Before we begin, it's important to note the wiki code examples will be using official Mojang mappings. You are also expected to have a basic knowledge of the Java programming language. If you don't, please learn Java first.
There is a simple structure: categories contains groups, groups contain options. You can also skip the groups and just add options to the category directly. They will always appear above any groups.
Before we start, lets go into detail about how to construct an Option
, then we'll use that to make a GUI.
An important concept in YACL options are the controllers. Each option type does not have a hardcoded way of being displayed. The logic of displaying the option in the GUI is held in the Controller
. To learn more about controllers, click here. You will see in the above example, we're choosing to use a tick-box to display and control the boolean option.
To start making a GUI with YACL, you will need to build an instance of YetAnotherConfigLib
. We will plug in our Option
code from above...
All you have to do then is tell YACL to generate a Screen instance from it.
You must generate a new instance of YetAnotherConfigLib
every time you want a GUI Screen
. You cannot just call generateScreen()
again!
It's that simple! You have made your first GUI with YACL!
Displaying the GUI
Now you've learned the basics of creating a config GUI, but how do you show it to the user?
Mod Menu (Fabric)
Mod Menu is an extremely popular mod for Fabric that adds a menu that displays a list of currently installed mods, like Forge. You can use its API to add a config button to your mod's entry that opens up your newly created YACL config screen.
Adding the dependency
First, add the repository to your build.gradle.
Then, add the dependency
Then, define the version of Mod Menu you're using in your gradle.properties
. You can get the latest version number here, but you may need a different version if you're not using the latest Minecraft version. See the versions page for a full list of versions.
Using the API
First, create the modmenu entrypoint by creating a new class in your mod.
If you want multiple methods to opening your configuration screen, extracting the config creation to a common method call is useful.
Registering the entrypoint
Now that you've created the entrypoint, we need to tell mod menu to use it.
And you're done! You can now test it out by going to the mod list, finding your mod, and pressing the configuration button to open your YACL GUI.
NeoForge Mod List
NeoForge has a mod list built-in, and allows you to register extension points to extend the functionality of your mod's entry, notably, a config button.
Add the following to your mod's constructor.
If you want multiple methods to opening your configuration screen, extracting the config creation to a common method call is useful.
That's it! You can now find your mod in the mod list and open your YACL configuration screen!
Last updated
Was this helpful?