SpectatorListener.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:SkyWarsReloaded 作者:
final void repellExpOrb(final Player player, final ExperienceOrb orb) {
    final Location pLoc = player.getLocation();
    final Location oLoc = orb.getLocation();
    final Vector dir = oLoc.toVector().subtract(pLoc.toVector());
    final double dx = Math.abs(dir.getX());
    final double dz = Math.abs(dir.getZ());
    if ( (dx == 0.0) && (dz == 0.0)){
        // Special case probably never happens
        dir.setX(0.001);
    }
    if ((dx < 3.0) && (dz < 3.0)){
        final Vector nDir = dir.normalize();
        final Vector newV = nDir.clone().multiply(0.3);
        newV.setY(0);
        orb.setVelocity(newV);
        if ((dx < 1.0) && (dz < 1.0)){
            // maybe oLoc
            orb.teleport(oLoc.clone().add(nDir.multiply(1.0)), TeleportCause.PLUGIN);
        } 
        if ((dx < 0.5) && (dz < 0.5)){
            orb.remove();
        } 
    } 
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号