Search in sources :

Example 1 with DataResource

use of net.silentchaos512.gear.util.DataResource in project Silent-Gear by SilentChaos512.

the class PartBuilder method trait.

public PartBuilder trait(DataResource<ITrait> trait, int level, ITraitCondition... conditions) {
    ITraitInstance inst = TraitInstance.of(trait, level, conditions);
    this.traits.add(inst);
    return this;
}
Also used : ITraitInstance(net.silentchaos512.gear.api.traits.ITraitInstance)

Example 2 with DataResource

use of net.silentchaos512.gear.util.DataResource in project Silent-Gear by SilentChaos512.

the class CuriosCompat method getHighestTraitLevel.

public static int getHighestTraitLevel(LivingEntity entity, DataResource<ITrait> trait) {
    LazyOptional<IItemHandlerModifiable> lazy = CuriosApi.getCuriosHelper().getEquippedCurios(entity);
    int max = 0;
    if (lazy.isPresent()) {
        IItemHandlerModifiable handler = lazy.orElseThrow(IllegalStateException::new);
        for (int i = 0; i < handler.getSlots(); ++i) {
            ItemStack stack = handler.getStackInSlot(i);
            if (stack.getItem() instanceof ICoreItem) {
                max = Math.max(max, TraitHelper.getTraitLevel(stack, trait));
            }
        }
    }
    return max;
}
Also used : IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) ICoreItem(net.silentchaos512.gear.api.item.ICoreItem) ItemStack(net.minecraft.world.item.ItemStack)

Example 3 with DataResource

use of net.silentchaos512.gear.util.DataResource in project Silent-Gear by SilentChaos512.

the class MaterialBuilder method trait.

public MaterialBuilder trait(PartType partType, DataResource<ITrait> trait, int level, ITraitCondition... conditions) {
    ITraitInstance inst = TraitInstance.of(trait, level, conditions);
    List<ITraitInstance> list = traits.computeIfAbsent(partType, pt -> new ArrayList<>());
    list.add(inst);
    return this;
}
Also used : ITraitInstance(net.silentchaos512.gear.api.traits.ITraitInstance)

Aggregations

ITraitInstance (net.silentchaos512.gear.api.traits.ITraitInstance)2 ItemStack (net.minecraft.world.item.ItemStack)1 IItemHandlerModifiable (net.minecraftforge.items.IItemHandlerModifiable)1 ICoreItem (net.silentchaos512.gear.api.item.ICoreItem)1