Search in sources :

Example 6 with EntityAttributeInstance

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

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

the class OwlEntity method setTamed.

@Override
public void setTamed(boolean tamed) {
    super.setTamed(tamed);
    EntityAttributeInstance maxHealth = getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH);
    EntityAttributeInstance attackDamage = getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE);
    if (tamed) {
        maxHealth.setBaseValue(20);
        attackDamage.setBaseValue(3);
        setHealth(getMaxHealth());
    } else {
        maxHealth.setBaseValue(8);
        attackDamage.setBaseValue(1);
    }
}
Also used : EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance)

Example 8 with EntityAttributeInstance

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

the class RavenEntity method setTamed.

@Override
public void setTamed(boolean tamed) {
    super.setTamed(tamed);
    EntityAttributeInstance maxHealth = getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH);
    EntityAttributeInstance attackDamage = getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE);
    if (tamed) {
        maxHealth.setBaseValue(20);
        attackDamage.setBaseValue(3);
        setHealth(getMaxHealth());
    } else {
        maxHealth.setBaseValue(8);
        attackDamage.setBaseValue(1);
    }
}
Also used : EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance)

Example 9 with EntityAttributeInstance

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

the class ToadEntity method setTamed.

@Override
public void setTamed(boolean tamed) {
    super.setTamed(tamed);
    EntityAttributeInstance maxHealth = getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH);
    if (tamed) {
        maxHealth.setBaseValue(20);
        setHealth(getMaxHealth());
    } else {
        maxHealth.setBaseValue(8);
    }
}
Also used : EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance)

Example 10 with EntityAttributeInstance

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

the class TransformationComponent method updateAttributes.

