Fixed the rainbow taunt

This commit is contained in:
LCastr0 2017-03-04 00:40:53 -03:00
parent d6605e973d
commit 85b5eee92f
2 changed files with 37 additions and 2 deletions

View File

@ -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<Material> 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();
}

View File

@ -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);
}
}