Search in sources :

Example 6 with EntityAttributeModifier

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

the class EntityUtil method applyProjectileResistance.

public static void applyProjectileResistance(Iterable<ItemStack> equipment, MutableInt resistance) {
    MutableInt slotIndex = new MutableInt(0);
    equipment.forEach(e -> {
        if (!e.isEmpty()) {
            EquipmentSlot slot = EquipmentSlot.values()[2 + slotIndex.getValue()];
            if (e.getAttributeModifiers(slot).containsKey(BMEntities.ATT_PROJECTILE_RESISTANCE)) {
                Collection<EntityAttributeModifier> modifiers = e.getAttributeModifiers(slot).get(BMEntities.ATT_PROJECTILE_RESISTANCE);
                for (EntityAttributeModifier mod : modifiers) {
                    resistance.add(mod.getValue());
                }
            }
        }
        slotIndex.add(1);
    });
}
Also used : MutableInt(org.apache.commons.lang3.mutable.MutableInt) EquipmentSlot(net.minecraft.entity.EquipmentSlot) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier)

Example 7 with EntityAttributeModifier

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

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

use of net.minecraft.entity.attribute.EntityAttributeModifier in project Terracraft by SimplyCmd.

the class LifeCrystalBlockItem method use.

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
    if (user.getAttributeValue(EntityAttributes.GENERIC_MAX_HEALTH) < 40) {
        final EntityAttributeInstance health = Objects.requireNonNull(user.getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH));
        final double value = user.getAttributeValue(EntityAttributes.GENERIC_MAX_HEALTH) - 10;
        health.removeModifier(uuid);
        health.addPersistentModifier(new EntityAttributeModifier(uuid, "life", value + 2, EntityAttributeModifier.Operation.ADDITION));
        user.heal(2);
        user.getStackInHand(hand).decrement(1);
        return TypedActionResult.consume(user.getStackInHand(hand));
    }
    return TypedActionResult.pass(user.getStackInHand(hand));
}
Also used : EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier) EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance)

Example 10 with EntityAttributeModifier

use of net.minecraft.entity.attribute.EntityAttributeModifier in project MCDoom by AzureDoom.

the class DaisyItem method getModifiers.

public Multimap<EntityAttribute, EntityAttributeModifier> getModifiers(ItemStack stack, SlotReference slot, LivingEntity entity, UUID uuid) {
    var modifiers = super.getModifiers(stack, slot, entity, uuid);
    modifiers.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(uuid, DoomMod.MODID + ":movement_speed", 2.0, EntityAttributeModifier.Operation.MULTIPLY_TOTAL));
    SlotAttributes.addSlotModifier(modifiers, "legs/belt", uuid, 1, EntityAttributeModifier.Operation.ADDITION);
    return modifiers;
}
Also used : EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier)

Aggregations

EntityAttributeModifier (net.minecraft.entity.attribute.EntityAttributeModifier)16 EntityAttribute (net.minecraft.entity.attribute.EntityAttribute)8 EntityAttributeInstance (net.minecraft.entity.attribute.EntityAttributeInstance)7 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)4 Map (java.util.Map)2 UUID (java.util.UUID)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 IServerPlayerEntity (de.siphalor.spiceoffabric.util.IServerPlayerEntity)1 EquipmentSlot (net.minecraft.entity.EquipmentSlot)1 ItemStack (net.minecraft.item.ItemStack)1 MutableInt (org.apache.commons.lang3.mutable.MutableInt)1