Reduce amount of particles spawned with the water wings

This commit is contained in:
LCastr0 2017-05-03 22:27:38 -03:00
parent cf56dfb9cf
commit 229c888498
2 changed files with 23 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;
import mineplex.core.common.shape.ShapeWings;
@ -14,6 +15,8 @@ import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.KitSelectorGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class WaterWingsKitSelector extends KitSelectorGadget
{
@ -21,6 +24,9 @@ public class WaterWingsKitSelector extends KitSelectorGadget
private ShapeWings _wings = new ShapeWings(UtilParticle.ParticleType.DRIP_WATER.particleName, new Vector(0.2,0.2,0.2), 1, 0, false, ShapeWings.DEFAULT_ROTATION, ShapeWings.ANGEL_WING_PATTERN);
private ShapeWings _wingsEdge = new ShapeWings(UtilParticle.ParticleType.DRIP_WATER.particleName, new Vector(0.1,0.1,0.1), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.ANGEL_WING_PATTERN);
private int _tick = 0;
private int _lastTick = 0;
public WaterWingsKitSelector(GadgetManager manager)
{
super(manager, "Water Wings", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE),
@ -29,11 +35,22 @@ public class WaterWingsKitSelector extends KitSelectorGadget
@Override
public void playParticle(Entity entity, Player playTo)
{
if (_tick != _lastTick)
{
double offsetY = getEntityYOffset(entity);
Location loc = entity.getLocation().add(0, offsetY, 0).add(entity.getLocation().getDirection().multiply(-0.2));
_wings.display(loc, playTo);
_wingsEdge.display(loc, playTo);
_lastTick = _tick;
}
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.FASTEST)
_tick++;
}
/**

View File

@ -20,7 +20,8 @@ public abstract class KitSelectorGadget extends Gadget
/**
* Plays the next particle for the selected entity
* @param entity
* @param entity The entity of the selected kit
* @param playTo The player that will receive the particles
*/
public abstract void playParticle(Entity entity, Player playTo);