Add amulet of vitality
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user