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();
}
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;
}
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;
}
}
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;
}
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();
});
}
Aggregations