Fixed Ice Spikes ability + upgraded it's targeting

This commit is contained in:
Aria Sangarin 2020-03-10 00:17:29 +01:00
parent 09d770ff4f
commit d63093d627

View File

@ -1,8 +1,10 @@
package net.Indyuce.mmocore.skill; package net.Indyuce.mmocore.skill;
import org.bukkit.FluidCollisionMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -41,16 +43,22 @@ public class Ice_Spikes extends Skill {
@Override @Override
public SkillResult whenCast(PlayerData data, SkillInfo skill) { public SkillResult whenCast(PlayerData data, SkillInfo skill) {
IceSpikesCast cast = new IceSpikesCast(data, skill); IceSpikesCast cast = new IceSpikesCast(data, skill);
if (!cast.isSuccessful()) if (!cast.isSuccessful() || cast.loc == null)
return cast; 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"); double damage = cast.getModifier("damage");
int slow = (int) (20 * cast.getModifier("slow")); int slow = (int) (20 * cast.getModifier("slow"));
new BukkitRunnable() { new BukkitRunnable() {
int j = 0; int j = 0;
@Override @Override
@ -86,9 +94,10 @@ public class Ice_Spikes extends Skill {
public IceSpikesCast(PlayerData data, SkillInfo skill) { public IceSpikesCast(PlayerData data, SkillInfo skill) {
super(data, skill); super(data, skill);
if (isSuccessful() && (loc = data.getPlayer().getWorld().rayTraceEntities(data.getPlayer().getEyeLocation(), if (!isSuccessful()) abort();
data.getPlayer().getEyeLocation().getDirection(), 30, (entity) -> MMOCoreUtils.canTarget(data.getPlayer(), entity))) == null)
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));
} }
} }
} }