Skip to content
LLytho edited this page Feb 1, 2023 · 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.almostunified.mods:almostunified-common:<version>")
}

Fabric Maven

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

Forge Maven

dependencies {
    modApi(fg.deobf("com.almostunified.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");
    }

    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);
        }
    }
}
Clone this wiki locally