use of net.fabricmc.loader.api.entrypoint.EntrypointContainer 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.entrypoint.EntrypointContainer in project BetterLoadingScreen by shedaniel.
the class MixinMinecraft method invoke.
@Unique
private static <T> Supplier<RuntimeException> invoke(String name, Class<T> type, StatusIdentifier<SteppedTask> taskId, IntConsumer total, BiConsumer<ModContainer, ? super T> invoker) {
ParentTask initMods = LoadGameSteps.initMods();
Collection<EntrypointContainer<T>> entrypoints = FabricLoader.getInstance().getEntrypointContainers(name, type);
Multimap<String, EntrypointContainer<T>> map = LinkedHashMultimap.create();
SteppedTask task = initMods.stepped(taskId);
for (EntrypointContainer<T> container : entrypoints) {
ModMetadata metadata = container.getProvider().getMetadata();
map.put(metadata.getId(), container);
}
total.accept(map.keySet().size());
return () -> {
RuntimeException exception = null;
for (Map.Entry<String, Collection<EntrypointContainer<T>>> entry : map.asMap().entrySet()) {
task.setCurrentStepInfo(Iterables.getFirst(entry.getValue(), null).getProvider().getMetadata().getName());
for (EntrypointContainer<T> container : entry.getValue()) {
try {
invoker.accept(container.getProvider(), container.getEntrypoint());
} catch (Throwable t) {
exception = ExceptionUtil.gatherExceptions(t, exception, exc -> new RuntimeException(String.format("Could not execute entrypoint stage '%s' due to errors, provided by '%s'!", name, container.getProvider().getMetadata().getId()), exc));
}
}
task.incrementStep();
}
return exception;
};
}
Aggregations