Search in sources :

Example 1 with StatusIdentifier

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;
    };
}
Also used : FabricLoader(net.fabricmc.loader.api.FabricLoader) Iterables(com.google.common.collect.Iterables) EntrypointContainer(net.fabricmc.loader.api.entrypoint.EntrypointContainer) Unique(org.spongepowered.asm.mixin.Unique) IntConsumer(java.util.function.IntConsumer) Multimap(com.google.common.collect.Multimap) Supplier(java.util.function.Supplier) Minecraft(net.minecraft.client.Minecraft) Mixin(org.spongepowered.asm.mixin.Mixin) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) ModContainer(net.fabricmc.loader.api.ModContainer) LinkedHashMultimap(com.google.common.collect.LinkedHashMultimap) LoadGameSteps(me.shedaniel.betterloadingscreen.api.step.LoadGameSteps) ExceptionUtil(net.fabricmc.loader.impl.util.ExceptionUtil) At(org.spongepowered.asm.mixin.injection.At) ClientModInitializer(net.fabricmc.api.ClientModInitializer) Redirect(org.spongepowered.asm.mixin.injection.Redirect) Collection(java.util.Collection) ModInitializer(net.fabricmc.api.ModInitializer) File(java.io.File) ParentTask(me.shedaniel.betterloadingscreen.api.step.ParentTask) ModMetadata(net.fabricmc.loader.api.metadata.ModMetadata) FabricLoaderImpl(net.fabricmc.loader.impl.FabricLoaderImpl) StatusIdentifier(me.shedaniel.betterloadingscreen.api.StatusIdentifier) Shadow(org.spongepowered.asm.mixin.Shadow) SteppedTask(me.shedaniel.betterloadingscreen.api.step.SteppedTask) SteppedTask(me.shedaniel.betterloadingscreen.api.step.SteppedTask) EntrypointContainer(net.fabricmc.loader.api.entrypoint.EntrypointContainer) ParentTask(me.shedaniel.betterloadingscreen.api.step.ParentTask) ModMetadata(net.fabricmc.loader.api.metadata.ModMetadata) Unique(org.spongepowered.asm.mixin.Unique)

Aggregations

Iterables (com.google.common.collect.Iterables)1 LinkedHashMultimap (com.google.common.collect.LinkedHashMultimap)1 Multimap (com.google.common.collect.Multimap)1 File (java.io.File)1 Collection (java.util.Collection)1 Map (java.util.Map)1 BiConsumer (java.util.function.BiConsumer)1 IntConsumer (java.util.function.IntConsumer)1 Supplier (java.util.function.Supplier)1 StatusIdentifier (me.shedaniel.betterloadingscreen.api.StatusIdentifier)1 LoadGameSteps (me.shedaniel.betterloadingscreen.api.step.LoadGameSteps)1 ParentTask (me.shedaniel.betterloadingscreen.api.step.ParentTask)1 SteppedTask (me.shedaniel.betterloadingscreen.api.step.SteppedTask)1 ClientModInitializer (net.fabricmc.api.ClientModInitializer)1 ModInitializer (net.fabricmc.api.ModInitializer)1 FabricLoader (net.fabricmc.loader.api.FabricLoader)1 ModContainer (net.fabricmc.loader.api.ModContainer)1 EntrypointContainer (net.fabricmc.loader.api.entrypoint.EntrypointContainer)1 ModMetadata (net.fabricmc.loader.api.metadata.ModMetadata)1 FabricLoaderImpl (net.fabricmc.loader.impl.FabricLoaderImpl)1