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