@SuppressWarnings("ConstantConditions")
public void updateAttributes() {
    boolean vampire = BewitchmentAPI.isVampire(obj, true);
    boolean werewolfBeast = BewitchmentAPI.isWerewolf(obj, false);
    EntityAttributeInstance attackDamageAttribute = obj.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE);
    EntityAttributeInstance attackSpeedAttribute = obj.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_SPEED);
    EntityAttributeInstance armorAttribute = obj.getAttributeInstance(EntityAttributes.GENERIC_ARMOR);
    EntityAttributeInstance armorToughnessAttribute = obj.getAttributeInstance(EntityAttributes.GENERIC_ARMOR_TOUGHNESS);
    EntityAttributeInstance movementSpeedAttribute = obj.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED);
    EntityAttributeInstance attackRange = obj.getAttributeInstance(ReachEntityAttributes.ATTACK_RANGE);
    EntityAttributeInstance reach = obj.getAttributeInstance(ReachEntityAttributes.REACH);
    EntityAttributeInstance stepHeight = obj.getAttributeInstance(StepHeightEntityAttributeMain.STEP_HEIGHT);
    boolean shouldHave = vampire && !BewitchmentAPI.isPledged(obj, BWPledges.LILITH);
    if (shouldHave && !attackDamageAttribute.hasModifier(VAMPIRE_ATTACK_DAMAGE_MODIFIER_0)) {
        attackDamageAttribute.addPersistentModifier(VAMPIRE_ATTACK_DAMAGE_MODIFIER_0);
        movementSpeedAttribute.addPersistentModifier(VAMPIRE_MOVEMENT_SPEED_MODIFIER_0);
    } else if (!shouldHave && attackDamageAttribute.hasModifier(VAMPIRE_ATTACK_DAMAGE_MODIFIER_0)) {
        attackDamageAttribute.removeModifier(VAMPIRE_ATTACK_DAMAGE_MODIFIER_0);
        movementSpeedAttribute.removeModifier(VAMPIRE_MOVEMENT_SPEED_MODIFIER_0);
    }
    shouldHave = vampire && BewitchmentAPI.isPledged(obj, BWPledges.LILITH);
    if (shouldHave && !attackDamageAttribute.hasModifier(VAMPIRE_ATTACK_DAMAGE_MODIFIER_1)) {
        attackDamageAttribute.addPersistentModifier(VAMPIRE_ATTACK_DAMAGE_MODIFIER_1);
        movementSpeedAttribute.addPersistentModifier(VAMPIRE_MOVEMENT_SPEED_MODIFIER_1);
    } else if (!shouldHave && attackDamageAttribute.hasModifier(VAMPIRE_ATTACK_DAMAGE_MODIFIER_1)) {
        attackDamageAttribute.removeModifier(VAMPIRE_ATTACK_DAMAGE_MODIFIER_1);
        movementSpeedAttribute.removeModifier(VAMPIRE_MOVEMENT_SPEED_MODIFIER_1);
    }
    shouldHave = werewolfBeast;
    if (shouldHave && !attackSpeedAttribute.hasModifier(WEREWOLF_ATTACK_SPEED_MODIFIER)) {
        attackSpeedAttribute.addPersistentModifier(WEREWOLF_ATTACK_SPEED_MODIFIER);
        armorAttribute.addPersistentModifier(WEREWOLF_ARMOR_MODIFIER);
        attackRange.addPersistentModifier(WEREWOLF_ATTACK_RANGE_MODIFIER);
        reach.addPersistentModifier(WEREWOLF_REACH_MODIFIER);
        stepHeight.addPersistentModifier(WEREWOLF_STEP_HEIGHT_MODIFIER);
    } else if (!shouldHave && attackSpeedAttribute.hasModifier(WEREWOLF_ATTACK_SPEED_MODIFIER)) {
        attackSpeedAttribute.removeModifier(WEREWOLF_ATTACK_SPEED_MODIFIER);
        armorAttribute.removeModifier(WEREWOLF_ARMOR_MODIFIER);
        attackRange.removeModifier(WEREWOLF_ATTACK_RANGE_MODIFIER);
        reach.removeModifier(WEREWOLF_REACH_MODIFIER);
        stepHeight.removeModifier(WEREWOLF_STEP_HEIGHT_MODIFIER);
    }
    shouldHave = werewolfBeast && !BewitchmentAPI.isPledged(obj, BWPledges.HERNE);
    if (shouldHave && !attackDamageAttribute.hasModifier(WEREWOLF_ATTACK_DAMAGE_MODIFIER_0)) {
        attackDamageAttribute.addPersistentModifier(WEREWOLF_ATTACK_DAMAGE_MODIFIER_0);
        armorToughnessAttribute.addPersistentModifier(WEREWOLF_ARMOR_TOUGHNESS_MODIFIER_0);
        movementSpeedAttribute.addPersistentModifier(WEREWOLF_MOVEMENT_SPEED_MODIFIER_0);
    } else if (!shouldHave && attackDamageAttribute.hasModifier(WEREWOLF_ATTACK_DAMAGE_MODIFIER_0)) {
        attackDamageAttribute.removeModifier(WEREWOLF_ATTACK_DAMAGE_MODIFIER_0);
        armorToughnessAttribute.removeModifier(WEREWOLF_ARMOR_TOUGHNESS_MODIFIER_0);
        movementSpeedAttribute.removeModifier(WEREWOLF_MOVEMENT_SPEED_MODIFIER_0);
    }
    shouldHave = werewolfBeast && BewitchmentAPI.isPledged(obj, BWPledges.HERNE);
    if (shouldHave && !attackDamageAttribute.hasModifier(WEREWOLF_ATTACK_DAMAGE_MODIFIER_1)) {
        attackDamageAttribute.addPersistentModifier(WEREWOLF_ATTACK_DAMAGE_MODIFIER_1);
        armorToughnessAttribute.addPersistentModifier(WEREWOLF_ARMOR_TOUGHNESS_MODIFIER_1);
        movementSpeedAttribute.addPersistentModifier(WEREWOLF_MOVEMENT_SPEED_MODIFIER_1);
    } else if (!shouldHave && attackDamageAttribute.hasModifier(WEREWOLF_ATTACK_DAMAGE_MODIFIER_1)) {
        attackDamageAttribute.removeModifier(WEREWOLF_ATTACK_DAMAGE_MODIFIER_1);
        armorToughnessAttribute.removeModifier(WEREWOLF_ARMOR_TOUGHNESS_MODIFIER_1);
        movementSpeedAttribute.removeModifier(WEREWOLF_MOVEMENT_SPEED_MODIFIER_1);
    }
}
Also used : EntityAttributeInstance(net.minecraft.entity.attribute.EntityAttributeInstance)

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