diff options
author | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-04-24 13:32:23 +0100 |
---|---|---|
committer | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-04-24 13:32:23 +0100 |
commit | 5417c7bd2d43c306863707bb91e7c88a651a696b (patch) | |
tree | 102088a05cf8dd9d772ceb619fa521ee952e68c0 /src/main/java/io/polyfrost/oneconfig/OneConfig.java | |
parent | a11a04cc1161a4ed55b85fa9bec877094f1e8e9d (diff) | |
download | OneConfig-5417c7bd2d43c306863707bb91e7c88a651a696b.tar.gz OneConfig-5417c7bd2d43c306863707bb91e7c88a651a696b.tar.bz2 OneConfig-5417c7bd2d43c306863707bb91e7c88a651a696b.zip |
mod cards, loading of mods, fixes, and some more stuff
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/OneConfig.java')
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/OneConfig.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/OneConfig.java b/src/main/java/io/polyfrost/oneconfig/OneConfig.java index 5d20af3..0f8fed9 100644 --- a/src/main/java/io/polyfrost/oneconfig/OneConfig.java +++ b/src/main/java/io/polyfrost/oneconfig/OneConfig.java @@ -2,16 +2,26 @@ package io.polyfrost.oneconfig; import io.polyfrost.oneconfig.command.OneConfigCommand; import io.polyfrost.oneconfig.config.OneConfigConfig; +import io.polyfrost.oneconfig.config.core.ConfigCore; +import io.polyfrost.oneconfig.config.data.ModData; +import io.polyfrost.oneconfig.config.data.ModType; import io.polyfrost.oneconfig.hud.HudCore; import io.polyfrost.oneconfig.test.TestConfig; import net.minecraft.client.Minecraft; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.ModMetadata; import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import java.io.File; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; @Mod(modid = "@ID@", name = "@NAME@", version = "@VER@") public class OneConfig { @@ -21,6 +31,8 @@ public class OneConfig { public static File themesDir = new File(oneConfigDir, "themes/"); public static OneConfigConfig config; public static TestConfig testConfig; + public static List<ModData> loadedMods = new ArrayList<>(); + public static List<ModMetadata> loadedOtherMods = new ArrayList<>(); @Mod.EventHandler public void onPreFMLInit(FMLPreInitializationEvent event) { @@ -37,4 +49,20 @@ public class OneConfig { MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new HudCore()); } + + @Mod.EventHandler + public void onPostFMLInit(FMLPostInitializationEvent event) { + loadedMods.addAll(ConfigCore.settings.keySet()); + LinkedHashSet<ModData> modData = new LinkedHashSet<>(ConfigCore.settings.keySet()); + for(ModContainer mod : Loader.instance().getActiveModList()) { + ModMetadata metadata = mod.getMetadata(); + loadedOtherMods.add(metadata); + String author = metadata.authorList.size() > 0 ? metadata.authorList.get(0) : ""; + ModData newMod = new ModData(metadata.name, ModType.OTHER, author, metadata.version); + if(newMod.name.equals("OneConfig") || newMod.name.equals("Minecraft Coder Pack") || newMod.name.equals("Forge Mod Loader") || newMod.name.equals("Minecraft Forge")) { + continue; + } + if(modData.add(newMod)) loadedMods.add(newMod); // anti duplicate fix + } + } } |