-
Notifications
You must be signed in to change notification settings - Fork 14
API
Relentless edited this page Jun 5, 2024
·
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.almostreliable.mods:almostunified-common:<version>")
}
dependencies {
modApi("com.almostreliable.mods:almostunified-fabric:<version>")
}
dependencies {
compileOnly(fg.deobf("com.almostreliable.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");
}
@Nullable
public static Item getPreferredItemForTag(TagKey<Item> tag) {
if (isLoaded()) {
return Adapter.getPreferredItemForTag(tag);
}
// Default behavior when AU is not loaded.
// This example code will just use the first item in the tag.
return Registry.ITEM.getTag(tag)
.map(HolderSet.ListBacked::stream)
.flatMap(Stream::findFirst)
.map(Holder::value)
.orElse(null);
}
private static class Adapter {
@Nullable
public static Item getPreferredItemForTag(TagKey<Item> tag) {
return AlmostUnifiedLookup.INSTANCE.getPreferredItemForTag(tag);
}
}
}
For other methods that can be used inside your custom integration, see the rest of the lookup interface.