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
@@ -276,6 +276,7 @@ public final class WizardryModels {
registerItemModel(WizardryItems.amulet_transience);
registerItemModel(WizardryItems.amulet_resurrection);
registerItemModel(WizardryItems.amulet_auto_shield);
registerItemModel(WizardryItems.amulet_absorption);
registerItemModel(WizardryItems.charm_haggler);
registerItemModel(WizardryItems.charm_experience_tome);
@@ -261,6 +261,7 @@ public final class WizardryItems {
public static final Item amulet_transience = placeholder();
public static final Item amulet_resurrection = placeholder();
public static final Item amulet_auto_shield = placeholder();
public static final Item amulet_absorption = placeholder();
public static final Item charm_haggler = placeholder();
public static final Item charm_experience_tome = placeholder();
@@ -620,6 +621,7 @@ public final class WizardryItems {
registerItem(registry, "amulet_transience", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.AMULET));
registerItem(registry, "amulet_resurrection", new ItemArtefact(EnumRarity.EPIC, ItemArtefact.Type.AMULET));
registerItem(registry, "amulet_auto_shield", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.AMULET));
registerItem(registry, "amulet_absorption", new ItemArtefact(EnumRarity.EPIC, ItemArtefact.Type.AMULET));
registerItem(registry, "charm_haggler", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.CHARM));
registerItem(registry, "charm_experience_tome", new ItemArtefact(EnumRarity.EPIC, ItemArtefact.Type.CHARM));
@@ -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);
}
}
}