Search in sources :

Example 1 with IModFileInfo

use of net.minecraftforge.forgespi.language.IModFileInfo in project MinecraftForge by MinecraftForge.

the class MinecraftLocator method buildMinecraftTOML.

private IModFileInfo buildMinecraftTOML(final IModFile iModFile) {
    final ModFile modFile = (ModFile) iModFile;
    /*
        final Path mcmodtoml = modFile.findResource("META-INF", "minecraftmod.toml");
        if (Files.notExists(mcmodtoml)) {
            LOGGER.fatal(LOADING, "Mod file {} is missing minecraftmod.toml file", modFile.getFilePath());
            return null;
        }

        final FileConfig mcmodstomlfile = FileConfig.builder(mcmodtoml).build();
        mcmodstomlfile.load();
        mcmodstomlfile.close();
        */
    // We haven't changed this in years, and I can't be asked right now to special case this one file in the path.
    final var conf = Config.inMemory();
    conf.set("modLoader", "minecraft");
    conf.set("loaderVersion", "1");
    conf.set("license", "Mojang Studios, All Rights Reserved");
    final var mods = Config.inMemory();
    mods.set("modId", "minecraft");
    mods.set("version", FMLLoader.versionInfo().mcVersion());
    mods.set("displayName", "Minecraft");
    mods.set("logoFile", "mcplogo.png");
    mods.set("credits", "Mojang, deobfuscated by MCP");
    mods.set("authors", "MCP: Searge,ProfMobius,IngisKahn,Fesh0r,ZeuX,R4wk,LexManos,Bspkrs");
    mods.set("description", "Minecraft, decompiled and deobfuscated with MCP technology");
    conf.set("mods", List.of(mods));
    /*
        conf.putAll(mcmodstomlfile);

        final var extralangs = Stream.<IModFileInfo.LanguageSpec>builder();
        final Path forgemodtoml = modFile.findResource("META-INF", "mods.toml");
        if (Files.notExists(forgemodtoml)) {
            LOGGER.info("No forge mods.toml file found, not loading forge mod");
        } else {
            final FileConfig forgemodstomlfile = FileConfig.builder(forgemodtoml).build();
            forgemodstomlfile.load();
            forgemodstomlfile.close();
            conf.putAll(forgemodstomlfile);
            conf.<List<Object>>get("mods").add(0, mcmodstomlfile.<List<Object>>get("mods").get(0)); // Add MC as a sub-mod
            extralangs.add(new IModFileInfo.LanguageSpec(mcmodstomlfile.get("modLoader"), MavenVersionAdapter.createFromVersionSpec(mcmodstomlfile.get("loaderVersion"))));
        }
        */
    final NightConfigWrapper configWrapper = new NightConfigWrapper(conf);
    // final ModFileInfo modFileInfo = new ModFileInfo(modFile, configWrapper, extralangs.build().toList());
    final ModFileInfo modFileInfo = new ModFileInfo(modFile, configWrapper, List.of());
    configWrapper.setFile(modFileInfo);
    return modFileInfo;
}
Also used : IModFile(net.minecraftforge.forgespi.locating.IModFile) IModFileInfo(net.minecraftforge.forgespi.language.IModFileInfo)

Example 2 with IModFileInfo

use of net.minecraftforge.forgespi.language.IModFileInfo in project MinecraftForge by MinecraftForge.

the class ModFileParser method modsTomlParser.

public static IModFileInfo modsTomlParser(final IModFile imodFile) {
    ModFile modFile = (ModFile) imodFile;
    LOGGER.debug(LogMarkers.LOADING, "Considering mod file candidate {}", modFile.getFilePath());
    final Path modsjson = modFile.findResource("META-INF", "mods.toml");
    if (!Files.exists(modsjson)) {
        LOGGER.warn(LogMarkers.LOADING, "Mod file {} is missing mods.toml file", modFile.getFilePath());
        return null;
    }
    final FileConfig fileConfig = FileConfig.builder(modsjson).build();
    fileConfig.load();
    fileConfig.close();
    final NightConfigWrapper configWrapper = new NightConfigWrapper(fileConfig);
    final ModFileInfo modFileInfo = new ModFileInfo(modFile, configWrapper);
    configWrapper.setFile(modFileInfo);
    return modFileInfo;
}
Also used : Path(java.nio.file.Path) FileConfig(com.electronwill.nightconfig.core.file.FileConfig) IModFile(net.minecraftforge.forgespi.locating.IModFile) IModFileInfo(net.minecraftforge.forgespi.language.IModFileInfo)

Aggregations

IModFileInfo (net.minecraftforge.forgespi.language.IModFileInfo)2 IModFile (net.minecraftforge.forgespi.locating.IModFile)2 FileConfig (com.electronwill.nightconfig.core.file.FileConfig)1 Path (java.nio.file.Path)1