Skip to content
Relentless edited this page Jun 5, 2024 · 8 revisions

Maven

Every release of this project is built and published to the BlameJared maven.

repositories {
    maven {
        url = 'https://maven.blamejared.com'
        name = 'BlameJared Maven'
    }
}

Common Maven

dependencies {
    modApi("com.almostreliable.mods:almostunified-common:<version>")
}

Fabric Maven

dependencies {
    modApi("com.almostreliable.mods:almostunified-fabric:<version>")
}

Forge Maven

dependencies {
    compileOnly(fg.deobf("com.almostreliable.mods:almostunified-forge:<version>"))
}

Create a simple adapter

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.

Clone this wiki locally