-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59402a8
commit 3eadb37
Showing
5 changed files
with
95 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package net.zepalesque.redux; | ||
|
||
import com.mojang.logging.LogUtils; | ||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.data.DataGenerator; | ||
import net.minecraft.data.PackOutput; | ||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.fml.ModLoadingContext; | ||
import net.neoforged.fml.common.Mod; | ||
import net.neoforged.fml.config.ModConfig; | ||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; | ||
import net.neoforged.neoforge.common.data.ExistingFileHelper; | ||
import net.neoforged.neoforge.data.event.GatherDataEvent; | ||
import net.zepalesque.redux.config.ReduxConfig; | ||
import net.zepalesque.zenith.api.condition.ConfigCondition; | ||
import net.zepalesque.zenith.api.condition.config.ConfigSerializer; | ||
import org.slf4j.Logger; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
@Mod(Redux.MODID) | ||
public class Redux { | ||
public static final String MODID = "aether_redux"; | ||
private static final Logger LOGGER = LogUtils.getLogger(); | ||
|
||
public Redux(IEventBus bus) { | ||
bus.addListener(this::commonSetup); | ||
bus.addListener(this::dataSetup); | ||
|
||
|
||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ReduxConfig.COMMON_SPEC, MODID + "/common.toml"); | ||
ConfigCondition.registerSerializer("redux_common", new ConfigSerializer(ReduxConfig.Common::serialize, ReduxConfig.Common::deserialize)); | ||
} | ||
|
||
private void commonSetup(final FMLCommonSetupEvent event) { | ||
|
||
} | ||
|
||
private void dataSetup(GatherDataEvent event) { | ||
DataGenerator generator = event.getGenerator(); | ||
ExistingFileHelper fileHelper = event.getExistingFileHelper(); | ||
CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider(); | ||
PackOutput packOutput = generator.getPackOutput(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/net/zepalesque/redux/config/ReduxConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package net.zepalesque.redux.config; | ||
|
||
import com.google.gson.JsonSyntaxException; | ||
import net.neoforged.neoforge.common.ModConfigSpec; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class ReduxConfig { | ||
|
||
public static class Common { | ||
|
||
public final ModConfigSpec.ConfigValue<Boolean> placeholder; | ||
|
||
public Common(ModConfigSpec.Builder builder) { | ||
builder.push("TODO"); | ||
placeholder = builder | ||
.comment("Temporary placeholder config, used") | ||
.define("Placeholder Config", true); | ||
builder.pop(); | ||
} | ||
|
||
public static String serialize(ModConfigSpec.ConfigValue<Boolean> config) { | ||
try { | ||
return config.getPath().toString(); | ||
} catch (NullPointerException e) { | ||
throw new JsonSyntaxException("Error loading config entry from JSON! Maybe the config key is incorrect?"); | ||
} | ||
} | ||
|
||
public static ModConfigSpec.ConfigValue<Boolean> deserialize(String string) { | ||
List<String> path = Arrays.asList(string.replace("[", "").replace("]", "").split(", ")); | ||
ModConfigSpec.ConfigValue<Boolean> config = COMMON_SPEC.getValues().get(path); | ||
|
||
return config; | ||
} | ||
} | ||
|
||
public static final ModConfigSpec COMMON_SPEC; | ||
public static final Common COMMON; | ||
|
||
static { | ||
final Pair<Common, ModConfigSpec> commonSpecPair = new ModConfigSpec.Builder().configure(Common::new); | ||
COMMON_SPEC = commonSpecPair.getRight(); | ||
COMMON = commonSpecPair.getLeft(); | ||
} | ||
|
||
} |