Search in sources :

Example 41 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project BloodMagic by WayofTime.

the class LivingArmourUpgradeMeleeDecrease method getAttributeModifiers.

@Override
public Multimap<String, AttributeModifier> getAttributeModifiers() {
    Multimap<String, AttributeModifier> modifierMap = HashMultimap.create();
    String name = getUniqueIdentifier() + "-DamageModifier1";
    modifierMap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(UUID.nameUUIDFromBytes(StringUtils.getBytesUtf8(name)), "DamageModifier1", meleeDamage[this.level], 1));
    return modifierMap;
}
Also used : AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 42 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project Minechem by iopleke.

the class PolytoolItem method getAttributeModifiers.

@Override
public Multimap getAttributeModifiers(ItemStack stack) {
    Multimap multimap = HashMultimap.create();
    multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Tool modifier", getSwordStr(stack), 0));
    return multimap;
}
Also used : Multimap(com.google.common.collect.Multimap) HashMultimap(com.google.common.collect.HashMultimap) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 43 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier 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)

Example 44 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project ArsMagica2 by Mithion.

the class BuffStatModifiers method applyOrRemoveScalingModifiersForBuff.

private void applyOrRemoveScalingModifiersForBuff(EntityLivingBase entity, int potionID, IAttribute attribute, AttributeModifier... modifiers) {
    IAttributeInstance inst = entity.getEntityAttribute(attribute);
    if (inst == null) {
        return;
    }
    AttributeModifier currentModifier = inst.getModifier(modifiers[0].getID());
    if (entity.isPotionActive(potionID)) {
        int magnitude = entity.getActivePotionEffect(Potion.potionTypes[potionID]).getAmplifier();
        AttributeModifier modifier = modifiers[Math.min(magnitude, modifiers.length - 1)];
        if (currentModifier != modifier) {
            if (currentModifier != null) {
                inst.removeModifier(currentModifier);
            }
            inst.applyModifier(modifier);
        }
    } else {
        if (currentModifier != null) {
            inst.removeModifier(currentModifier);
        }
    }
}
Also used : IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 45 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project ArsMagica2 by Mithion.

the class BuffStatModifiers method clearAllModifiers.

private void clearAllModifiers(EntityLivingBase entity, KeyValuePair<IAttribute, AttributeModifier>... modifiers) {
    for (KeyValuePair<IAttribute, AttributeModifier> entry : modifiers) {
        IAttributeInstance inst = entity.getEntityAttribute(entry.getKey());
        if (inst == null)
            continue;
        AttributeModifier currentModifier = inst.getModifier(entry.getValue().getID());
        if (currentModifier == entry.getValue()) {
            inst.removeModifier(currentModifier);
        }
    }
}
Also used : IAttribute(net.minecraft.entity.ai.attributes.IAttribute) IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Aggregations

AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)116 Nonnull (javax.annotation.Nonnull)19 Multimap (com.google.common.collect.Multimap)14 IAttributeInstance (net.minecraft.entity.ai.attributes.IAttributeInstance)11 UUID (java.util.UUID)9 ItemStack (net.minecraft.item.ItemStack)9 IAttribute (net.minecraft.entity.ai.attributes.IAttribute)8 HashMultimap (com.google.common.collect.HashMultimap)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 Map (java.util.Map)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)4 Potion (net.minecraft.potion.Potion)4 PotionEffect (net.minecraft.potion.PotionEffect)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 Calendar (java.util.Calendar)3 EnergyUpgrade (crazypants.enderio.base.item.darksteel.upgrade.energy.EnergyUpgrade)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2