Search in sources :

Example 1 with ModifiableAttributeInstance

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

the class Freedom method applyEffect.

@Override
public boolean applyEffect(EntityPlayer player, World world, ItemStack stack, ImbuementApplicationTypes matchedType, Object... params) {
    ModifiableAttributeInstance instance = (ModifiableAttributeInstance) player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.movementSpeed);
    ArrayList<AttributeModifier> toRemove = new ArrayList<AttributeModifier>();
    Collection c = instance.func_111122_c();
    ArrayList arraylist = new ArrayList(c);
    Iterator iterator = arraylist.iterator();
    while (iterator.hasNext()) {
        AttributeModifier attributemodifier = (AttributeModifier) iterator.next();
        if (attributemodifier.getOperation() == 2 && attributemodifier.getAmount() < 0.0f) {
            toRemove.add(attributemodifier);
        }
    }
    for (AttributeModifier modifier : toRemove) {
        instance.removeModifier(modifier);
    }
    return toRemove.size() > 0;
}
Also used : ModifiableAttributeInstance(net.minecraft.entity.ai.attributes.ModifiableAttributeInstance) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Collection(java.util.Collection) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)1 ModifiableAttributeInstance (net.minecraft.entity.ai.attributes.ModifiableAttributeInstance)1