Overhaul legend particle
This commit is contained in:
parent
ea8c7be5f0
commit
f7ac799476
@ -1,6 +1,9 @@
|
||||
package mineplex.core.gadget.gadgets.particle;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -16,13 +19,46 @@ import mineplex.core.inventory.ClientItem;
|
||||
import mineplex.core.inventory.data.Item;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Random;
|
||||
|
||||
public class ParticleLegend extends ParticleGadget
|
||||
{
|
||||
private static final double PI = Math.PI;
|
||||
private static final int BASE_PILLARS = 9;
|
||||
private static final int PILLAR_VARIANCE = 7;
|
||||
private static final int COLOR_VARIANCE = 5;
|
||||
private static final int MOVING_PARTICLES = 8;
|
||||
private static final double VERTICAL_SPEED = 0.1;
|
||||
private static final double HEIGHT_VARIANCE = 0.8;
|
||||
private static final double ROTATIONAL_SPEED = .03;
|
||||
private static final double RADIAL_VARIANCE = 0.09;
|
||||
private static final double DARK_PARTICLE_CHANCE = 0.5;
|
||||
private static final double BASE_RADIUS = 1.30;
|
||||
private static final double HEIGHT_MODIFIER_BASE = 0.1;
|
||||
private static final double HEIGHT_MODIFIER_MAX = 1.3;
|
||||
private static final double HEIGHT_MODIFIER_INTERVAL = 0.2;
|
||||
private static final Color[] SELECTABLE_COLORS = {
|
||||
new Color(170, 100, 170),
|
||||
new Color(50, 10, 60),
|
||||
new Color(120, 10, 170),
|
||||
new Color(65, 20, 80)
|
||||
};
|
||||
|
||||
private final int _pillars = pillars();
|
||||
private final Color[] _colors = colors();
|
||||
private final double[] _heights = heights();
|
||||
private final double[] _verticals = verticals();
|
||||
private final double[] _variance = variances();
|
||||
private final double[] _thetas = thetas();
|
||||
private final double[] _radii = radii();
|
||||
|
||||
public ParticleLegend(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Legendary Aura",
|
||||
UtilText.splitLineToArray(C.cGray + "This particle will be updated soon! Yay!", LineFormat.LORE),
|
||||
UtilText.splitLineToArray(C.cGray + "Let the energy of the End protect you.", LineFormat.LORE),
|
||||
-1,
|
||||
Material.ENDER_PORTAL_FRAME, (byte)0);
|
||||
}
|
||||
@ -31,9 +67,151 @@ public class ParticleLegend extends ParticleGadget
|
||||
public void playParticle(Player player, UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.getWorld().playEffect(player.getLocation().add(0, 1, 0), Effect.ENDER_SIGNAL, 0);
|
||||
if (Manager.isMoving(player))
|
||||
{
|
||||
Location loc = player.getLocation().add(0, 1.5, 0);
|
||||
|
||||
for (int i = 0; i < MOVING_PARTICLES; i++)
|
||||
{
|
||||
UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST,
|
||||
UtilMath.gauss(loc, 8, 4, 8), 0, UtilParticle.ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (event.getTick() % (ROTATIONAL_SPEED * 100) == 0)
|
||||
{
|
||||
for (int i = 0; i < _pillars; i++)
|
||||
{
|
||||
_thetas[i] = rollover(_thetas[i], ROTATIONAL_SPEED);
|
||||
_heights[i] = rollover(_heights[i], _verticals[i]);
|
||||
|
||||
double x = (_radii[i] * Math.cos(_thetas[i])) + player.getLocation().getX();
|
||||
double z = (_radii[i] * Math.sin(_thetas[i])) + player.getLocation().getZ();
|
||||
double y = (Math.sin(_heights[i]) * _variance[i]) + player.getLocation().getY();
|
||||
|
||||
for (double h = HEIGHT_MODIFIER_BASE; h <= HEIGHT_MODIFIER_MAX; h+= HEIGHT_MODIFIER_INTERVAL)
|
||||
{
|
||||
UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST,
|
||||
new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL);
|
||||
|
||||
if (Math.random() < DARK_PARTICLE_CHANCE)
|
||||
{
|
||||
UtilParticle.playColoredParticleToAll(Color.BLACK, UtilParticle.ParticleType.RED_DUST,
|
||||
new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private double[] heights()
|
||||
{
|
||||
double[] array = new double[_pillars];
|
||||
|
||||
for (int i = 0; i < _pillars; i++)
|
||||
{
|
||||
array[i] = 6.28 * Math.random();
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
private double[] variances()
|
||||
{
|
||||
double[] array = new double[_pillars];
|
||||
|
||||
for (int i = 0; i < _pillars; i++)
|
||||
{
|
||||
array[i] = Math.random() * HEIGHT_VARIANCE;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
private double[] verticals()
|
||||
{
|
||||
double[] array = new double[_pillars];
|
||||
|
||||
for (int i = 0; i < _pillars; i++)
|
||||
{
|
||||
array[i] = Math.random() * VERTICAL_SPEED;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
private double[] thetas()
|
||||
{
|
||||
double[] array = new double[_pillars];
|
||||
double theta = 0;
|
||||
double interval = (2 * PI) / _pillars;
|
||||
|
||||
for (int i = 0; i < _pillars; i++)
|
||||
{
|
||||
array[i] = theta;
|
||||
theta += interval;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
private double[] radii()
|
||||
{
|
||||
double[] array = new double[_pillars];
|
||||
|
||||
for (int i = 0; i < _pillars; i++)
|
||||
{
|
||||
array[i] = BASE_RADIUS + (Math.random() * RADIAL_VARIANCE);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
private Color[] colors()
|
||||
{
|
||||
Random random = new Random();
|
||||
|
||||
Color[] array = new Color[_pillars];
|
||||
|
||||
for (int i = 0; i < _pillars; i++)
|
||||
{
|
||||
Color color = SELECTABLE_COLORS[i % SELECTABLE_COLORS.length];
|
||||
|
||||
int r = color.getRed() + (int) (random.nextGaussian() * COLOR_VARIANCE);
|
||||
int g = color.getGreen() + (int) (random.nextGaussian() * COLOR_VARIANCE);
|
||||
int b = color.getBlue() + (int) (random.nextGaussian() * COLOR_VARIANCE);
|
||||
|
||||
r = Math.min(255, Math.max(0, r));
|
||||
g = Math.min(255, Math.max(0, g));
|
||||
b = Math.min(255, Math.max(0, b));
|
||||
|
||||
array[i] = new Color(r, g, b);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
private int pillars()
|
||||
{
|
||||
return BASE_PILLARS + (int) ((Math.random() * PILLAR_VARIANCE) - (PILLAR_VARIANCE / 2));
|
||||
}
|
||||
|
||||
private double rollover(double value, double additive)
|
||||
{
|
||||
value += additive;
|
||||
|
||||
if (value >= 2 * PI)
|
||||
{
|
||||
value = value - (2 * PI);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
Loading…
Reference in New Issue
Block a user