From b4fc50ad719235f1ef541622a634cdf48a41371d Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:41:16 +0100 Subject: [PATCH] Add amulet of vitality --- .../wizardry/client/model/WizardryModels.java | 1 + .../wizardry/registry/WizardryItems.java | 2 ++ .../wizardry/spell/GreaterHeal.java | 2 +- .../electroblob/wizardry/spell/GroupHeal.java | 2 +- .../java/electroblob/wizardry/spell/Heal.java | 25 +++++++++++++++++- .../assets/ebwizardry/lang/en_gb.lang | 2 ++ .../assets/ebwizardry/lang/en_us.lang | 2 ++ .../models/item/amulet_absorption.json | 6 +++++ .../textures/items/amulet_absorption.png | Bin 0 -> 6301 bytes 9 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/assets/ebwizardry/models/item/amulet_absorption.json create mode 100644 src/main/resources/assets/ebwizardry/textures/items/amulet_absorption.png 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/amul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