From 2b89a890d0835a43abc4bf4d121a5e09415496c0 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Mon, 16 Dec 2019 15:25:15 +0000 Subject: [PATCH] Route blink effect through the proxies and make the blink spell check for the first-person player, fixes #280 --- src/main/java/electroblob/wizardry/CommonProxy.java | 4 ++++ src/main/java/electroblob/wizardry/client/ClientProxy.java | 5 +++++ src/main/java/electroblob/wizardry/spell/Banish.java | 6 +++--- src/main/java/electroblob/wizardry/spell/Blink.java | 6 +++--- src/main/java/electroblob/wizardry/spell/PhaseStep.java | 3 +-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/electroblob/wizardry/CommonProxy.java b/src/main/java/electroblob/wizardry/CommonProxy.java index 71165cc2..74682ce4 100644 --- a/src/main/java/electroblob/wizardry/CommonProxy.java +++ b/src/main/java/electroblob/wizardry/CommonProxy.java @@ -7,6 +7,7 @@ import electroblob.wizardry.spell.Spell; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; @@ -238,6 +239,9 @@ public class CommonProxy { + "of sound events, but the given array contained less than 3 sound events!"); playSpellSoundLoop(world, x, y, z, spell, sounds[0], sounds[1], sounds[2], category, volume, pitch, duration); } + + /** Starts the first-person blink overlay effect for the specified player. */ + public void playBlinkEffect(EntityPlayer player){} /** * Gets the client side world using Minecraft.getMinecraft().world. Only to be called client side! Returns diff --git a/src/main/java/electroblob/wizardry/client/ClientProxy.java b/src/main/java/electroblob/wizardry/client/ClientProxy.java index b5d75afb..3fcbc428 100644 --- a/src/main/java/electroblob/wizardry/client/ClientProxy.java +++ b/src/main/java/electroblob/wizardry/client/ClientProxy.java @@ -190,6 +190,11 @@ public class ClientProxy extends CommonProxy { } } + @Override + public void playBlinkEffect(EntityPlayer player){ + if(Minecraft.getMinecraft().player == player) WizardryClientEventHandler.playBlinkEffect(); + } + @Override public Set getSpellHUDSkins(){ return GuiSpellDisplay.getSkinKeys(); diff --git a/src/main/java/electroblob/wizardry/spell/Banish.java b/src/main/java/electroblob/wizardry/spell/Banish.java index 9777892f..e12fe1ff 100644 --- a/src/main/java/electroblob/wizardry/spell/Banish.java +++ b/src/main/java/electroblob/wizardry/spell/Banish.java @@ -1,5 +1,6 @@ package electroblob.wizardry.spell; +import electroblob.wizardry.Wizardry; import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.util.ParticleBuilder; import electroblob.wizardry.util.ParticleBuilder.Type; @@ -7,6 +8,7 @@ import electroblob.wizardry.util.SpellModifiers; import electroblob.wizardry.util.WizardryUtilities; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; @@ -78,9 +80,7 @@ public class Banish extends SpellRay { world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); } - // Can't be bothered to route this through the proxies! - if(entity == net.minecraft.client.Minecraft.getMinecraft().player) - electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect(); + if(entity instanceof EntityPlayer) Wizardry.proxy.playBlinkEffect((EntityPlayer)entity); } if(y != null){ diff --git a/src/main/java/electroblob/wizardry/spell/Blink.java b/src/main/java/electroblob/wizardry/spell/Blink.java index f6adf784..ce8cf619 100644 --- a/src/main/java/electroblob/wizardry/spell/Blink.java +++ b/src/main/java/electroblob/wizardry/spell/Blink.java @@ -1,5 +1,6 @@ package electroblob.wizardry.spell; +import electroblob.wizardry.Wizardry; import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.util.RayTracer; import electroblob.wizardry.util.SpellModifiers; @@ -41,9 +42,8 @@ public class Blink extends Spell { world.spawnParticle(EnumParticleTypes.PORTAL, dx, dy, dz, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); } - - // Can't be bothered to route this through the proxies! - electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect(); + + Wizardry.proxy.playBlinkEffect(caster); } if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){ diff --git a/src/main/java/electroblob/wizardry/spell/PhaseStep.java b/src/main/java/electroblob/wizardry/spell/PhaseStep.java index 18926341..9f21eac8 100644 --- a/src/main/java/electroblob/wizardry/spell/PhaseStep.java +++ b/src/main/java/electroblob/wizardry/spell/PhaseStep.java @@ -43,8 +43,7 @@ public class PhaseStep extends Spell { world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5); } - // Can't be bothered to route this through the proxies! - electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect(); + Wizardry.proxy.playBlinkEffect(caster); } if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){