From 61634a9cc36f123be8d1c982b1e951bda3e3aac3 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Tue, 1 Feb 2022 18:23:47 +0000 Subject: [PATCH] Change resurrection wait time and add particles to indicate where an ally died --- .../wizardry/spell/Resurrection.java | 46 ++++++++++++++++++- .../ebwizardry/spells/resurrection.json | 2 +- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/main/java/electroblob/wizardry/spell/Resurrection.java b/src/main/java/electroblob/wizardry/spell/Resurrection.java index f5511d56..383f306e 100644 --- a/src/main/java/electroblob/wizardry/spell/Resurrection.java +++ b/src/main/java/electroblob/wizardry/spell/Resurrection.java @@ -1,5 +1,6 @@ package electroblob.wizardry.spell; +import electroblob.wizardry.Wizardry; import electroblob.wizardry.data.WizardData; import electroblob.wizardry.item.ISpellCastingItem; import electroblob.wizardry.item.SpellActions; @@ -8,6 +9,7 @@ import electroblob.wizardry.packet.WizardryPacketHandler; import electroblob.wizardry.registry.Spells; import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.util.ParticleBuilder; +import electroblob.wizardry.util.ParticleBuilder.Type; import electroblob.wizardry.util.SpellModifiers; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -16,11 +18,15 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import java.util.Arrays; import java.util.Comparator; +@EventBusSubscriber public class Resurrection extends Spell { public static final String WAIT_TIME = "wait_time"; @@ -112,4 +118,42 @@ public class Resurrection extends Spell { && ((ISpellCastingItem)stack.getItem()).canCast(stack, Spells.resurrection, player, EnumHand.MAIN_HAND, 0, new SpellModifiers()); } -} + @SubscribeEvent + public static void onPlayerTickEvent(LivingUpdateEvent event){ + + if(event.getEntity() instanceof EntityPlayer){ + + EntityPlayer player = (EntityPlayer)event.getEntity(); + + if(player.world.isRemote && !player.isEntityAlive()){ + + EntityPlayer firstPersonPlayer = Wizardry.proxy.getThePlayer(); + + if(WizardData.get(firstPersonPlayer).isPlayerAlly(player)){ + + ItemStack wand = firstPersonPlayer.getHeldItemMainhand(); + + if(!(wand.getItem() instanceof ISpellCastingItem)){ + wand = firstPersonPlayer.getHeldItemOffhand(); + if(!(wand.getItem() instanceof ISpellCastingItem)) return; + } + + if(((ISpellCastingItem)wand.getItem()).getCurrentSpell(wand) == Spells.resurrection){ + + // TODO: Find some way of getting at the modifiers before the spell is cast + int waitTime = Spells.resurrection.getProperty(WAIT_TIME).intValue(); + + if(player.deathTime > waitTime){ + ParticleBuilder.create(Type.SPARKLE, player.world.rand, player.posX, player.posY + 0.5, player.posZ, 0.5, false) + .clr(1, 1, 0.3f).vel(0, 0.02, 0).spawn(player.world); + }else{ + ParticleBuilder.create(Type.DUST, player.world.rand, player.posX, player.posY + 0.5, player.posZ, 0.5, false) + .clr(1, 1, 0.3f).vel(0, 0.02, 0).time(50).spawn(player.world); + } + } + } + } + } + } + +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/spells/resurrection.json b/src/main/resources/assets/ebwizardry/spells/resurrection.json index d9124f5f..c0cd0bf1 100644 --- a/src/main/resources/assets/ebwizardry/spells/resurrection.json +++ b/src/main/resources/assets/ebwizardry/spells/resurrection.json @@ -18,6 +18,6 @@ "cooldown": 400, "base_properties": { "effect_radius": 8, - "wait_time": 300 + "wait_time": 200 } } \ No newline at end of file