shedaniel / AutoConfig

Fork of Auto Config.
Apache License 2.0
28 stars 13 forks source link

Crash when trying to read config #17

Closed Mantarri closed 4 years ago

Mantarri commented 4 years ago

When I try to read my config with ModConfig config = AutoConfig.getConfigHolder(ModConfig.class).getConfig();

I get a crash when trying to start Minecraft log

I do register the config in my mod's onInitialize method.

AutoConfig.register(ModConfig.class, Toml4jConfigSerializer::new);

shedaniel commented 4 years ago

You are using getConfigHolder before register

Mantarri commented 4 years ago

What could cause that though? I try to read the config in a Mixin to theregister method inItems, and I register the config in my Mod's onInitialize, so the config should be registered before that Mixin is even loaded, if I understand how this works correctly.

shedaniel commented 4 years ago

Items register is done before mod init

Mantarri commented 4 years ago

Ah, that explains it. Is there some way to open the config at that point then? If I'm correct, I could just register it there, but I assume that doing it there isn't the best idea.

shedaniel commented 4 years ago

you could unify the get config method with register, with a boolean flag to know if it has been registered, if not, register it before getting the config object