本文整理匯總了Java中org.bukkit.util.Vector.isZero方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector.isZero方法的具體用法?Java Vector.isZero怎麽用?Java Vector.isZero使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.util.Vector
的用法示例。
在下文中一共展示了Vector.isZero方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: applyImpulses
import org.bukkit.util.Vector; //導入方法依賴的package包/類
private void applyImpulses(LivingEntity attacker) {
final KnockbackSettings knockback = this.knockback.get();
final Vector normal = victim.getLocation().subtract(attacker.getLocation()).toVector();
if(normal.isZero()) return;
normal.normalize();
final Vector victimNormal = knockback.pitchedNormal(normal);
final Vector attackerNormal = normal.times(-1);
if(victimNormal.isZero() || attackerNormal.isZero()) return;
final boolean ground = attacker.isOnGround();
final double attackSpeed = Math.max(0, attacker.getPredictedVelocity().dot(normal));
final boolean sprint = ground && attackSpeed > knockback.sprintThreshold;
victim.applyImpulse(victimNormal.multiply(knockback.power(sprint)), true);
attacker.applyImpulse(attackerNormal.multiply(knockback.recoil(ground) * attackSpeed), true);
final MatchPlayer matchAttacker = match.getPlayer(attacker);
if(matchAttacker != null) {
matchAttacker.facet(DamageDisplayPlayerFacet.class).showKnockback(victim, sprint);
}
}
示例2: pitchedNormal
import org.bukkit.util.Vector; //導入方法依賴的package包/類
public Vector pitchedNormal(Vector delta) {
delta = delta.clone();
delta.setY(0);
if(delta.isZero()) return Vectors.ZERO;
delta.normalize();
final double theta = Math.toRadians(pitch);
final double cos = Math.cos(theta);
delta.set(cos * delta.getX(),
Math.sin(theta),
cos * delta.getZ());
return delta;
}
示例3: spawn
import org.bukkit.util.Vector; //導入方法依賴的package包/類
@Override
public void spawn(Player viewer, Location location, Vector velocity) {
spawn(viewer, uuid, location);
if(!velocity.isZero()) {
sendPacket(viewer, new PacketPlayOutEntityVelocity(entityId(), velocity.getX(), velocity.getY(), velocity.getZ()));
}
}