Configuration

Configuration

2M Downloads

Gui config

MrStickyPiston opened this issue · 15 comments

commented

What gui is the gui config setting used for?

commented

Minecraft ingame GUI as this is minecraft library

commented

The Gui itself (if you are reffering to the subclass within Configurable interface) is used only as grouping of GUI specific subinterfaces for improved readability.
For example there is @NumberFormat annotation which is used to specify DecimalFormat of numbers which will be displayed on gui, or @ColorValue which adds color picker to your string config field and so on.

commented

For example there is @numberformat annotation which is used to specify DecimalFormat of numbers which will be displayed on gui

But what gui is that used in?

commented

But i dont see an option to show a gui to configurate

commented

The GUI is generated automatically and the fields with @Configurable annotation are displayed. The GUI subclasses only edit specific attributes of the generated GUI elements, you cannot configure entire GUI.
The GUI can be accessed within the Mods directory on Forge, or by using ModMenu mod on Fabric.

Or maybe you could specify in detail what you exactly want to do

commented

With modmenu: Screenshot_20240129_192600_PojavLauncher (Minecraft Java Edition for Android).jpg

Cant choose config

commented

yes, the GUI does not work in development environment in the Fabric version

commented

The screenshot was not from the development environment but in a normal client environment.

commented

This is my config, am i doing something wrong?

import dev.toma.configuration.config.Config;
import dev.toma.configuration.config.Configurable;

@Config(id = BuildersJetpack.MOD_ID)
public class ModConfig {

    public enum fuelHudType {
        NONE,
        BAR,
        PERCENTAGE,
        NUMBER
    }

    // Client
    @Configurable
    @Configurable.Comment("The particle that will be displayed under the player while flying")
    public String PARTICLE = "minecraft:cloud";

    @Configurable
    @Configurable.Comment("The sound that will be played when the player uses the jetpack fuel item")
    public String FUEL_ITEM_SUCCESS = "minecraft:item.bucket.fill_lava";

    @Configurable
    @Configurable.Comment("Hide the fuel hud if chat is open to avoid overlapping")
    public boolean FUEL_HUD_CHAT_FIX = true;

    @Configurable
    @Configurable.Comment("X location of the fuel hud")
    public float FUEL_HUD_X = 10;

    @Configurable
    @Configurable.Comment("Y location of the fuel hud")
    public float FUEL_HUD_Y = 10;

    @Configurable
    @Configurable.Comment("How the amount of fuel will be displayed. (NONE, BAR, PERCENTAGE, NUMBER)")
    public fuelHudType FUEL_HUD_TYPE = fuelHudType.BAR;

    @Configurable
    @Configurable.Comment("Fuel icon used for the fuel bar")
    public String FUEL_BAR_ICON = "▊";

    @Configurable
    @Configurable.Comment("Color code for the remaining fuel in the fuel bar")
    public String FUEL_BAR_REMAINING_COLOR = "§f";

    @Configurable
    @Configurable.Comment("Color code for the used fuel in the fuel bar")
    public String FUEL_BAR_USED_COLOR = "§8";

    // Server
    @Configurable
    @Configurable.Comment("The maximum amount of fuel a jetpack can have")
    @Configurable.Range(min=0)
    public int MAX_FUEL = 1000;

    @Configurable
    @Configurable.Comment("The base fuel cost per tick while flying")
    @Configurable.DecimalRange(min=0)
    @Configurable.Gui.NumberFormat("0.000#")
    public float FLY_BASE_FUEL_COST = 0.002F;

    @Configurable
    @Configurable.Comment("The cost per speed of flying with formula SPEED/COST")
    @Configurable.DecimalRange(min=0.00001)
    @Configurable.Gui.NumberFormat("0.000#")
    public float FLY_MOVEMENT_FUEL_COST = 40F;

    @Configurable
    @Configurable.Comment("Show warnings in chat when fuel reaches a certain amount")
    public boolean FUEL_WARNING = true;

    @Configurable
    @Configurable.Comment("The milestones a warning is sent if fuel warning is true")
    @Configurable.Range(min=0)
    public int[] FUEL_WARNINGS = {100, 50, 25, 10, 5, 4, 3, 2, 1};

    @Configurable
    @Configurable.Comment("The amount of fuel the fuel item adds to the jetpack")
    @Configurable.Range(min=0)
    public int FUEL_ITEM_AMOUNT = 100;

    @Configurable
    @Configurable.Comment("The amount of speed the fuel cost will be capped")
    @Configurable.DecimalRange(min=0)
    public float FUEL_SPEED_CAP = 1.4F;
}
commented

I have not touched fabric in a long time, but I believe there was some issue with the config gui display within development environment.
If the config file is created normally (i.e. exists in the config directory) then everything should be okay on your side. If not, then it means that you have not registered your config.

commented

The config file generates and values edited appear in game, so its just the gui thats broken?

commented

Weird, this should not be needed as it should be automatically integrated using the ModMenu API - implemented here

I'll look into it more

commented

Ty!

commented

I got it working using

public class ModMenuApiImpl implements ModMenuApi {
    @Override
    public ConfigScreenFactory<?> getModConfigScreenFactory() {

        return parent -> Configuration.getConfigScreenByGroup(BuildersJetpack.MOD_ID, parent);
    }
}

May be worth to notice this in the setup guide.

commented

This issue should not appear again in 1.21+ mc versions (where I have confirmed it's functionality via testmod), but I have not been able to simulate it in older versions