java类org.bukkit.event.player.PlayerAnimationEvent的实例源码

NoSwingA.java 文件源码 项目:Crescent 阅读 23 收藏 0 点赞 0 评论 0
@Override
public void call(Event event) {
    if (event instanceof PlayerInteractEvent) {
        final PlayerInteractEvent pie = (PlayerInteractEvent) event;

        // Types of interacting where the arm must swing.
        if (pie.getAction() == Action.LEFT_CLICK_AIR || pie.getAction() == Action.LEFT_CLICK_BLOCK) {
            lastInteract = System.currentTimeMillis();
        }
    } else if (event instanceof PlayerAnimationEvent) {
        final PlayerAnimationEvent pae = (PlayerAnimationEvent) event;

        if (pae.getAnimationType() == PlayerAnimationType.ARM_SWING) {
            final long difference = System.currentTimeMillis() - lastInteract;

            Bukkit.broadcastMessage("swing difference: " + difference);
        }
    }
}
PlayerStaminaState.java 文件源码 项目:ProjectAres 阅读 25 收藏 0 点赞 0 评论 0
void onEvent(PlayerAnimationEvent event) {
    if(event.getAnimationType() != PlayerAnimationType.ARM_SWING) return;
    if(event.getPlayer().isDigging()) return;
    if(!isHoldingWeapon()) return;

    swinging = true;
    lastSwingTick = player.getMatch().getClock().now().tick;
}
PlayerMovementListener.java 文件源码 项目:ProjectAres 阅读 28 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void detectBlockPunch(PlayerAnimationEvent event) {
    if(event.getAnimationType() != PlayerAnimationType.ARM_SWING) return;
    if(event.getPlayer().getGameMode() != GameMode.ADVENTURE) return;

    // Client will not punch blocks in adventure mode, so we detect it ourselves and fire a BlockPunchEvent.
    // We do this in the kit module only because its the one that is responsible for putting players in adventure mode.
    // A few other modules rely on this, including StaminaModule and BlockDropsModule.
    RayBlockIntersection hit = event.getPlayer().getTargetedBlock(true, false);
    if(hit == null) return;

    eventBus.callEvent(new BlockPunchEvent(event.getPlayer(), hit));
}
VanguardListener.java 文件源码 项目:Vanguard 阅读 29 收藏 0 点赞 0 评论 0
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
    public void move(PlayerAnimationEvent ev) {
        if (Vanguard.isLocked(ev.getPlayer().getUniqueId())) {
//            ev.getPlayer().sendMessage(Configuration.getStringContainer()
//                    .getString("googletokenlogin")
//                    .replace("$timeout$", Long.toString(Configuration.getTimeoutSeconds()))
//                    .split("\n"));
            ev.setCancelled(true);
        }
    }
