Search in sources :

Example 6 with ModMetadata

use of net.minecraftforge.fml.common.ModMetadata in project MinecraftForge by MinecraftForge.

the class FMLClientHandler method detectOptifine.

private void detectOptifine() {
    try {
        Class<?> optifineConfig = Class.forName("Config", false, Loader.instance().getModClassLoader());
        String optifineVersion = (String) optifineConfig.getField("VERSION").get(null);
        Map<String, Object> dummyOptifineMeta = ImmutableMap.<String, Object>builder().put("name", "Optifine").put("version", optifineVersion).build();
        InputStream optifineModInfoInputStream = getClass().getResourceAsStream("optifinemod.info");
        try {
            ModMetadata optifineMetadata = MetadataCollection.from(optifineModInfoInputStream, "optifine").getMetadataForId("optifine", dummyOptifineMeta);
            optifineContainer = new DummyModContainer(optifineMetadata);
            FMLLog.info("Forge Mod Loader has detected optifine %s, enabling compatibility features", optifineContainer.getVersion());
        } finally {
            IOUtils.closeQuietly(optifineModInfoInputStream);
        }
    } catch (Exception e) {
        optifineContainer = null;
    }
}
Also used : ModMetadata(net.minecraftforge.fml.common.ModMetadata) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) DummyModContainer(net.minecraftforge.fml.common.DummyModContainer) JsonObject(com.google.gson.JsonObject) WrongMinecraftVersionException(net.minecraftforge.fml.common.WrongMinecraftVersionException) DuplicateModsFoundException(net.minecraftforge.fml.common.DuplicateModsFoundException) LoaderException(net.minecraftforge.fml.common.LoaderException) IOException(java.io.IOException) ModSortingException(net.minecraftforge.fml.common.toposort.ModSortingException) MissingModsException(net.minecraftforge.fml.common.MissingModsException) Java8VersionException(net.minecraftforge.fml.common.Java8VersionException)

Example 7 with ModMetadata

use of net.minecraftforge.fml.common.ModMetadata in project MinecraftForge by MinecraftForge.

the class BlockStateMappingsTest method setup.

@BeforeClass
public static void setup() {
    System.setProperty("fml.queryResult", "confirm");
    System.setProperty("fml.doNotBackup", "true");
    Loader.instance();
    Bootstrap.register();
    Loader.instance().setupTestHarness(new DummyModContainer(new ModMetadata() {

        {
            modId = "test";
        }
    }));
}
Also used : ModMetadata(net.minecraftforge.fml.common.ModMetadata) DummyModContainer(net.minecraftforge.fml.common.DummyModContainer) BeforeClass(org.junit.BeforeClass)

Example 8 with ModMetadata

use of net.minecraftforge.fml.common.ModMetadata in project MinecraftForge by MinecraftForge.

the class SubstitutionInjectionTest method setup.

@BeforeClass
public static void setup() {
    Loader.instance();
    Bootstrap.register();
    Loader.instance().setupTestHarness(new DummyModContainer(new ModMetadata() {

        {
            modId = "test";
        }
    }));
}
Also used : ModMetadata(net.minecraftforge.fml.common.ModMetadata) DummyModContainer(net.minecraftforge.fml.common.DummyModContainer) BeforeClass(org.junit.BeforeClass)

Aggregations

ModMetadata (net.minecraftforge.fml.common.ModMetadata)8 DummyModContainer (net.minecraftforge.fml.common.DummyModContainer)6 BeforeClass (org.junit.BeforeClass)5 JsonObject (com.google.gson.JsonObject)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ForgeEventHandler (net.geforcemods.securitycraft.handlers.ForgeEventHandler)1 ItemStack (net.minecraft.item.ItemStack)1 Configuration (net.minecraftforge.common.config.Configuration)1 DuplicateModsFoundException (net.minecraftforge.fml.common.DuplicateModsFoundException)1 Java8VersionException (net.minecraftforge.fml.common.Java8VersionException)1 LoaderException (net.minecraftforge.fml.common.LoaderException)1 MissingModsException (net.minecraftforge.fml.common.MissingModsException)1 EventHandler (net.minecraftforge.fml.common.Mod.EventHandler)1 WrongMinecraftVersionException (net.minecraftforge.fml.common.WrongMinecraftVersionException)1 ModSortingException (net.minecraftforge.fml.common.toposort.ModSortingException)1