Added titan particle trail.
This commit is contained in:
parent
84fde1c087
commit
24f8a98545
@ -1,14 +1,12 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import net.minecraft.server.v1_8_R3.EnumParticle;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EnumParticle;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
|
||||
|
||||
public class UtilParticle
|
||||
{
|
||||
@ -243,6 +241,22 @@ public class UtilParticle
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static void PlayParticleToAll(ParticleType type, Location location, Vector offset, float speed, int count, ViewDist dist)
|
||||
{
|
||||
PlayParticle(type, location, (float) offset.getX(), (float) offset.getY(), (float) offset.getZ(), speed, count, dist, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
public static void PlayParticle(ParticleType type, Location location, Vector offset, float speed, int count, ViewDist dist, Player... players)
|
||||
{
|
||||
PlayParticle(type, location, (float) offset.getX(), (float) offset.getY(), (float) offset.getZ(), speed, count, dist, players);
|
||||
}
|
||||
|
||||
public static void PlayParticleToAll(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ,
|
||||
float speed, int count, ViewDist dist)
|
||||
{
|
||||
PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count, dist, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ,
|
||||
float speed, int count, ViewDist dist, Player... players)
|
||||
{
|
||||
|
@ -1,13 +1,25 @@
|
||||
package mineplex.core.gadget.gadgets;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.gadget.types.ParticleGadget;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.ParticleGadget;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class ParticleTitan extends ParticleGadget
|
||||
{
|
||||
|
||||
private int _tick;
|
||||
|
||||
public ParticleTitan(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Titanic Particle", new String[]
|
||||
@ -16,7 +28,71 @@ public class ParticleTitan extends ParticleGadget
|
||||
" ",
|
||||
C.cRed + "Unlocked with Titan Rank",
|
||||
},
|
||||
-1,
|
||||
// Price for debuging purposes
|
||||
10,
|
||||
Material.INK_SACK, (byte)8);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_tick++;
|
||||
_tick = _tick%620;
|
||||
|
||||
for(Player player : GetActive())
|
||||
{
|
||||
if (!shouldDisplay(player)) continue;
|
||||
|
||||
double total = 3;
|
||||
double step = (1/total)*Math.PI*2;
|
||||
double offset1 = (step/20)*_tick%20;
|
||||
double offset2 = (step/31)*_tick%31;
|
||||
|
||||
double r = 3;
|
||||
boolean redstone = false;
|
||||
|
||||
if(Manager.isMoving(player)) r = 0.5;
|
||||
|
||||
for(int i = 0; i < total; i++)
|
||||
{
|
||||
double rad = step*i + offset1;
|
||||
|
||||
double x = Math.sin(rad);
|
||||
double y = 0;
|
||||
double z = Math.cos(rad);
|
||||
|
||||
|
||||
Vector v = new Vector(x,y,z).normalize();
|
||||
v.multiply(r);
|
||||
Location loc = player.getLocation();
|
||||
loc.add(0, 0.1, 0);
|
||||
|
||||
loc.add(v);
|
||||
|
||||
|
||||
if(redstone) UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, 1, 0, 0, 1, 0, ViewDist.NORMAL);
|
||||
v.multiply(-1);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FLAME, loc, v, 0.05f, 0, ViewDist.NORMAL);
|
||||
|
||||
rad = -(step*i + offset2);
|
||||
x = Math.sin(rad);
|
||||
z = Math.cos(rad);
|
||||
|
||||
v = new Vector(x,y,z).normalize();
|
||||
v.multiply(r);
|
||||
loc = player.getLocation();
|
||||
loc.add(0, 0.1, 0);
|
||||
|
||||
loc.add(v);
|
||||
|
||||
if(redstone) UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, 1, 0, 0, 1, 0, ViewDist.NORMAL);
|
||||
v.multiply(-1);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FLAME, loc, v, 0.05f, 0, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user