Search in sources :

Example 11 with ModContainer

use of net.fabricmc.loader.api.ModContainer in project fabric by Legacy-Fabric.

the class CrashReportMixin method getFabricMods.

@Unique
public String getFabricMods() {
    Map<String, String> mods = new TreeMap<>();
    for (ModContainer container : FabricLoader.getInstance().getAllMods()) {
        mods.put(container.getMetadata().getId(), container.getMetadata().getName() + " " + container.getMetadata().getVersion().getFriendlyString());
    }
    StringBuilder modString = new StringBuilder();
    for (String id : mods.keySet()) {
        modString.append("\n\t\t");
        modString.append(id);
        modString.append(": ");
        modString.append(mods.get(id));
    }
    return modString.toString();
}
Also used : ModContainer(net.fabricmc.loader.api.ModContainer) TreeMap(java.util.TreeMap) Unique(org.spongepowered.asm.mixin.Unique)

Example 12 with ModContainer

use of net.fabricmc.loader.api.ModContainer in project Iris by IrisShaders.

the class Iris method onInitializeClient.

@Override
public void onInitializeClient() {
    FabricLoader.getInstance().getModContainer("sodium").ifPresent(modContainer -> {
        sodiumInstalled = true;
        String versionString = modContainer.getMetadata().getVersion().getFriendlyString();
        // nice warning, and prevent them from playing the game with a wrong version of Sodium.
        if (!SodiumVersionCheck.isAllowedVersion(versionString)) {
            sodiumInvalid = true;
        }
    });
    ModContainer iris = FabricLoader.getInstance().getModContainer(MODID).orElseThrow(() -> new IllegalStateException("Couldn't find the mod container for Iris"));
    IRIS_VERSION = iris.getMetadata().getVersion().getFriendlyString();
    try {
        if (!Files.exists(getShaderpacksDirectory())) {
            Files.createDirectories(getShaderpacksDirectory());
        }
    } catch (IOException e) {
        logger.warn("Failed to create the shaderpacks directory!");
        logger.warn("", e);
    }
    irisConfig = new IrisConfig(FabricLoader.getInstance().getConfigDir().resolve("iris.properties"));
    try {
        irisConfig.initialize();
    } catch (IOException e) {
        logger.error("Failed to initialize Iris configuration, default values will be used instead");
        logger.error("", e);
    }
    reloadKeybind = KeyBindingHelper.registerKeyBinding(new KeyMapping("iris.keybind.reload", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_R, "iris.keybinds"));
    toggleShadersKeybind = KeyBindingHelper.registerKeyBinding(new KeyMapping("iris.keybind.toggleShaders", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_K, "iris.keybinds"));
    shaderpackScreenKeybind = KeyBindingHelper.registerKeyBinding(new KeyMapping("iris.keybind.shaderPackSelection", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_O, "iris.keybinds"));
    initialized = true;
}
Also used : IrisConfig(net.coderbot.iris.config.IrisConfig) ModContainer(net.fabricmc.loader.api.ModContainer) KeyMapping(net.minecraft.client.KeyMapping) IOException(java.io.IOException)

Example 13 with ModContainer

use of net.fabricmc.loader.api.ModContainer in project EmissiveMod by Traben-0.

the class MIX_SimpleResourceReload method injected.

