Search in sources :

Example 1 with EntityAttributeModifier

use of net.minecraft.entity.attribute.EntityAttributeModifier in project EnvironmentZ by Globox1997.

the class ColdEffect method onApplied.

@Override
public void onApplied(LivingEntity entity, AttributeContainer attributes, int amplifier) {
    EntityAttributeInstance entityAttributeInstance = attributes.getCustomInstance((EntityAttributes.GENERIC_MOVEMENT_SPEED));
    if (entityAttributeInstance != null) {
        EntityAttributeModifier entityAttributeModifier = new EntityAttributeModifier(this.getTranslationKey(), -0.15D, EntityAttributeModifier.Operation.MULTIPLY_TOTAL);
        entityAttributeInstance.removeModifier(entityAttributeModifier);
        entityAttributeInstance.addPersistentModifier(new EntityAttributeModifier(COLDNESS, this.getTranslationKey() + " " + entityAttributeModifier.getValue(), this.adjustModifierAmount(amplifier, entityAttributeModifier), entityAttributeModifier.getOperation()));
    }
}
Also used : EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier) EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance)

Example 2 with EntityAttributeModifier

use of net.minecraft.entity.attribute.EntityAttributeModifier in project EnvironmentZ by Globox1997.

the class OverheatingEffect method onApplied.

@Override
public void onApplied(LivingEntity entity, AttributeContainer attributes, int amplifier) {
    EntityAttributeInstance entityAttributeInstance = attributes.getCustomInstance((EntityAttributes.GENERIC_MOVEMENT_SPEED));
    if (entityAttributeInstance != null) {
        EntityAttributeModifier entityAttributeModifier = new EntityAttributeModifier(this.getTranslationKey(), -0.15D, EntityAttributeModifier.Operation.MULTIPLY_TOTAL);
        entityAttributeInstance.removeModifier(entityAttributeModifier);
        entityAttributeInstance.addPersistentModifier(new EntityAttributeModifier(DEHYDRATION, this.getTranslationKey() + " " + entityAttributeModifier.getValue(), this.adjustModifierAmount(0, entityAttributeModifier), entityAttributeModifier.getOperation()));
    }
}
Also used : EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier) EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance)

Example 3 with EntityAttributeModifier

use of net.minecraft.entity.attribute.EntityAttributeModifier in project bewitchment by MoriyaShiine.

the class ZephyrHarnessItem method getModifiers.

@Override
public Multimap<EntityAttribute, EntityAttributeModifier> getModifiers(ItemStack stack, SlotReference slot, LivingEntity entity, UUID uuid) {
    Multimap<EntityAttribute, EntityAttributeModifier> modifiers = super.getModifiers(stack, slot, entity, uuid);
    modifiers.put(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(uuid, "Trinket modifier", 0.1, EntityAttributeModifier.Operation.ADDITION));
    return modifiers;
}
Also used : EntityAttribute(net.minecraft.entity.attribute.EntityAttribute) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier)

Example 4 with EntityAttributeModifier

use of net.minecraft.entity.attribute.EntityAttributeModifier in project Biome-Makeover by Lemonszz.

the class BMEnchantment method addAttributes.

public boolean addAttributes(LivingEntity entity, ItemStack stack, EquipmentSlot slot, int level) {
    if (attributeModifiers.size() <= 0 || stack.isEmpty())
        return false;
    for (Map.Entry<EntityAttribute, EntityAttributeModifier> attributeEntry : this.attributeModifiers.entrySet()) {
        UUID id = MathUtils.uuidFromString(slot.toString());
        EntityAttributeInstance entityAttributeInstance = entity.getAttributes().getCustomInstance(attributeEntry.getKey());
        if (entityAttributeInstance != null) {
            EntityAttributeModifier mod = attributeEntry.getValue();
            entityAttributeInstance.removeModifier(mod);
            entityAttributeInstance.addTemporaryModifier(new EntityAttributeModifier(id, this.getTranslationKey() + " " + level, this.adjustModifierAmount(level, mod), mod.getOperation()));
        }
    }
    return true;
}
Also used : EntityAttribute(net.minecraft.entity.attribute.EntityAttribute) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier) UUID(java.util.UUID) Map(java.util.Map) EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance)

Example 5 with EntityAttributeModifier

use of net.minecraft.entity.attribute.EntityAttributeModifier in project Biome-Makeover by Lemonszz.

the class BMEnchantment method addAttributeModifier.

protected void addAttributeModifier(EntityAttribute attribute, String uuid, double amount, EntityAttributeModifier.Operation operation) {
    EntityAttributeModifier entityAttributeModifier = new EntityAttributeModifier(UUID.fromString(uuid), this::getTranslationKey, amount, operation);
    this.attributeModifiers.put(attribute, entityAttributeModifier);
}
Also used : EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier)

Aggregations

EntityAttributeModifier (net.minecraft.entity.attribute.EntityAttributeModifier)13 EntityAttribute (net.minecraft.entity.attribute.EntityAttribute)7 EntityAttributeInstance (net.minecraft.entity.attribute.EntityAttributeInstance)5 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)4 Map (java.util.Map)2 UUID (java.util.UUID)2 EquipmentSlot (net.minecraft.entity.EquipmentSlot)1 MutableInt (org.apache.commons.lang3.mutable.MutableInt)1