Jump to content

Recommended Posts

Posted (edited)

I'm trying to figure out how to create a multi-line define list in the TOML config file using ForgeConfigSpec. Anyone have any insights?

 

Here's the code:

 

public class AttributesConfig {
    
    final ForgeConfigSpec.ConfigValue<List<? extends String>> attributes;
    
    AttributesConfig(final ForgeConfigSpec.Builder builder) {
        
        builder.push("Attributes");
        builder.comment("Add attribute modifiers to entities to change their stats. Takes 4-6 values seperated by a semicolon.",
                "Format:        entity;attribute;operator;value;dimension;child",
                "entity:        entity name",
                "attribute:     attribute name (Possible attributes: " + AttributeHelper.getAttributesString() + ")",
                "operator:      operator type (0 = add, 1 = multiply and add)",
                "value:         value which will be used for the calculation",
                "dimension:     dimension (ID) in which the entity should get the boost (optional! Leave this blank or use a \"/\" for any dimension)",
                "child:         0 = the modifier doesn't care if the entity is a child or not, 1 = adults only, 2 = children only (optional! Leave this blank for 0)");
        attributes = builder
                .defineList("Attributes", Arrays.asList(Constants.ATTRIBUTE_DEFAULT), ELEMENT_VALIDATOR);
        builder.pop();
    }
}

 

Here's the current output (all one line):

 

"Attributes" = ["zombie;generic.maxHealth;1;0.5;/;1", "zombie_pigman;generic.maxHealth;1;0.5;/;1", "zombie_villager;generic.maxHealth;1;0.5;/;1", ...etc.]

 

Here's what I'm trying to achieve:

"Attributes" = "zombie;generic.maxHealth;1;0.5;/;1",
               "zombie_pigman;generic.maxHealth;1;0.5;/;1",
               "zombie_villager;generic.maxHealth;1;0.5;/;1"
               etc...

 

Thanks!
 

Edited by p1ut0nium
  • 3 months later...
Posted (edited)

defineList takes an array.  ForgeConfig handles the reading and writing of the config file. So guessing any application of a line separator would be on the ForgeConfig side. I'm just wondering if there are any flags or such [documented or undocumented] to have the config file print out the array as a list rather than one long run on paragraph. The option probably does not exist but it never hurts to ask.
 

5 hours ago, Beethoven92 said:

Don't you just need a


System.lineSeparator()

here? Or a "%n" inside the string where you want to go to a new line. Example: ("FirstString" + System.lineSeparator() + "NewLineString") or ("FirstString%nNewLineString)

 

Edited by frakier
there, their and they're... I used their for there

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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