use of me.shedaniel.betterloadingscreen.api.step.ParentTask in project BetterLoadingScreen by shedaniel.
the class MixinGameData method syncRegistry.
@Inject(method = "freezeData", remap = false, at = @At(value = "INVOKE", target = "Lnet/minecraftforge/registries/GameData;loadRegistry(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraftforge/registries/RegistryManager;Lnet/minecraftforge/registries/RegistryManager;Ljava/lang/Class;Z)V"), locals = LocalCapture.CAPTURE_FAILHARD)
private static void syncRegistry(CallbackInfo ci, Iterator iterator, Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> entry) {
ParentTask task = LoadGameSteps.finalizeRegistry();
SteppedTask syncTask = task.stepped(LoadGameSteps.FinalizeRegistry.SYNC);
syncTask.setCurrentStepInfo(entry.getValue().getRegistryName().toString());
}
use of me.shedaniel.betterloadingscreen.api.step.ParentTask in project BetterLoadingScreen by shedaniel.
the class MixinGameData method onFreezeData.
@Inject(method = "freezeData", remap = false, at = @At("HEAD"))
private static void onFreezeData(CallbackInfo ci) {
MinecraftStub stub = (MinecraftStub) Minecraft.getInstance();
stub.moveRenderOut();
ParentTask task = LoadGameSteps.finalizeRegistry();
try {
Field field = RegistryManager.class.getDeclaredField("registries");
field.setAccessible(true);
BiMap<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> frozenRegistries = (BiMap<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>>) field.get(RegistryManager.FROZEN);
BiMap<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> registries = (BiMap<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>>) field.get(RegistryManager.ACTIVE);
SteppedTask syncTask = task.stepped(LoadGameSteps.FinalizeRegistry.SYNC);
syncTask.setTotalSteps(registries.size());
SteppedTask freezeTask = task.stepped(LoadGameSteps.FinalizeRegistry.FREEZE);
freezeTask.setTotalSteps(frozenRegistries.size() + registries.size());
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
use of me.shedaniel.betterloadingscreen.api.step.ParentTask in project BetterLoadingScreen by shedaniel.
the class MixinGameData method freezeDataPost.
@Inject(method = { "lambda$freezeData$4", "lambda$freezeData$5", "lambda$freezeData$8", "lambda$freezeData$9" }, remap = false, at = @At(value = "RETURN"))
private static void freezeDataPost(ResourceLocation id, ForgeRegistry registry, CallbackInfo ci) {
ParentTask task = LoadGameSteps.finalizeRegistry();
SteppedTask freezeTask = task.stepped(LoadGameSteps.FinalizeRegistry.FREEZE);
freezeTask.incrementStep();
}
use of me.shedaniel.betterloadingscreen.api.step.ParentTask 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;
};
}
use of me.shedaniel.betterloadingscreen.api.step.ParentTask in project BetterLoadingScreen by shedaniel.
the class MixinModelBakeryFabric method init.
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/util/Map;forEach(Ljava/util/function/BiConsumer;)V", ordinal = 0))
private void init(ResourceManager resourceManager, BlockColors blockColors, ProfilerFiller profilerFiller, int i, CallbackInfo ci) {
int stateCount = 0, itemCount = Registry.ITEM.size();
for (Block block : Registry.BLOCK) {
stateCount += block.getStateDefinition().getPossibleStates().size();
}
ParentTask task = LoadGameSteps.loadModel();
SteppedTask blockTask = task.stepped(LoadGameSteps.LoadModel.BLOCK);
blockTask.setTotalSteps(stateCount);
SteppedTask itemTask = task.stepped(LoadGameSteps.LoadModel.ITEM);
itemTask.setTotalSteps(itemCount);
((ModelBakeryStub) this).betterloadingscreen$setBlockTask(blockTask);
((ModelBakeryStub) this).betterloadingscreen$setItemTask(itemTask);
}
Aggregations