Search in sources :

Example 1 with Attribute

use of net.minecraft.entity.ai.attributes.Attribute in project Bookshelf by Darkhax-Minecraft.

the class EnchantmentAttribute method applyModifiers.

protected void applyModifiers(LivingEntity living, int level) {
    final AttributeModifierManager attributeMap = living.getAttributes();
    for (final Entry<Attribute, AttributeModifier> entry : this.getModifiers(level).entrySet()) {
        final ModifiableAttributeInstance modifiable = attributeMap.getInstance(entry.getKey());
        if (modifiable != null) {
            final AttributeModifier effectModifier = entry.getValue();
            modifiable.removeModifier(effectModifier);
            modifiable.addPermanentModifier(effectModifier);
        }
    }
}
Also used : AttributeModifierManager(net.minecraft.entity.ai.attributes.AttributeModifierManager) Attribute(net.minecraft.entity.ai.attributes.Attribute) ModifiableAttributeInstance(net.minecraft.entity.ai.attributes.ModifiableAttributeInstance) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Aggregations

Attribute (net.minecraft.entity.ai.attributes.Attribute)1 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)1 AttributeModifierManager (net.minecraft.entity.ai.attributes.AttributeModifierManager)1 ModifiableAttributeInstance (net.minecraft.entity.ai.attributes.ModifiableAttributeInstance)1