From 0a1840d76ee7de678854a384c097040c91e11176 Mon Sep 17 00:00:00 2001 From: Gugle Date: Sun, 11 Aug 2024 22:59:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=9F=20=E8=B0=83=E6=95=B4=20Forge=20?= =?UTF-8?q?=E4=BE=A7=E8=B5=84=E6=BA=90=E5=8C=85=E6=B3=A8=E5=86=8C=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/registrar/forge/ResourcePacksHelperImpl.java | 5 ++++- .../lib/registrar/forge/ResourcePacksHelperImpl.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/forge/src/main/java/dev/anvilcraft/lib/registrar/forge/ResourcePacksHelperImpl.java b/forge/src/main/java/dev/anvilcraft/lib/registrar/forge/ResourcePacksHelperImpl.java index 1b375b4..4283983 100644 --- a/forge/src/main/java/dev/anvilcraft/lib/registrar/forge/ResourcePacksHelperImpl.java +++ b/forge/src/main/java/dev/anvilcraft/lib/registrar/forge/ResourcePacksHelperImpl.java @@ -8,7 +8,9 @@ import net.minecraft.server.packs.repository.PackSource; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.AddPackFindersEvent; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.resource.PathPackResources; @@ -24,7 +26,8 @@ public static void registerBuiltinResourcePack(@NotNull ResourceLocation pack, R throw new IllegalStateException("%s's ModContainer couldn't be found!".formatted(modid)); } IModFile modFile = modFileInfo.getFile(); - MinecraftForge.EVENT_BUS.addListener((AddPackFindersEvent event) -> { + IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); + bus.addListener((AddPackFindersEvent event) -> { if (event.getPackType() == PackType.SERVER_DATA && type.isServer()) { registerPack(event, modFile, pack, PackType.SERVER_DATA); } else if (type.isClient()) { diff --git a/neoforge/src/main/java/dev/anvilcraft/lib/registrar/forge/ResourcePacksHelperImpl.java b/neoforge/src/main/java/dev/anvilcraft/lib/registrar/forge/ResourcePacksHelperImpl.java index 1b375b4..4283983 100644 --- a/neoforge/src/main/java/dev/anvilcraft/lib/registrar/forge/ResourcePacksHelperImpl.java +++ b/neoforge/src/main/java/dev/anvilcraft/lib/registrar/forge/ResourcePacksHelperImpl.java @@ -8,7 +8,9 @@ import net.minecraft.server.packs.repository.PackSource; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.AddPackFindersEvent; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.resource.PathPackResources; @@ -24,7 +26,8 @@ public static void registerBuiltinResourcePack(@NotNull ResourceLocation pack, R throw new IllegalStateException("%s's ModContainer couldn't be found!".formatted(modid)); } IModFile modFile = modFileInfo.getFile(); - MinecraftForge.EVENT_BUS.addListener((AddPackFindersEvent event) -> { + IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); + bus.addListener((AddPackFindersEvent event) -> { if (event.getPackType() == PackType.SERVER_DATA && type.isServer()) { registerPack(event, modFile, pack, PackType.SERVER_DATA); } else if (type.isClient()) {