|
3 | 3 | import net.neoforged.bus.api.Event; |
4 | 4 | import net.neoforged.bus.api.EventPriority; |
5 | 5 | import net.neoforged.fml.ModList; |
| 6 | +import net.neoforged.fml.ModLoader; |
6 | 7 | import net.neoforged.fml.ModLoadingContext; |
7 | 8 | import net.neoforged.fml.event.IModBusEvent; |
8 | 9 | import net.neoforged.fml.loading.progress.StartupNotificationManager; |
9 | 10 | import net.neoforged.neoforge.registries.GameData; |
10 | 11 | import net.neoforged.neoforge.registries.RegisterEvent; |
11 | 12 | import org.embeddedt.modernfix.annotation.ClientOnlyMixin; |
12 | | -import org.embeddedt.modernfix.neoforge.util.AsyncLoadingScreen; |
13 | 13 | import org.spongepowered.asm.mixin.Mixin; |
14 | 14 | import org.spongepowered.asm.mixin.injection.At; |
15 | | -import org.spongepowered.asm.mixin.injection.Inject; |
16 | 15 | import org.spongepowered.asm.mixin.injection.Redirect; |
17 | | -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
18 | 16 |
|
19 | 17 | @Mixin(value = GameData.class, remap = false) |
20 | 18 | @ClientOnlyMixin |
21 | 19 | public class GameDataMixin { |
22 | 20 |
|
23 | | - private static AsyncLoadingScreen mfix$asyncScreen; |
24 | | - |
25 | | - @Inject(method = "postRegisterEvents", at = @At(value = "INVOKE", target = "Ljava/util/Set;iterator()Ljava/util/Iterator;", ordinal = 0)) |
26 | | - private static void createAsyncScreen(CallbackInfo ci) { |
27 | | - mfix$asyncScreen = new AsyncLoadingScreen(); |
28 | | - } |
29 | | - |
30 | | - @Inject(method = "postRegisterEvents", at = @At(value = "INVOKE", target = "Ljava/lang/RuntimeException;getSuppressed()[Ljava/lang/Throwable;", ordinal = 0)) |
31 | | - private static void closeAsyncScreen(CallbackInfo ci) { |
32 | | - mfix$asyncScreen.close(); |
33 | | - mfix$asyncScreen = null; |
34 | | - } |
35 | | - |
36 | 21 | @Redirect(method = "postRegisterEvents", at = @At(value = "INVOKE", target = "Lnet/neoforged/fml/ModLoader;postEventWrapContainerInModOrder(Lnet/neoforged/bus/api/Event;)V")) |
37 | | - private static <T extends Event & IModBusEvent> void swapThreadAndPost(T event) { |
| 22 | + private static <T extends Event & IModBusEvent> void postWithProgressBar(T event) { |
| 23 | + if(ModLoader.hasErrors()) { |
| 24 | + return; |
| 25 | + } |
38 | 26 | RegisterEvent registryEvent = (RegisterEvent)event; |
39 | 27 | // We control phases ourselves so we can make a separate progress bar for each phase. |
40 | 28 | String registryName = registryEvent.getRegistryKey().location().toString(); |
41 | 29 | for(EventPriority phase : EventPriority.values()) { |
42 | | - var pb = StartupNotificationManager.addProgressBar(registryName, ModList.get().size()); |
| 30 | + // FIXME need to use prepend rather than append for it to be visible for now |
| 31 | + var pb = StartupNotificationManager.prependProgressBar(registryName, ModList.get().size()); |
43 | 32 | try { |
44 | 33 | ModList.get().forEachModInOrder(mc -> { |
45 | 34 | ModLoadingContext.get().setActiveContainer(mc); |
46 | 35 | pb.label(pb.name() + " - " + mc.getModInfo().getDisplayName()); |
47 | 36 | pb.increment(); |
48 | | - var bus = mc.getEventBus(); |
49 | | - if(bus != null) { |
50 | | - bus.post(phase, event); |
51 | | - } |
| 37 | + mc.acceptEvent(phase, event); |
52 | 38 | ModLoadingContext.get().setActiveContainer(null); |
53 | 39 | }); |
54 | 40 | } finally { |
|
0 commit comments