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);
});
}
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);
}
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);
}
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));
}
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;
}
Aggregations