Search in sources :

Example 61 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project Gaia-Dimension by Andromander.

the class GDZirconPrinceSword method getItemAttributeModifiers.

// TODO: Make this sword have lightning projectiles, reducing durability by 3
// TODO: [FUTURE] Can be used to unlock Unknown Goldstone Structure
// We will need this in order to make the weapon slow
@Override
@Nonnull
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
    Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
    if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
        // This is not our speed anymore
        multimap.removeAll(SharedMonsterAttributes.ATTACK_SPEED.getName());
        // Speed is set to 1; 0.6 less than normal
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.3, 0));
    }
    return multimap;
}
Also used : AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier) Nonnull(javax.annotation.Nonnull)

Example 62 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project Charset by CharsetMC.

the class ItemUtils method getAttributeValue.

public static double getAttributeValue(EntityEquipmentSlot slot, ItemStack is, IAttribute attr) {
    Multimap<String, AttributeModifier> attrs = is.getItem().getAttributeModifiers(slot, is);
    if (attrs != null) {
        AttributeMap map = new AttributeMap();
        map.applyAttributeModifiers(attrs);
        IAttributeInstance instance = map.getAttributeInstance(attr);
        if (instance != null) {
            return instance.getAttributeValue();
        }
    }
    return 0;
}
Also used : AttributeMap(net.minecraft.entity.ai.attributes.AttributeMap) IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 63 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project Galacticraft by micdoodle8.

the class ItemSwordAsteroids method getItemAttributeModifiers.

@Override
public Multimap<String, AttributeModifier> getItemAttributeModifiers() {
    Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers();
    multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", this.attackDamageD, 0));
    return multimap;
}
Also used : AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 64 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project CompositeGear by TwilightWingsStudio.

the class ItemCGMelee method getAttributeModifiers.

@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) {
    Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
    if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
        double speedModifier = SWORD_SPEED_MODIFIER;
        // TODO: Fix this stupid check in future.
        if (stack.getItem() == ItemsCG.compositeDagger) {
            speedModifier = DAGGER_SPEED_MODIFIER;
        }
        if (stack.getItem() == ItemsCG.compositeMace) {
            speedModifier = MACE_SPEED_MODIFIER;
        }
        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 3.0D + (double) this.getAttackDamage(), 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", speedModifier, 0));
    }
    return multimap;
}
Also used : AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 65 with AttributeModifier

use of net.minecraft.entity.ai.attributes.AttributeModifier in project Bewitchment by Um-Mitternacht.

the class BrewAttributeModifier method removeAttributeModifiers.

public void removeAttributeModifiers(AbstractAttributeMap attributeMapIn, int amplifier) {
    for (Map.Entry<IAttribute, AttributeModifier> entry : modifierMap.entrySet()) {
        IAttributeInstance attribute = attributeMapIn.getAttributeInstance(entry.getKey());
        if (attribute == null)
            continue;
        attribute.removeModifier(entry.getValue());
    }
}
Also used : IAttribute(net.minecraft.entity.ai.attributes.IAttribute) IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier) AbstractAttributeMap(net.minecraft.entity.ai.attributes.AbstractAttributeMap) Map(java.util.Map)

Aggregations

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