Jump to content

Server Config not being created in IDE (1.19.2)


The Typholorian

Recommended Posts

so I'm tryna make a server config for my mod. I have it renamed and all, but it only generates when I export the mod and run it. Here's my config code:

ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ServerConfig.SPEC, "pnegative-server-config.toml");

in the main mod file, 

import net.minecraftforge.common.ForgeConfigSpec;

class ServerConfig {
    public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
    public static final ForgeConfigSpec SPEC;

    static {
        BUILDER.push("Project Negative Config");

        BUILDER.pop();
        SPEC = BUILDER.build();
    }
}

in config file. I am looking for the config file in run/saves/worldname/serverconfig. Only seeing forge-server.toml. Help? It doesn't crash, just doesn't work as it's supposed to. 

Link to comment
Share on other sites

This is the message I get in the logs/debug.log when I run that code:

Quote

[18Aug2023 20:09:31.662] [modloading-worker-0/DEBUG] [net.minecraftforge.fml.ModLoadingContext/]: Attempted to register an empty config for type SERVER on mod examplemod using file name pnegative-server-config.toml

It's ignoring you, because you have no config.

https://github.com/MinecraftForge/MinecraftForge/blob/ab70bde1d648125acee073a93a25d4b8f08985c9/fmlcore/src/main/java/net/minecraftforge/fml/ModLoadingContext.java#L53

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Add some actual configuration options to your config.

https://forge.gemwire.uk/wiki/Configs

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Yeah. I added

    public static final ForgeConfigSpec.ConfigValue<Boolean> ENABLE_BUILDING_TOOLS_MODULE;

and

        ENABLE_BUILDING_TOOLS_MODULE = BUILDER.define("Building Tools Module", true);

into the config file, and using 

ENABLE_BUILDING_TOOLS_MODULE.get()

to get the variable. Working when I remove that part, but it doesn't do what I want with the variable. 

Link to comment
Share on other sites

If you contine to post code snippets out of context, I will just ignore you.

Post a working example that reproduces your problem on github.

NOTE: You won't be able to use get() on a server config until a save is loaded. Those configs are world specific.

Even normal configs are not accessible until FMLClient/CommonSetup: https://forge.gemwire.uk/wiki/Stages_of_Modloading

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

I am using it like this: 

if (ENABLE_BUILDING_TOOLS_MODULE.get()) {
    net.the_typholorian.pnegative.building_tools.Items.register(modEventBus);
}

inside my main mod class file. I want it to register the items if the config enables them. I tried with passing true/false, and it worked as I wanted it to. 

I can't figure out how to add folders to a github, is a .zip okay?

Link to comment
Share on other sites

You can't use any of forge's config system during mod construction. Read the lnks I posted above.

If you want that you will need to write your own config system.

 

But conditionally registering blocks and items is a very bad idea,

Not least because there is no way to synchronize such configuration between client and server.

The client will have already decided whether to create blocks/items long before it connects to the server.

The client could also switch to another server running the same mod but with different config, i.e. different blocks and items.

Such things are not supportable by minecraft.

 

Instead you should unconditionally register all blocks and items and then use other mechanisms to decide what is accessible. e.g. conditionally registering recipes.

https://docs.minecraftforge.net/en/latest/resources/server/conditional/

 

Use search in this forum for many other discussions on this topic.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Well, it seems like Apotheosis does something similar, conditionally registering blocks/items if a config value is true. The problem I am having is that the server config is not being generated while in the IDE. If I export the mod and generate a world, it shows up fine. Is there maybe some setting or some code I am missing to make it generate in the IDE, so I don't have to export for testing?

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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