@Inject(method = "getProgress", at = @At("RETURN"))
private void injected(CallbackInfoReturnable<Float> cir) {
    if (cir.getReturnValue() == 1.0) {
        if (falseAfterFirstRun) {
            falseAfterFirstRun = false;
            resetVisuals();
            for (ModContainer mod : FabricLoader.getInstance().getAllMods()) {
                if (mod.toString().contains("puzzle")) {
                    modMessage("Entity Texture Features - @Motschen's Mod 'Puzzle' was detected: please ensure you disable emissive entities in that mod!", false);
                    puzzleDetected = true;
                    break;
                }
            }
        }
    } else {
        falseAfterFirstRun = true;
    }
}
Also used : ModContainer(net.fabricmc.loader.api.ModContainer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 14 with ModContainer

use of net.fabricmc.loader.api.ModContainer in project conditional-mixin by Fallen-Breath.

the class SimpleRestrictionChecker method checkConditions.

private List<Result> checkConditions(List<AnnotationNode> conditions) {
    List<Result> results = Lists.newArrayList();
    for (AnnotationNode condition : conditions) {
        Condition.Type type = Annotations.getValue(condition, "type", Condition.Type.class, Condition.Type.MOD);
        switch(type) {
            case MOD:
                String modId = Annotations.getValue(condition, "value");
                Objects.requireNonNull(modId);
                Optional<ModContainer> modContainer = FabricLoader.getInstance().getModContainer(modId);
                if (!modContainer.isPresent()) {
                    results.add(new Result(false, String.format("required mod %s not found", modId)));
                    continue;
                }
                Version modVersion = modContainer.get().getMetadata().getVersion();
                List<String> versionPredicates = Lists.newArrayList(Annotations.getValue(condition, "versionPredicates", Lists.newArrayList()));
                if (!VersionChecker.doesVersionSatisfyPredicate(modVersion, versionPredicates)) {
                    results.add(new Result(false, String.format("mod %s@%s does not matches version predicates %s", modId, modVersion.getFriendlyString(), versionPredicates)));
                    continue;
                }
                results.add(new Result(true, String.format("conflicted/unsupported mod %s@%s found", modId, modVersion.getFriendlyString())));
                break;
            case MIXIN:
                String className = Annotations.getValue(condition, "value");
                if (!this.checkRestriction(className)) {
                    results.add(new Result(false, String.format("required mixin class %s disabled", className)));
                    continue;
                }
                results.add(new Result(true, String.format("conflicted mixin class %s found", className)));
                break;
        }
    }
    return results;
}
Also used : Condition(me.fallenbreath.conditionalmixin.api.annotation.Condition) ModContainer(net.fabricmc.loader.api.ModContainer) AnnotationNode(org.objectweb.asm.tree.AnnotationNode) Version(net.fabricmc.loader.api.Version)

Example 15 with ModContainer

use of net.fabricmc.loader.api.ModContainer in project quilt-standard-libraries by QuiltMC.

the class CrashInfoImpl method addDetails.

@Override
public void addDetails(SystemDetails details) {
    details.addSection("Quilt Mods", () -> {
        var builder = new StringBuilder();
        for (ModContainer mod : FabricLoader.getInstance().getAllMods()) {
            var metadata = mod.getMetadata();
            builder.append("\n\t\t%s: %s %s".formatted(metadata.getId(), metadata.getName(), metadata.getVersion().getFriendlyString()));
        }
        return builder.toString();
    });
}
Also used : ModContainer(net.fabricmc.loader.api.ModContainer)

Aggregations

ModContainer (net.fabricmc.loader.api.ModContainer)32 IOException (java.io.IOException)5 Path (java.nio.file.Path)4 Collection (java.util.Collection)4 Inject (org.spongepowered.asm.mixin.injection.Inject)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 File (java.io.File)2 Field (java.lang.reflect.Field)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 Condition (me.fallenbreath.conditionalmixin.api.annotation.Condition)2 FabricLoader (net.fabricmc.loader.api.FabricLoader)2 Version (net.fabricmc.loader.api.Version)2 ModMetadata (net.fabricmc.loader.api.metadata.ModMetadata)2 I18n (net.minecraft.client.resource.language.I18n)2 ResourcePack (net.minecraft.resource.ResourcePack)2 LiteralText (net.minecraft.text.LiteralText)2 Identifier (net.minecraft.util.Identifier)2 Unique (org.spongepowered.asm.mixin.Unique)2 IMixinTransformer (org.spongepowered.asm.mixin.transformer.IMixinTransformer)2