Search in sources :

Example 1 with EntityAttributeInstance

use of net.minecraft.entity.attribute.EntityAttributeInstance 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 EntityAttributeInstance

use of net.minecraft.entity.attribute.EntityAttributeInstance 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 EntityAttributeInstance

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

the class PlayerEntityMixin method tick.

@Inject(method = "tick", at = @At("TAIL"))
private void tick(CallbackInfo callbackInfo) {
    if (!world.isClient) {
        boolean shouldHave = BewitchmentAPI.getFamiliar((PlayerEntity) (Object) this) == EntityType.WOLF;
        EntityAttributeInstance armorAttribute = getAttributeInstance(EntityAttributes.GENERIC_ARMOR);
        EntityAttributeInstance armorToughnessAttribute = getAttributeInstance(EntityAttributes.GENERIC_ARMOR_TOUGHNESS);
        if (shouldHave && !armorAttribute.hasModifier(WOLF_FAMILIAR_ARMOR_MODIFIER)) {
            armorAttribute.addPersistentModifier(WOLF_FAMILIAR_ARMOR_MODIFIER);
            armorToughnessAttribute.addPersistentModifier(WOLF_FAMILIAR_ARMOR_TOUGHNESS_MODIFIER);
        } else if (!shouldHave && armorAttribute.hasModifier(WOLF_FAMILIAR_ARMOR_MODIFIER)) {
            armorAttribute.removeModifier(WOLF_FAMILIAR_ARMOR_MODIFIER);
            armorToughnessAttribute.removeModifier(WOLF_FAMILIAR_ARMOR_TOUGHNESS_MODIFIER);
        }
    }
}
Also used : EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with EntityAttributeInstance

use of net.minecraft.entity.attribute.EntityAttributeInstance 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 EntityAttributeInstance

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

the class WitchEntityMixin method tickMovement.

@Inject(at = @At("TAIL"), method = "tickMovement")
public void tickMovement(CallbackInfo cbi) {
    if (!isDrinking()) {
        if (random.nextFloat() < 0.10) {
            boolean found = false;
            for (StatusEffectInstance effect : getStatusEffects()) if (((StatusEffectAccess) effect.getEffectType()).bm_getType() == StatusEffectType.HARMFUL) {
                found = true;
                break;
            }
            if (found) {
                this.equipStack(EquipmentSlot.MAINHAND, PotionUtil.setPotion(new ItemStack(Items.POTION), BMPotions.ANTIDOTE_POT));
                this.drinkTimeLeft = this.getMainHandStack().getMaxUseTime();
                this.setDrinking(true);
                if (!this.isSilent()) {
                    this.world.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F, 0.8F + this.random.nextFloat() * 0.4F);
                }
                EntityAttributeInstance entityAttributeInstance = this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED);
                entityAttributeInstance.removeModifier(DRINKING_SPEED_PENALTY_MODIFIER);
                entityAttributeInstance.addTemporaryModifier(DRINKING_SPEED_PENALTY_MODIFIER);
            }
        }
    }
}
Also used : StatusEffectAccess(party.lemons.biomemakeover.util.access.StatusEffectAccess) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ItemStack(net.minecraft.item.ItemStack) EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

EntityAttributeInstance (net.minecraft.entity.attribute.EntityAttributeInstance)12 EntityAttributeModifier (net.minecraft.entity.attribute.EntityAttributeModifier)5 Map (java.util.Map)2 UUID (java.util.UUID)2 EntityAttribute (net.minecraft.entity.attribute.EntityAttribute)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 Entity (net.minecraft.entity.Entity)1 ExperienceOrbEntity (net.minecraft.entity.ExperienceOrbEntity)1 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)1 MobEntity (net.minecraft.entity.mob.MobEntity)1 AnimalEntity (net.minecraft.entity.passive.AnimalEntity)1 PassiveEntity (net.minecraft.entity.passive.PassiveEntity)1 ItemStack (net.minecraft.item.ItemStack)1 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)1 StatusEffectAccess (party.lemons.biomemakeover.util.access.StatusEffectAccess)1