-
Notifications
You must be signed in to change notification settings - Fork 14
API
LLytho edited this page Feb 1, 2023
·
8 revisions
Every release of this project is built and published to the BlameJared maven.
repositories {
maven {
url = 'https://maven.blamejared.com'
name = 'BlameJared Maven'
}
}
dependencies {
modApi("com.almostunified.mods:almostunified-common:<version>")
}
dependencies {
modApi("com.almostunified.mods:almostunified-fabric:<version>")
}
dependencies {
modApi(fg.deobf("com.almostunified.mods:almostunified-forge:<version>"))
}
public class AlmostUnifiedAdapter {
public static boolean isLoaded() {
// For Forge:
return ModList.get().isLoaded("almostunified");
// For Fabric:
return FabricLoader.getInstance().isModLoaded("almostunified");
}
public Item getPreferredItemForTag(TagKey<Item> tag) {
if (isLoaded()) {
return Adapter.getPreferredItemForTag(tag);
}
return Registry.ITEM.getTag(tag)
.map(HolderSet.ListBacked::stream)
.flatMap(Stream::findFirst)
.map(Holder::value)
.orElse(null);
}
private static class Adapter {
public static Item getPreferredItemForTag(TagKey<Item> tag) {
return AlmostUnifiedLookup.INSTANCE.getPreferredItemForTag(tag);
}
}
}