Skip to content

Commit

Permalink
Fix config on forge
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-dencep committed Jan 16, 2024
1 parent 26366d8 commit f5018e9
Showing 1 changed file with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
/*
* Copyright 2023 dima_dencep.
*
* Licensed under the Open Software License, Version 3.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
* https://github.com/dima-dencep/rrls/blob/HEAD/LICENSE
*/

package com.github.dimadencep.mods.rrls.neoforge;

import com.github.dimadencep.mods.rrls.Rrls;
import com.github.dimadencep.mods.rrls.config.AprilFool;
import com.github.dimadencep.mods.rrls.config.HideType;
import com.github.dimadencep.mods.rrls.config.ShowIn;
import com.github.dimadencep.mods.rrls.config.Type;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModList;
import net.neoforged.fml.config.ConfigFileTypeHandler;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.loading.FMLPaths;
import net.neoforged.neoforge.common.ModConfigSpec;
import org.apache.commons.lang3.tuple.Pair;

Expand Down Expand Up @@ -78,16 +91,13 @@ public ConfigExpectPlatformImpl(ModConfigSpec.Builder builder) {
.defineEnum("aprilFool", AprilFool.ON_APRIL);
}

static {
ModList.get().getModContainerById(Rrls.MOD_ID)
.ifPresent(
activeContainer -> activeContainer.addConfig(new ModConfig(
ModConfig.Type.CLIENT,
ConfigExpectPlatformImpl.CONFIG_SPEC_PAIR.getValue(),
activeContainer,
"rrls.toml")
)
);
static { // Early loading for config
ModContainer activeContainer = ModList.get().getModContainerById(Rrls.MOD_ID).orElseThrow();

ModConfig modConfig = new ModConfig(ModConfig.Type.CLIENT, ConfigExpectPlatformImpl.CONFIG_SPEC_PAIR.getValue(), activeContainer, "rrls.toml");
modConfig.getSpec().acceptConfig(ConfigFileTypeHandler.TOML.reader(FMLPaths.CONFIGDIR.get()).apply(modConfig));

activeContainer.addConfig(modConfig);
}

public static HideType hideType() {
Expand Down

0 comments on commit f5018e9

Please sign in to comment.