use of net.fabricmc.loader.api.metadata.ModMetadata in project MasaGadget by plusls.
the class MasaGuiUtil method initMasaModScreenList.
private static void initMasaModScreenList() {
initialised = true;
MinecraftClient client = MinecraftClient.getInstance();
if (!ModInfo.isModLoaded(ModInfo.MODMENU_MOD_ID)) {
return;
}
FabricLoader.getInstance().getEntrypointContainers("modmenu", ModMenuApi.class).forEach(entrypoint -> {
ModMetadata metadata = entrypoint.getProvider().getMetadata();
try {
ModMenuApi api = entrypoint.getEntrypoint();
Screen screen = api.getModConfigScreenFactory().create(client.currentScreen);
if (screen instanceof GuiConfigsBase) {
ConfigScreenFactory<?> configScreenFactory = api.getModConfigScreenFactory();
masaGuiData.put(configScreenFactory, metadata.getName());
masaGuiClassData.put(screen.getClass(), configScreenFactory);
}
} catch (Throwable e) {
ModInfo.LOGGER.error("Mod {} provides a broken implementation of ModMenuApi", metadata.getId(), e);
}
});
}
use of net.fabricmc.loader.api.metadata.ModMetadata in project StationAPI by ModificationStation.
the class MixinSoundHelper method loadModAudio.
@Environment(EnvType.CLIENT)
private static void loadModAudio(SoundMap array, String channel) {
try {
for (ModContainer modContainer : FabricLoader.getInstance().getAllMods()) {
ModMetadata stationMod = modContainer.getMetadata();
Path basePath = Paths.get("/assets/" + stationMod.getId() + "/stationapi/sounds/" + channel);
if (MixinSoundHelper.class.getResource(basePath.toString().replace("\\", "/")) != null) {
RecursiveReader recursiveReader = new RecursiveReader("/assets/" + stationMod.getId() + "/stationapi/sounds/" + channel, (filepath) -> filepath.endsWith(".ogg") || filepath.endsWith(".mp3") || filepath.endsWith(".wav"));
for (URL audioUrl : recursiveReader.read()) {
String audioID = audioUrl.toString().replace("\\", "/").split("/stationapi/sounds/" + channel)[1].replaceFirst("/", "");
((CustomSoundMap) array).putSound(stationMod.getId() + ":" + audioID, audioUrl);
}
}
}
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
}
use of net.fabricmc.loader.api.metadata.ModMetadata in project StationAPI by ModificationStation.
the class VanillaChecker method init.
@EventListener(priority = ListenerPriority.HIGH)
private static void init(PreInitEvent event) {
LOGGER.info("Adding vanilla checker lang folder...");
I18n.addLangFolder(StationAPI.MODID, "/assets/" + MODID + "/lang");
LOGGER.info("Gathering mods that require client verification...");
String value = StationAPI.MODID + ":verify_client";
FabricLoader.getInstance().getAllMods().forEach(modContainer -> {
ModMetadata modMetadata = modContainer.getMetadata();
if (modMetadata.containsCustomValue(value) && modMetadata.getCustomValue(value).getAsBoolean())
CLIENT_REQUIRED_MODS.add(modContainer);
});
}
use of net.fabricmc.loader.api.metadata.ModMetadata in project frame-fabric by moddingplayground.
the class DataMain method main.
public static void main(String[] strings) throws IOException {
OptionParser opts = new OptionParser();
OptionSpec<Void> help = opts.accepts("help", "Show the help menu").forHelp();
OptionSpec<Void> server = opts.accepts("server", "Include server generators");
OptionSpec<Void> client = opts.accepts("client", "Include client generators");
OptionSpec<Void> dev = opts.accepts("dev", "Include development tools");
OptionSpec<Void> reports = opts.accepts("reports", "Include data reports");
OptionSpec<Void> validate = opts.accepts("validate", "Validate inputs");
OptionSpec<Void> all = opts.accepts("all", "Include all generators");
OptionSpec<String> output = opts.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated");
OptionSpec<String> extra = opts.accepts("extra", "Additional output folder to copy assets to").withRequiredArg();
OptionSpec<String> input = opts.accepts("input", "Input folder").withRequiredArg();
OptionSet optionSet = opts.parse(strings);
if (!optionSet.has(help) && optionSet.hasOptions()) {
Path path = Paths.get(output.value(optionSet));
boolean genAll = optionSet.has(all);
boolean genClient = genAll || optionSet.has(client);
boolean genServer = genAll || optionSet.has(server);
boolean genDev = genAll || optionSet.has(dev);
boolean genReports = genAll || optionSet.has(reports);
boolean genValidate = genAll || optionSet.has(validate);
FabricLoader loader = FabricLoader.getInstance();
List<EntrypointContainer<ToymakerEntrypoint>> initializers = loader.getEntrypointContainers("toymaker", ToymakerEntrypoint.class);
if (initializers.isEmpty()) {
LOGGER.error("No data generators were initialized!");
} else {
for (EntrypointContainer<ToymakerEntrypoint> initializer : initializers) {
ModMetadata meta = initializer.getProvider().getMetadata();
if (TARGET_MOD_ID != null && !meta.getId().equals(TARGET_MOD_ID))
continue;
LOGGER.info("Initializing data generator for " + meta.getId());
initializer.getEntrypoint().onInitializeToymaker();
}
}
DataGenerator gen = create(path, optionSet.valuesOf(input).stream().map(Paths::get).collect(Collectors.toList()), genClient, genServer, genDev, genReports, genValidate);
DataGenAccess access = (DataGenAccess) gen;
access.run(config -> optionSet.valuesOf(extra).stream().map(Paths::get).forEach(config::addCopyPath));
} else {
opts.printHelpOn(System.out);
}
}
use of net.fabricmc.loader.api.metadata.ModMetadata in project meteor-client by MeteorDevelopment.
the class AddonManager method init.
@Init(stage = InitStage.Pre)
public static void init() {
// Meteor pseudo addon
{
METEOR = new MeteorAddon() {
@Override
public void onInitialize() {
}
};
ModMetadata metadata = FabricLoader.getInstance().getModContainer("meteor-client").get().getMetadata();
METEOR.name = metadata.getName();
METEOR.authors = new String[metadata.getAuthors().size()];
if (metadata.containsCustomValue("meteor-client:color"))
METEOR.color.parse(metadata.getCustomValue("meteor-client:color").getAsString());
int i = 0;
for (Person author : metadata.getAuthors()) {
METEOR.authors[i++] = author.getName();
}
}
// Addons
for (EntrypointContainer<MeteorAddon> entrypoint : FabricLoader.getInstance().getEntrypointContainers("meteor", MeteorAddon.class)) {
ModMetadata metadata = entrypoint.getProvider().getMetadata();
MeteorAddon addon = entrypoint.getEntrypoint();
addon.name = metadata.getName();
addon.authors = new String[metadata.getAuthors().size()];
if (metadata.containsCustomValue("meteor-client:color"))
addon.color.parse(metadata.getCustomValue("meteor-client:color").getAsString());
int i = 0;
for (Person author : metadata.getAuthors()) {
addon.authors[i++] = author.getName();
}
ADDONS.add(addon);
}
}
Aggregations