本文整理汇总了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()));
}
}