Jump to content

Phylogeny

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by Phylogeny

  1. An enum is what tells Forge to generate a cycling button config element. Do you have a constructive suggestions as to how to tell Forge to create one with formatted text (with or without an enum)? It helps to give input on what should be done, as well a what shouldn't.

  2. Here's a more stable way, that requires only the EnumHelper:

    static
    {
    	for (RarityGlowTypeNames value : RarityGlowTypeNames.values())
    	{
    		String name = "";
    		for (String word : value.name().split("_"))
    			name += word.substring(0, 1) + word.substring(1).toLowerCase() + " ";
    
    		EnumHelper.addEnum(RarityGlowType.class, name.substring(0, name.length() - 1), new Class<?>[0]);
    	}
    }
    
    // This is inside the root class for the config file
    public static class Inventory
    {
    	@Config.Name("Rarity Type")
    	public RarityGlowType rarityGlowType = RarityGlowType.values()[0];
    }
    
    public enum RarityGlowType {}
    
    public enum RarityGlowTypeNames
    {
    	SOLID_COLOR, GRADIENT_COLOR;
    }

     

    Or here's a variant of that without dynamic name generation:

    static
    {
    	for (RarityGlowTypeNames name : RarityGlowTypeNames.values())
    		EnumHelper.addEnum(RarityGlowType.class, name.toString(), new Class<?>[0]);
    }
    
    // This is inside the root class for the config file
    public static class Inventory
    {
    	@Config.Name("Rarity Type")
    	public RarityGlowType rarityGlowType = RarityGlowType.values()[0];
    }
    
    public enum RarityGlowType {}
    
    public enum RarityGlowTypeNames
    {
    	SOLID_COLOR("Solid Color"),
    	GRADIENT_COLOR("Gradient Color");
    
    	private String name;
    
    	private RarityGlowTypeNames(String name)
    	{
    		this.name = name;
    	}
    
    	@Override
    	public String toString()
    	{
    		return name;
    	}
    }

     

    An example of checking the value could be:

    ConfigMod.inventory.rarityGlowType.ordinal() == RarityGlowTypeNames.GRADIENT_COLOR.ordinal()

     

×
×
  • Create New...

Important Information

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