From 85b5eee92f8a33425c737d1657e8dfac1b2fe085 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sat, 4 Mar 2017 00:40:53 -0300 Subject: [PATCH] Fixed the rainbow taunt --- .../gadget/gadgets/taunts/RainbowTaunt.java | 9 ++++++ .../particleeffects/RainbowTauntEffect.java | 30 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java index 16e94cd67..70e8000b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java @@ -1,5 +1,8 @@ package mineplex.core.gadget.gadgets.taunts; +import java.util.HashSet; + +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -8,6 +11,7 @@ import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.TauntGadget; +import mineplex.core.particleeffects.EffectLocation; import mineplex.core.particleeffects.RainbowTauntEffect; import mineplex.core.recharge.Recharge; @@ -32,7 +36,12 @@ public class RainbowTaunt extends TauntGadget if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) return; + HashSet ignore = new HashSet<>(); + ignore.add(Material.AIR); + Location loc = player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5); + RainbowTauntEffect rainbowTauntEffect = new RainbowTauntEffect(player, Manager.getPlugin()); + rainbowTauntEffect.setTargetLocation(new EffectLocation(loc)); rainbowTauntEffect.start(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTauntEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTauntEffect.java index 5875ea06c..886bc3aef 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTauntEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTauntEffect.java @@ -37,7 +37,7 @@ public class RainbowTauntEffect extends Effect @Override public void runEffect() { - Location location = getEffectLocation().getLocation(); + /*Location location = getEffectLocation().getFixedLocation(); Location target = getTargetLocation().getLocation(); Vector link = target.toVector().subtract(location.toVector()); float length = (float) link.length(); @@ -48,7 +48,7 @@ public class RainbowTauntEffect extends Effect float y = (float) (-pitch * Math.pow(x, 2) + HEIGHT); location.add(v).add(0, y, 0); ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, - new DustSpellColor(_color), _effectLocation.getLocation().clone().add(0, .5, 0)); + new DustSpellColor(_color), location); coloredParticle.display(); location.subtract(0, y, 0).subtract(v); @@ -70,6 +70,32 @@ public class RainbowTauntEffect extends Effect else _color = _red; } + }*/ + Location location = getEffectLocation().getFixedLocation(); + Location target = getTargetLocation().getFixedLocation(); + Color[] colors = new Color[]{_violet, _indigo, _blue, _green, _yellow, _orange, _red}; + + for (int i = 0; i < 7; i++) + { + line(location.clone().add(0, 0.25 * i, 0), target.clone().add(0, 0.25 * i, 0), colors[i]); + } + } + + private void line(Location startLocation, Location targetLocation, Color color) + { + Vector link = targetLocation.toVector().subtract(startLocation.toVector()); + float length = (float) link.length(); + float pitch = (float) (4 * HEIGHT / Math.pow(length, 2)); + for (int i = 0; i < PARTICLES; i++) + { + Vector v = link.clone().normalize().multiply(length * i / PARTICLES); + float x = ((float) i / PARTICLES) * length - length / 2; + float y = (float) (-pitch * Math.pow(x, 2) + HEIGHT); + startLocation.add(v).add(0, y, 0); + ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, + new DustSpellColor(color), startLocation); + coloredParticle.display(); + startLocation.subtract(0, y, 0).subtract(v); } }