2015-05-16 18:58:58 +02:00
|
|
|
package mineplex.game.clans.items.legendaries;
|
|
|
|
|
2015-05-25 20:22:06 +02:00
|
|
|
import org.bukkit.Material;
|
2015-05-16 18:58:58 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2015-05-25 20:22:06 +02:00
|
|
|
import org.bukkit.util.Vector;
|
2015-05-16 18:58:58 +02:00
|
|
|
|
2015-10-30 23:13:19 +01:00
|
|
|
import mineplex.core.common.util.UtilEnt;
|
2015-10-26 16:37:44 +01:00
|
|
|
import mineplex.core.common.util.UtilMath;
|
2015-10-30 23:13:19 +01:00
|
|
|
import mineplex.core.common.util.UtilParticle;
|
|
|
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
|
|
|
import mineplex.core.common.util.UtilParticle.ViewDist;
|
2015-10-26 16:37:44 +01:00
|
|
|
import mineplex.core.common.util.UtilTextBottom;
|
|
|
|
|
2015-05-16 18:58:58 +02:00
|
|
|
public class WindBlade extends LegendaryItem
|
|
|
|
{
|
2015-06-01 18:25:20 +02:00
|
|
|
public static final double FLIGHT_VELOCITY = 0.75d;
|
2015-10-26 16:37:44 +01:00
|
|
|
public static final int MAX_FLIGHT_TIME = 80; // Max flight of 80 ticks
|
2015-05-16 18:58:58 +02:00
|
|
|
|
2015-10-26 16:37:44 +01:00
|
|
|
private double _power;
|
2015-05-16 18:58:58 +02:00
|
|
|
|
|
|
|
public WindBlade()
|
|
|
|
{
|
2015-10-26 16:37:44 +01:00
|
|
|
super("Wind Blade", "Activate flying ability to take flight for 80 ticks before landing!", Material.RECORD_8); // TODO:
|
|
|
|
// Configurable?
|
2015-05-16 18:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void update(Player wielder)
|
|
|
|
{
|
2015-05-25 20:22:06 +02:00
|
|
|
// Check if player is attempting to fly and activate
|
2015-05-16 18:58:58 +02:00
|
|
|
if (isHoldingRightClick() && canPropel())
|
|
|
|
{
|
2015-10-30 23:13:19 +01:00
|
|
|
removePower(UtilEnt.isGrounded(wielder) ? 1.17 : .88);
|
2015-05-16 18:58:58 +02:00
|
|
|
propelPlayer(wielder);
|
2015-10-30 23:13:19 +01:00
|
|
|
UtilParticle.PlayParticle(ParticleType.MOB_SPELL, wielder.getLocation().add(0, 1, 0), -.5f + (float) Math.random(), -.5f + (float) Math.random(), -.5f + (float) Math.random(), 1f, 3, ViewDist.NORMAL);
|
2015-05-16 18:58:58 +02:00
|
|
|
}
|
2015-05-25 20:22:06 +02:00
|
|
|
|
2015-10-30 23:13:19 +01:00
|
|
|
if (UtilEnt.isGrounded(wielder))
|
2015-05-25 20:22:06 +02:00
|
|
|
{
|
2015-10-26 16:37:44 +01:00
|
|
|
addPower(0.33);
|
2015-05-25 20:22:06 +02:00
|
|
|
}
|
2015-10-26 16:37:44 +01:00
|
|
|
|
2015-10-30 23:13:19 +01:00
|
|
|
UtilTextBottom.displayProgress(UtilMath.clamp(_power, .0, 80.) / 80., wielder);
|
2015-05-16 18:58:58 +02:00
|
|
|
}
|
2015-10-26 16:37:44 +01:00
|
|
|
|
2015-05-16 18:58:58 +02:00
|
|
|
private void propelPlayer(Player player)
|
|
|
|
{
|
2015-05-25 20:22:06 +02:00
|
|
|
Vector direction = player.getLocation().getDirection().normalize();
|
2015-10-26 16:37:44 +01:00
|
|
|
direction.multiply(FLIGHT_VELOCITY);
|
2015-05-25 20:22:06 +02:00
|
|
|
|
|
|
|
player.setVelocity(direction);
|
2015-10-26 16:37:44 +01:00
|
|
|
player.setFallDistance(0f);
|
2015-05-16 18:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private boolean canPropel()
|
|
|
|
{
|
2015-10-26 16:37:44 +01:00
|
|
|
return _power > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addPower(double power)
|
|
|
|
{
|
2015-10-30 23:13:19 +01:00
|
|
|
_power = UtilMath.clamp(_power + power, -20, 80);
|
2015-10-26 16:37:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void removePower(double power)
|
|
|
|
{
|
2015-10-30 23:13:19 +01:00
|
|
|
_power = UtilMath.clamp(_power - power, -20, 80);
|
2015-05-16 18:58:58 +02:00
|
|
|
}
|
|
|
|
}
|