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