Search in sources :

Example 1 with ArtifactVersion

use of net.minecraftforge.fml.common.versioning.ArtifactVersion in project MinecraftForge by MinecraftForge.

the class MissingModsException method printStackTrace.

@Override
protected void printStackTrace(WrappedPrintStream stream) {
    stream.println("Missing Mods:");
    for (ArtifactVersion v : missingMods) {
        stream.println(String.format("\t%s : %s", v.getLabel(), v.getRangeString()));
    }
    stream.println("");
}
Also used : ArtifactVersion(net.minecraftforge.fml.common.versioning.ArtifactVersion)

Example 2 with ArtifactVersion

use of net.minecraftforge.fml.common.versioning.ArtifactVersion in project MinecraftForge by MinecraftForge.

the class ModAPIManager method registerDataTableAndParseAPI.

public void registerDataTableAndParseAPI(ASMDataTable dataTable) {
    this.dataTable = dataTable;
    Set<ASMData> apiList = dataTable.getAll("net.minecraftforge.fml.common.API");
    apiContainers = Maps.newHashMap();
    for (ASMData data : apiList) {
        Map<String, Object> annotationInfo = data.getAnnotationInfo();
        String apiPackage = data.getClassName().substring(0, data.getClassName().indexOf(".package-info"));
        String providedAPI = (String) annotationInfo.get("provides");
        String apiOwner = (String) annotationInfo.get("owner");
        String apiVersion = (String) annotationInfo.get("apiVersion");
        APIContainer container = apiContainers.get(providedAPI);
        if (container == null) {
            container = new APIContainer(providedAPI, apiVersion, data.getCandidate().getModContainer(), VersionParser.parseVersionReference(apiOwner));
            apiContainers.put(providedAPI, container);
        } else {
            container.validate(providedAPI, apiOwner, apiVersion);
        }
        container.addOwnedPackage(apiPackage);
        for (ModContainer mc : data.getCandidate().getContainedMods()) {
            String embeddedIn = mc.getModId();
            if (container.currentReferents.contains(embeddedIn)) {
                continue;
            }
            FMLLog.fine("Found API %s (owned by %s providing %s) embedded in %s", apiPackage, apiOwner, providedAPI, embeddedIn);
            if (!embeddedIn.equals(apiOwner)) {
                container.addAPIReference(embeddedIn);
            }
        }
    }
    for (APIContainer container : apiContainers.values()) {
        for (String pkg : container.packages) {
            Set<ModCandidate> candidates = dataTable.getCandidatesFor(pkg);
            for (ModCandidate candidate : candidates) {
                List<String> candidateIds = Lists.transform(candidate.getContainedMods(), new ModIdFunction());
                if (!candidateIds.contains(container.ownerMod.getLabel()) && !container.currentReferents.containsAll(candidateIds)) {
                    FMLLog.info("Found mod(s) %s containing declared API package %s (owned by %s) without associated API reference", candidateIds, pkg, container.ownerMod);
                    container.addAPIReferences(candidateIds);
                }
            }
        }
        if (apiContainers.containsKey(container.ownerMod.getLabel())) {
            ArtifactVersion owner = container.ownerMod;
            do {
                APIContainer parent = apiContainers.get(owner.getLabel());
                if (parent == container) {
                    FMLLog.finer("APIContainer %s is it's own parent. skipping", owner);
                    container.markSelfReferenced();
                    break;
                }
                FMLLog.finer("Removing upstream parent %s from %s", parent.ownerMod.getLabel(), container);
                container.currentReferents.remove(parent.ownerMod.getLabel());
                container.referredMods.remove(parent.ownerMod);
                owner = parent.ownerMod;
            } while (apiContainers.containsKey(owner.getLabel()));
        }
        FMLLog.fine("Creating API container dummy for API %s: owner: %s, dependents: %s", container.providedAPI, container.ownerMod, container.referredMods);
    }
}
Also used : ASMData(net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData) DefaultArtifactVersion(net.minecraftforge.fml.common.versioning.DefaultArtifactVersion) ArtifactVersion(net.minecraftforge.fml.common.versioning.ArtifactVersion) ModCandidate(net.minecraftforge.fml.common.discovery.ModCandidate) ModIdFunction(net.minecraftforge.fml.common.functions.ModIdFunction)

Example 3 with ArtifactVersion

use of net.minecraftforge.fml.common.versioning.ArtifactVersion in project MinecraftForge by MinecraftForge.

the class LoadController method sendEventToModContainer.

