From d63093d62766c1af197ae1fa19e1d29c1158bd8a Mon Sep 17 00:00:00 2001 From: Aria Sangarin Date: Tue, 10 Mar 2020 00:17:29 +0100 Subject: [PATCH] Fixed Ice Spikes ability + upgraded it's targeting --- .../net/Indyuce/mmocore/skill/Ice_Spikes.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/skill/Ice_Spikes.java b/src/main/java/net/Indyuce/mmocore/skill/Ice_Spikes.java index e48a8d6f..961f3a58 100644 --- a/src/main/java/net/Indyuce/mmocore/skill/Ice_Spikes.java +++ b/src/main/java/net/Indyuce/mmocore/skill/Ice_Spikes.java @@ -1,8 +1,10 @@ package net.Indyuce.mmocore.skill; +import org.bukkit.FluidCollisionMode; import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.Sound; +import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.potion.PotionEffect; @@ -41,16 +43,22 @@ public class Ice_Spikes extends Skill { @Override public SkillResult whenCast(PlayerData data, SkillInfo skill) { IceSpikesCast cast = new IceSpikesCast(data, skill); - if (!cast.isSuccessful()) + if (!cast.isSuccessful() || cast.loc == null) return cast; - - Location loc = cast.loc.getHitBlock().getLocation(); + + Location loc; + Block hitBlock = cast.loc.getHitBlock(); + if (hitBlock == null) { + Entity hitEntity = cast.loc.getHitEntity(); + if(hitEntity == null) return cast; + else loc = hitEntity.getLocation(); + } + else loc = hitBlock.getLocation(); double damage = cast.getModifier("damage"); int slow = (int) (20 * cast.getModifier("slow")); new BukkitRunnable() { - int j = 0; @Override @@ -86,9 +94,10 @@ public class Ice_Spikes extends Skill { public IceSpikesCast(PlayerData data, SkillInfo skill) { super(data, skill); - if (isSuccessful() && (loc = data.getPlayer().getWorld().rayTraceEntities(data.getPlayer().getEyeLocation(), - data.getPlayer().getEyeLocation().getDirection(), 30, (entity) -> MMOCoreUtils.canTarget(data.getPlayer(), entity))) == null) - abort(); + if (!isSuccessful()) abort(); + + loc = data.getPlayer().getWorld().rayTrace(data.getPlayer().getEyeLocation(), data.getPlayer().getEyeLocation().getDirection(), + 30, FluidCollisionMode.ALWAYS, true, 1.0D, (entity) -> MMOCoreUtils.canTarget(data.getPlayer(), entity)); } } }