PlayerConnection.java 文件源码

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

项目:SpigotSource 作者:
public void a(PacketPlayInArmAnimation packetplayinarmanimation) {
    PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.x());
    if (this.player.dead) return; // CraftBukkit
    this.player.resetIdleTimer();
    // CraftBukkit start - Raytrace to look for 'rogue armswings'
    float f1 = this.player.pitch;
    float f2 = this.player.yaw;
    double d0 = this.player.locX;
    double d1 = this.player.locY + (double) this.player.getHeadHeight();
    double d2 = this.player.locZ;
    Vec3D vec3d = new Vec3D(d0, d1, d2);

    float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
    float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
    float f5 = -MathHelper.cos(-f1 * 0.017453292F);
    float f6 = MathHelper.sin(-f1 * 0.017453292F);
    float f7 = f4 * f5;
    float f8 = f3 * f5;
    double d3 = player.playerInteractManager.getGameMode() == WorldSettings.EnumGamemode.CREATIVE ? 5.0D : 4.5D;
    Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
    MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false);

    if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
        CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
    }

    // Arm swing animation
    PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer());
    this.server.getPluginManager().callEvent(event);

    if (event.isCancelled()) return;
    // CraftBukkit end
    this.player.a(packetplayinarmanimation.a());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号