Add amulet of vitality

This commit is contained in:
Electroblob77
2020-06-02 23:41:16 +01:00
parent 930ad77db5
commit b4fc50ad71
9 changed files with 39 additions and 3 deletions
@@ -15,7 +15,7 @@ public class GreaterHeal extends SpellBuff {
protected boolean applyEffects(EntityLivingBase caster, SpellModifiers modifiers){
if(caster.getHealth() < caster.getMaxHealth() && caster.getHealth() > 0){
caster.heal(getProperty(HEALTH).floatValue() * modifiers.get(SpellModifiers.POTENCY));
Heal.heal(caster, getProperty(HEALTH).floatValue() * modifiers.get(SpellModifiers.POTENCY));
return true;
}
@@ -35,7 +35,7 @@ public class GroupHeal extends Spell {
if(target.getHealth() < target.getMaxHealth() && target.getHealth() > 0){
target.heal(getProperty(HEALTH).floatValue() * modifiers.get(SpellModifiers.POTENCY));
Heal.heal(target, getProperty(HEALTH).floatValue() * modifiers.get(SpellModifiers.POTENCY));
if(world.isRemote) ParticleBuilder.spawnHealParticles(world, target);
playSound(world, target, ticksInUse, -1, modifiers);
@@ -1,7 +1,10 @@
package electroblob.wizardry.spell;
import electroblob.wizardry.item.ItemArtefact;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.util.SpellModifiers;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
public class Heal extends SpellBuff {
@@ -15,11 +18,31 @@ public class Heal extends SpellBuff {
protected boolean applyEffects(EntityLivingBase caster, SpellModifiers modifiers){
if(caster.getHealth() < caster.getMaxHealth() && caster.getHealth() > 0){
caster.heal(getProperty(HEALTH).floatValue() * modifiers.get(SpellModifiers.POTENCY));
heal(caster, getProperty(HEALTH).floatValue() * modifiers.get(SpellModifiers.POTENCY));
return true;
}
return false;
}
/**
* Heals the given entity by the given amount, accounting for special behaviour from artefacts. This does not check
* whether the entity is already on full health or not.
* @param entity The entity to heal
* @param health The number of half-hearts to heal
*/
public static void heal(EntityLivingBase entity, float health){
float excessHealth = entity.getHealth() + health - entity.getMaxHealth();
entity.heal(health);
// If the player is able to heal, they can't possibly have absorption hearts, so no need to check!
if(excessHealth > 0 && entity instanceof EntityPlayer
&& ItemArtefact.isArtefactActive((EntityPlayer)entity, WizardryItems.amulet_absorption)){
entity.setAbsorptionAmount(excessHealth);
}
}
}