PlayerConnection.java 文件源码 项目:CraftBukkit 阅读 35 收藏 0 点赞 0 评论 0
public void a(PacketPlayInArmAnimation packetplayinarmanimation) {
    if (this.player.dead) return; // CraftBukkit
    this.player.v();
    if (packetplayinarmanimation.d() == 1) {
        // CraftBukkit start - Raytrace to look for 'rogue armswings'
        float f = 1.0F;
        float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f;
        float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f;
        double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f;
        double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * (double) f + 1.62D - (double) this.player.height;
        double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f;
        Vec3D vec3d = Vec3D.a(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 = 5.0D;
        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 != EnumMovingObjectType.BLOCK) {
            CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand());
        }

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

        if (event.isCancelled()) return;
        // CraftBukkit end

        this.player.ba();
    }
}
PlayerConnection.java 文件源码 项目:Almura-Server 阅读 25 收藏 0 点赞 0 评论 0
public void a(Packet18ArmAnimation packet18armanimation) {
    if (this.player.dead) return; // CraftBukkit

    this.player.u();
    if (packet18armanimation.b == 1) {
        // CraftBukkit start - Raytrace to look for 'rogue armswings'
        float f = 1.0F;
        float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f;
        float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f;
        double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f;
        double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * (double) f + 1.62D - (double) this.player.height;
        double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f;
        Vec3D vec3d = this.player.world.getVec3DPool().create(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 = 5.0D;
        Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
        MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, true);

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

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

        if (event.isCancelled()) return;
        // CraftBukkit end

        this.player.aV();
    }
}
PlayerConnection.java 文件源码 项目:Tweakkit-Server 阅读 29 收藏 0 点赞 0 评论 0
public void a(PacketPlayInArmAnimation packetplayinarmanimation) {
    if (this.player.dead) return; // CraftBukkit
    this.player.v();
    if (packetplayinarmanimation.d() == 1) {
        // CraftBukkit start - Raytrace to look for 'rogue armswings'
        float f = 1.0F;
        float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f;
        float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f;
        double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f;
        double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * (double) f + 1.62D - (double) this.player.height;
        double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f;
        Vec3D vec3d = Vec3D.a(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() == EnumGamemode.CREATIVE ? 5.0D : 4.5D; // Spigot
        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 != EnumMovingObjectType.BLOCK) {
            CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand());
        }

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

        if (event.isCancelled()) return;
        // CraftBukkit end

        this.player.ba();
    }
}
PlayerConnection.java 文件源码 项目:SpigotSource 阅读 26 收藏 0 点赞 0 评论 0
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());
}
PlayerConnection.java 文件源码 项目:Craft-city 阅读 24 收藏 0 点赞 0 评论 0
public void a(Packet18ArmAnimation packet18armanimation) {
    if (this.player.dead) return; // CraftBukkit

    if (packet18armanimation.b == 1) {
        // CraftBukkit start - Raytrace to look for 'rogue armswings'
        float f = 1.0F;
        float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f;
        float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f;
        double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f;
        double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * (double) f + 1.62D - (double) this.player.height;
        double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f;
        Vec3D vec3d = this.player.world.getVec3DPool().create(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 = 5.0D;
        Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
        MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, true);

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

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

        if (event.isCancelled()) return;
        // CraftBukkit end

        this.player.bK();
    }
}
ThirstListener.java 文件源码 项目:RoyalSurvivors 阅读 32 收藏 0 点赞 0 评论 0
@EventHandler
public void thirstSwing(PlayerAnimationEvent e) {
    if (e.getAnimationType() != PlayerAnimationType.ARM_SWING) return;
    Player p = e.getPlayer();
    if (!RUtils.isInInfectedWorld(p)) return;
    final ItemStack hand = p.getItemInHand();
    if (hand == null || hand.getType() == Material.AIR) changeThirst(p, -Config.thirstSwing);
    else changeThirst(p, -Config.thirstSwingItem);
}
DetectionListener.java 文件源码 项目:Crescent 阅读 25 收藏 0 点赞 0 评论 0
@EventHandler
public void onPlayerAnimation(PlayerAnimationEvent event) {
    final Player player = event.getPlayer();

    getCheckVersion(player, CheckType.AUTOCLICKER, "A").call(event);
}
CombatManager.java 文件源码 项目:ZentrelaRPG 阅读 25 收藏 0 点赞 0 评论 0
@EventHandler
public void onAnim(PlayerAnimationEvent event) {
    if (event.getAnimationType() == PlayerAnimationType.ARM_SWING) {
        check(event.getPlayer().getInventory().getItemInMainHand(), event.getPlayer());
    }
}
StaminaMatchModule.java 文件源码 项目:ProjectAres 阅读 24 收藏 0 点赞 0 评论 0
@EventHandler(ignoreCancelled = true)
public void onPlayerSwing(PlayerAnimationEvent event) {
    PlayerStaminaState state = states.get(event.getPlayer());
    if(state != null) state.onEvent(event);
}
DamageDisplayPlayerFacet.java 文件源码 项目:ProjectAres 阅读 23 收藏 0 点赞 0 评论 0
@TargetedEventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSwing(PlayerAnimationEvent event) {
    if(event.getAnimationType() != PlayerAnimationType.ARM_SWING) return;
    if(event.getPlayer().isDigging()) return;
    updateSpeedometer();
}
SpellListener.java 文件源码 项目:MiniWynn 阅读 24 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void on(PlayerAnimationEvent animationEvent){
    Player player = animationEvent.getPlayer();
    on(player, Spell.MouseClick.LEFT);
}
NetHandlerPlayServer.java 文件源码 项目:Cauldron 阅读 25 收藏 0 点赞 0 评论 0
public void processAnimation(C0APacketAnimation p_147350_1_)
{
    if (this.playerEntity.isDead)
    {
        return;    // CraftBukkit
    }

    this.playerEntity.func_143004_u();

    if (p_147350_1_.func_149421_d() == 1)
    {
        // CraftBukkit start - Raytrace to look for 'rogue armswings'
        float f = 1.0F;
        float f1 = this.playerEntity.prevRotationPitch + (this.playerEntity.rotationPitch - this.playerEntity.prevRotationPitch) * f;
        float f2 = this.playerEntity.prevRotationYaw + (this.playerEntity.rotationYaw - this.playerEntity.prevRotationYaw) * f;
        double d0 = this.playerEntity.prevPosX + (this.playerEntity.posX - this.playerEntity.prevPosX) * (double) f;
        double d1 = this.playerEntity.prevPosY + (this.playerEntity.posY - this.playerEntity.prevPosY) * (double) f + 1.62D - (double) this.playerEntity.yOffset;
        double d2 = this.playerEntity.prevPosZ + (this.playerEntity.posZ - this.playerEntity.prevPosZ) * (double) f;
        Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
        float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
        float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
        float f5 = -MathHelper.cos(-f1 * 0.017453292F);
        float f6 = MathHelper.sin(-f1 * 0.017453292F);
        float f7 = f4 * f5;
        float f8 = f3 * f5;
        double d3 = 5.0D;
        Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
        MovingObjectPosition movingobjectposition = this.playerEntity.worldObj.rayTraceBlocks(vec3, vec31, true);
        boolean valid = false;

        if (movingobjectposition == null || movingobjectposition.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK)
        {
            valid = true;
        }
        else
        {
            Block block = this.playerEntity.worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);

            if (!block.isOpaqueCube())   // Should be isBreakable?
            {
                valid = true;
            }
        }

        if (valid)
        {
            CraftEventFactory.callPlayerInteractEvent(this.playerEntity, Action.LEFT_CLICK_AIR, this.playerEntity.inventory.getCurrentItem());
        }

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

        if (event.isCancelled())
        {
            return;
        }

        // CraftBukkit end
        this.playerEntity.swingItem();
    }
}
StaminaSymptom.java 文件源码 项目:ProjectAres 阅读 60 收藏 0 点赞 0 评论 0
public void onSwing(PlayerAnimationEvent event) {}


问题


面经


文章

微信
公众号

扫码关注公众号