Search in sources :

Example 1 with EntityAttribute

use of net.minecraft.entity.attribute.EntityAttribute 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 2 with EntityAttribute

use of net.minecraft.entity.attribute.EntityAttribute 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 3 with EntityAttribute

use of net.minecraft.entity.attribute.EntityAttribute in project artifality by PinkGoosik.

the class WrathElement method onInit.

@Override
public void onInit(LivingEntity entity, World world) {
    Multimap<EntityAttribute, EntityAttributeModifier> attributes;
    ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder();
    builder.put(EntityAttributes.GENERIC_MAX_HEALTH, new EntityAttributeModifier("Element modifier", 15, EntityAttributeModifier.Operation.ADDITION));
    attributes = builder.build();
    entity.getAttributes().addTemporaryModifiers(attributes);
    entity.heal(15);
}
Also used : EntityAttribute(net.minecraft.entity.attribute.EntityAttribute) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier)

Example 4 with EntityAttribute

use of net.minecraft.entity.attribute.EntityAttribute in project artifality by PinkGoosik.

the class IncrementalElement method onInit.

@Override
public void onInit(LivingEntity entity, World world) {
    Multimap<EntityAttribute, EntityAttributeModifier> attributes;
    ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder();
    builder.put(EntityAttributes.GENERIC_MAX_HEALTH, new EntityAttributeModifier("Element modifier", 15, EntityAttributeModifier.Operation.ADDITION));
    attributes = builder.build();
    entity.getAttributes().addTemporaryModifiers(attributes);
    entity.heal(15);
}
Also used : EntityAttribute(net.minecraft.entity.attribute.EntityAttribute) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier)

Example 5 with EntityAttribute

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

the class BMEnchantment method removeAttributes.

public void removeAttributes(LivingEntity entity, EquipmentSlot slot) {
    for (Map.Entry<EntityAttribute, EntityAttributeModifier> attributeEntry : this.attributeModifiers.entrySet()) {
        UUID slotID = MathUtils.uuidFromString(slot.toString());
        EntityAttributeInstance entityAttributeInstance = entity.getAttributes().getCustomInstance(attributeEntry.getKey());
        if (entityAttributeInstance != null) {
            EntityAttributeModifier mod = entityAttributeInstance.getModifier(slotID);
            if (mod != null)
                entityAttributeInstance.removeModifier(mod);
            else
                System.out.println("ERROR REMOVING MODIFIER: DOESNT EXIST??? : " + entityAttributeInstance.getAttribute().getTranslationKey());
        }
    }
}
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)

Aggregations

EntityAttribute (net.minecraft.entity.attribute.EntityAttribute)7 EntityAttributeModifier (net.minecraft.entity.attribute.EntityAttributeModifier)7 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)4 Map (java.util.Map)2 UUID (java.util.UUID)2 EntityAttributeInstance (net.minecraft.entity.attribute.EntityAttributeInstance)2