use of me.shedaniel.betterloadingscreen.api.StatusIdentifier 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