-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: TheSilkMiner <thesilkminer@outlook.com>
- Loading branch information
1 parent
1799777
commit a7228df
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Forge/src/main/java/com/blamejared/contenttweaker/forge/resource/ForgeResourceManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.blamejared.contenttweaker.forge.resource; | ||
|
||
import com.blamejared.contenttweaker.core.resource.RuntimeRepositorySource; | ||
import com.blamejared.contenttweaker.core.resource.UserRepositorySource; | ||
import net.minecraft.server.packs.PackType; | ||
import net.minecraft.server.packs.repository.RepositorySource; | ||
import net.minecraftforge.event.AddPackFindersEvent; | ||
import net.minecraftforge.eventbus.api.EventPriority; | ||
import net.minecraftforge.eventbus.api.IEventBus; | ||
|
||
import java.util.function.Function; | ||
|
||
public final class ForgeResourceManager { | ||
private ForgeResourceManager() {} | ||
|
||
public static void init(final IEventBus modBus) { | ||
modBus.addListener(EventPriority.HIGH, false, AddPackFindersEvent.class, ForgeResourceManager::injectRuntime); | ||
modBus.addListener(EventPriority.LOW, false, AddPackFindersEvent.class, ForgeResourceManager::injectUser); | ||
} | ||
|
||
private static void injectRuntime(final AddPackFindersEvent event) { | ||
injectSource(event, RuntimeRepositorySource::of); | ||
} | ||
|
||
private static void injectUser(final AddPackFindersEvent event) { | ||
injectSource(event, UserRepositorySource::of); | ||
} | ||
|
||
private static void injectSource(final AddPackFindersEvent event, final Function<PackType, ? extends RepositorySource> constructor) { | ||
event.addRepositorySource(constructor.apply(event.getPackType())); | ||
} | ||
} |