Search in sources :

Example 1 with ModelPredicateProvider

use of net.modificationstation.stationapi.api.client.model.item.ModelPredicateProvider in project StationAPI by ModificationStation.

the class ModelOverride method matches.

boolean matches(ItemInstance stack, @Nullable ClientLevel world, @Nullable Living entity) {
    ItemBase item = stack.getType();
    Iterator<Entry<Identifier, Float>> var5 = this.predicateToThresholds.entrySet().iterator();
    Entry<Identifier, Float> entry;
    ModelPredicateProvider modelPredicateProvider;
    if (!var5.hasNext()) {
        return true;
    }
    entry = var5.next();
    modelPredicateProvider = ModelPredicateProviderRegistry.INSTANCE.get(item, entry.getKey());
    while (modelPredicateProvider != null && modelPredicateProvider.call(stack, world, entity) >= entry.getValue()) {
        if (!var5.hasNext()) {
            return true;
        }
        entry = var5.next();
        modelPredicateProvider = ModelPredicateProviderRegistry.INSTANCE.get(item, entry.getKey());
    }
    return false;
}
Also used : Identifier(net.modificationstation.stationapi.api.registry.Identifier) ItemBase(net.minecraft.item.ItemBase) ModelPredicateProvider(net.modificationstation.stationapi.api.client.model.item.ModelPredicateProvider)

Aggregations

ItemBase (net.minecraft.item.ItemBase)1 ModelPredicateProvider (net.modificationstation.stationapi.api.client.model.item.ModelPredicateProvider)1 Identifier (net.modificationstation.stationapi.api.registry.Identifier)1