Skip to content

Commit

Permalink
🌟 调整 Forge 侧资源包注册 API
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Aug 11, 2024
1 parent 6d38c54 commit 0a1840d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()) {
Expand Down

0 comments on commit 0a1840d

Please sign in to comment.