StandardGun.java 文件源码

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

项目:AddGun 作者:
/**
 * Based on shooting the gun, jerks the player's head to the direction of firing
 * 
 * @param entity the entity shooting
 * @param direction the direction of shot
 */
public void knockback(LivingEntity entity, Vector direction) {
    if (entity instanceof Player) {
        Player p = (Player) entity;
        Vector begin = p.getEyeLocation().getDirection().clone();
        Vector end = begin.clone().getMidpoint(direction).getMidpoint(begin); // 25% of "direction" between start and where fire occurred.
        long kickback = Math.max(Math.min(this.cooldown / 3, (long) Animation.FRAME_DELAY * 3l), (long) Animation.FRAME_DELAY * 2l);
        long kickdown = Math.max((long) Animation.FRAME_DELAY * 2l, this.cooldown - kickback);
        AddGun.getPlugin().getPlayerListener().playAnimation(p, new Animation(p, begin, kickback, direction, kickdown, end));
    } else {
        entity.teleport(entity.getLocation().setDirection(direction), TeleportCause.PLUGIN);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号