diff --git a/src/main/java/electroblob/wizardry/client/model/WizardryModels.java b/src/main/java/electroblob/wizardry/client/model/WizardryModels.java index f89c73d5..4b6c1991 100644 --- a/src/main/java/electroblob/wizardry/client/model/WizardryModels.java +++ b/src/main/java/electroblob/wizardry/client/model/WizardryModels.java @@ -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); diff --git a/src/main/java/electroblob/wizardry/registry/WizardryItems.java b/src/main/java/electroblob/wizardry/registry/WizardryItems.java index ff04d069..b17f7ceb 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryItems.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryItems.java @@ -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)); diff --git a/src/main/java/electroblob/wizardry/spell/GreaterHeal.java b/src/main/java/electroblob/wizardry/spell/GreaterHeal.java index 9d7055fc..af6c8bc4 100644 --- a/src/main/java/electroblob/wizardry/spell/GreaterHeal.java +++ b/src/main/java/electroblob/wizardry/spell/GreaterHeal.java @@ -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; } diff --git a/src/main/java/electroblob/wizardry/spell/GroupHeal.java b/src/main/java/electroblob/wizardry/spell/GroupHeal.java index 75ec5df3..d0849810 100644 --- a/src/main/java/electroblob/wizardry/spell/GroupHeal.java +++ b/src/main/java/electroblob/wizardry/spell/GroupHeal.java @@ -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); diff --git a/src/main/java/electroblob/wizardry/spell/Heal.java b/src/main/java/electroblob/wizardry/spell/Heal.java index 8bc201da..8baf906b 100644 --- a/src/main/java/electroblob/wizardry/spell/Heal.java +++ b/src/main/java/electroblob/wizardry/spell/Heal.java @@ -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); + } + + } + } diff --git a/src/main/resources/assets/ebwizardry/lang/en_gb.lang b/src/main/resources/assets/ebwizardry/lang/en_gb.lang index e0b79b81..bb57b8fc 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_gb.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_gb.lang @@ -360,6 +360,8 @@ item.ebwizardry\:amulet_resurrection.name=Amulet of the Immortal item.ebwizardry\:amulet_resurrection.desc=The resurrection spell can be used on yourself from beyond the grave item.ebwizardry\:amulet_auto_shield.name=Hyeleth's Amulet item.ebwizardry\:amulet_auto_shield.desc=Grants a 25%% chance to trigger the shield spell for a few seconds when bound to a wand on your hotbar +item.ebwizardry\:amulet_absorption.name=Amulet of Vitality +item.ebwizardry\:amulet_absorption.desc=Excess health from healing spells is converted into absorption hearts item.ebwizardry\:charm_haggler.name=Haggler's Sign item.ebwizardry\:charm_haggler.desc=Wizards are guaranteed to offer a new trade every time you trade with them diff --git a/src/main/resources/assets/ebwizardry/lang/en_us.lang b/src/main/resources/assets/ebwizardry/lang/en_us.lang index 7ebc10b5..16f3ccdc 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_us.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_us.lang @@ -360,6 +360,8 @@ item.ebwizardry\:amulet_resurrection.name=Amulet of the Immortal item.ebwizardry\:amulet_resurrection.desc=The resurrection spell can be used on yourself from beyond the grave item.ebwizardry\:amulet_auto_shield.name=Hyeleth's Amulet item.ebwizardry\:amulet_auto_shield.desc=Grants a 25%% chance to trigger the shield spell for a few seconds when bound to a wand on your hotbar +item.ebwizardry\:amulet_absorption.name=Amulet of Vitality +item.ebwizardry\:amulet_absorption.desc=Excess health from healing spells is converted into absorption hearts item.ebwizardry\:charm_haggler.name=Haggler's Sign item.ebwizardry\:charm_haggler.desc=Wizards are guaranteed to offer a new trade every time you trade with them diff --git a/src/main/resources/assets/ebwizardry/models/item/amulet_absorption.json b/src/main/resources/assets/ebwizardry/models/item/amulet_absorption.json new file mode 100644 index 00000000..e9d56323 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/models/item/amulet_absorption.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "ebwizardry:items/amulet_absorption" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/textures/items/amulet_absorption.png b/src/main/resources/assets/ebwizardry/textures/items/amulet_absorption.png new file mode 100644 index 00000000..1a81b45c Binary files /dev/null and b/src/main/resources/assets/ebwizardry/textures/items/amulet_absorption.png differ