private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc) {
    String modId = mc.getModId();
    Collection<String> requirements = Collections2.transform(mc.getRequirements(), new ArtifactVersionNameFunction());
    for (ArtifactVersion av : mc.getDependencies()) {
        if (av.getLabel() != null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(), ModState.ERRORED)) {
            FMLLog.log(modId, Level.ERROR, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
            modStates.put(modId, ModState.ERRORED);
            return;
        }
    }
    activeContainer = mc;
    stateEvent.applyModContainer(mc);
    ThreadContext.put("mod", modId);
    FMLLog.log(modId, Level.TRACE, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
    eventChannels.get(modId).post(stateEvent);
    FMLLog.log(modId, Level.TRACE, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
    ThreadContext.remove("mod");
    activeContainer = null;
    if (stateEvent instanceof FMLStateEvent) {
        if (!errors.containsKey(modId)) {
            modStates.put(modId, ((FMLStateEvent) stateEvent).getModState());
        } else {
            modStates.put(modId, ModState.ERRORED);
        }
    }
}
Also used : ArtifactVersion(net.minecraftforge.fml.common.versioning.ArtifactVersion) FMLStateEvent(net.minecraftforge.fml.common.event.FMLStateEvent) ArtifactVersionNameFunction(net.minecraftforge.fml.common.functions.ArtifactVersionNameFunction)

Example 4 with ArtifactVersion

use of net.minecraftforge.fml.common.versioning.ArtifactVersion in project MinecraftForge by MinecraftForge.

the class ModSorter method buildGraph.

private void buildGraph(List<ModContainer> modList, Map<String, ModContainer> nameLookup) {
    modGraph = new DirectedGraph<ModContainer>();
    modGraph.addNode(beforeAll);
    modGraph.addNode(before);
    modGraph.addNode(afterAll);
    modGraph.addNode(after);
    modGraph.addEdge(before, after);
    modGraph.addEdge(beforeAll, before);
    modGraph.addEdge(after, afterAll);
    for (ModContainer mod : modList) {
        modGraph.addNode(mod);
    }
    for (ModContainer mod : modList) {
        if (mod.isImmutable()) {
            // Immutable mods are always before everything
            modGraph.addEdge(beforeAll, mod);
            modGraph.addEdge(mod, before);
            continue;
        }
        boolean preDepAdded = false;
        boolean postDepAdded = false;
        for (ArtifactVersion dep : mod.getDependencies()) {
            preDepAdded = true;
            String modid = dep.getLabel();
            if (modid.equals("*")) {
                // We are "after" everything
                modGraph.addEdge(mod, afterAll);
                modGraph.addEdge(after, mod);
                postDepAdded = true;
            } else {
                modGraph.addEdge(before, mod);
                if (nameLookup.containsKey(modid) || Loader.isModLoaded(modid)) {
                    modGraph.addEdge(nameLookup.get(modid), mod);
                }
            }
        }
        for (ArtifactVersion dep : mod.getDependants()) {
            postDepAdded = true;
            String modid = dep.getLabel();
            if (modid.equals("*")) {
                // We are "before" everything
                modGraph.addEdge(beforeAll, mod);
                modGraph.addEdge(mod, before);
                preDepAdded = true;
            } else {
                modGraph.addEdge(mod, after);
                if (Loader.isModLoaded(modid)) {
                    modGraph.addEdge(mod, nameLookup.get(modid));
                }
            }
        }
        if (!preDepAdded) {
            modGraph.addEdge(before, mod);
        }
        if (!postDepAdded) {
            modGraph.addEdge(mod, after);
        }
    }
}
Also used : ArtifactVersion(net.minecraftforge.fml.common.versioning.ArtifactVersion) DummyModContainer(net.minecraftforge.fml.common.DummyModContainer) ModContainer(net.minecraftforge.fml.common.ModContainer)

Example 5 with ArtifactVersion

use of net.minecraftforge.fml.common.versioning.ArtifactVersion in project BaseMetals by MinecraftModDevelopmentMods.

the class CommonProxy method preInit.

/**
 * @param event
 */
public void preInit(final FMLPreInitializationEvent event) {
    Config.init();
    if ((Options.requireMMDOreSpawn()) && (!Loader.isModLoaded(SharedStrings.ORESPAWN_MODID))) {
        if (Options.fallbackOrespawn()) {
            GameRegistry.registerWorldGenerator(new FallbackGenerator(), 0);
        } else {
            final HashSet<ArtifactVersion> orespawnMod = new HashSet<>();
            orespawnMod.add(new DefaultArtifactVersion(SharedStrings.ORESPAWN_VERSION));
            throw new MissingModsException(orespawnMod, SharedStrings.ORESPAWN_MODID, SharedStrings.ORESPAWN_MISSING_TEXT);
        }
    }
    com.mcmoddev.lib.init.Materials.init();
    Materials.init();
    Fluids.init();
    ItemGroups.init();
    com.mcmoddev.lib.init.Blocks.init();
    Blocks.init();
    com.mcmoddev.lib.init.Items.init();
    Items.init();
    // icons have to be setup after the blocks and items are initialized
    VillagerTrades.init();
    MinecraftForge.EVENT_BUS.register(new EventHandler());
    IntegrationManager.INSTANCE.preInit(event);
    IntegrationManager.INSTANCE.runCallbacks("preInit");
    allsGood = true;
}
Also used : FallbackGenerator(com.mcmoddev.lib.oregen.FallbackGenerator) ArtifactVersion(net.minecraftforge.fml.common.versioning.ArtifactVersion) DefaultArtifactVersion(net.minecraftforge.fml.common.versioning.DefaultArtifactVersion) DefaultArtifactVersion(net.minecraftforge.fml.common.versioning.DefaultArtifactVersion) EventHandler(com.mcmoddev.basemetals.util.EventHandler) MissingModsException(net.minecraftforge.fml.common.MissingModsException) HashSet(java.util.HashSet)

Aggregations

ArtifactVersion (net.minecraftforge.fml.common.versioning.ArtifactVersion)15 DefaultArtifactVersion (net.minecraftforge.fml.common.versioning.DefaultArtifactVersion)7 ModContainer (net.minecraftforge.fml.common.ModContainer)4 ArrayList (java.util.ArrayList)2 ArtifactVersionNameFunction (net.minecraftforge.fml.common.functions.ArtifactVersionNameFunction)2 VersionRange (net.minecraftforge.fml.common.versioning.VersionRange)2 EventHandler (com.mcmoddev.basemetals.util.EventHandler)1 FallbackGenerator (com.mcmoddev.lib.oregen.FallbackGenerator)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Properties (java.util.Properties)1 DummyModContainer (net.minecraftforge.fml.common.DummyModContainer)1 MetadataCollection (net.minecraftforge.fml.common.MetadataCollection)1 MissingModsException (net.minecraftforge.fml.common.MissingModsException)1 EventHandler (net.minecraftforge.fml.common.Mod.EventHandler)1