当前位置: 首页>>代码示例>>Java>>正文


Java CraftEventFactory.callPlayerInteractEvent方法代码示例

本文整理汇总了Java中org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent方法的典型用法代码示例。如果您正苦于以下问题:Java CraftEventFactory.callPlayerInteractEvent方法的具体用法?Java CraftEventFactory.callPlayerInteractEvent怎么用?Java CraftEventFactory.callPlayerInteractEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.craftbukkit.event.CraftEventFactory的用法示例。


在下文中一共展示了CraftEventFactory.callPlayerInteractEvent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dig

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public void dig(int i, int j, int k, int l) {
    // CraftBukkit start
    PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, i, j, k, l, this.player.inventory.getItemInHand());
    if (!this.gamemode.isAdventure() || this.player.d(i, j, k)) {
        if (event.isCancelled()) {
            // Let the client know the block still exists
            ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world));
            // Update any tile entity data for this block
            TileEntity tileentity = this.world.getTileEntity(i, j, k);
            if (tileentity != null) {
                this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
            }
            return;
        }
        // CraftBukkit end
        if (this.isCreative()) {
            if (!this.world.douseFire((EntityHuman) null, i, j, k, l)) {
                this.breakBlock(i, j, k);
            }
        } else {
            // this.world.douseFire((EntityHuman) null, i, j, k, l); // CraftBukkit - Moved down
            this.lastDigTick = this.currentTick;
            float f = 1.0F;
            Block block = this.world.getType(i, j, k);
            // CraftBukkit start - Swings at air do *NOT* exist.
            if (event.useInteractedBlock() == Event.Result.DENY) {
                // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
                if (block == Blocks.WOODEN_DOOR) {
                    // For some reason *BOTH* the bottom/top part have to be marked updated.
                    boolean bottom = (this.world.getData(i, j, k) & 8) == 0;
                    ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world));
                    ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j + (bottom ? 1 : -1), k, this.world));
                } else if (block == Blocks.TRAP_DOOR) {
                    ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world));
                }
            } else if (block.getMaterial() != Material.AIR) {
                block.attack(this.world, i, j, k, this.player);
                f = block.getDamage(this.player, this.player.world, i, j, k);
                // Allow fire punching to be blocked
                this.world.douseFire((EntityHuman) null, i, j, k, l);
            }

            if (event.useItemInHand() == Event.Result.DENY) {
                // If we 'insta destroyed' then the client needs to be informed.
                if (f > 1.0f) {
                    ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world));
                }
                return;
            }
            org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, i, j, k, this.player.inventory.getItemInHand(), f >= 1.0f);

            if (blockEvent.isCancelled()) {
                // Let the client know the block still exists
                ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world));
                return;
            }

            if (blockEvent.getInstaBreak()) {
                f = 2.0f;
            }
            // CraftBukkit end

            if (block.getMaterial() != Material.AIR && f >= 1.0F) {
                this.breakBlock(i, j, k);
            } else {
                this.d = true;
                this.f = i;
                this.g = j;
                this.h = k;
                int i1 = (int) (f * 10.0F);

                this.world.d(this.player.getId(), i, j, k, i1);
                this.o = i1;
            }
        }
        world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
    }
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:79,代码来源:PlayerInteractManager.java

示例2: a

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:38,代码来源:PlayerConnection.java

示例3: a

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:39,代码来源:PlayerConnection.java

示例4: interact

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public boolean interact(EntityHuman entityhuman, World world, ItemStack itemstack, int i, int j, int k, int l, float f, float f1, float f2) {
    int i1 = world.getTypeId(i, j, k);

    // CraftBukkit start - Interact
    boolean result = false;
    if (i1 > 0) {
        PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, i, j, k, l, itemstack);
        if (event.useInteractedBlock() == Event.Result.DENY) {
            // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
            if (i1 == Block.WOODEN_DOOR.id) {
                boolean bottom = (world.getData(i, j, k) & 8) == 0;
                ((EntityPlayer) entityhuman).playerConnection.sendPacket(new Packet53BlockChange(i, j + (bottom ? 1 : -1), k, world));
            }
            result = (event.useItemInHand() != Event.Result.ALLOW);
        } else if (!entityhuman.isSneaking() || itemstack == null) {
            result = Block.byId[i1].interact(world, i, j, k, entityhuman, l, f, f1, f2);
        }

        if (itemstack != null && !result) {
            int j1 = itemstack.getData();
            int k1 = itemstack.count;

            result = itemstack.placeItem(entityhuman, world, i, j, k, l, f, f1, f2);

            // The item count should not decrement in Creative mode.
            if (this.isCreative()) {
                itemstack.setData(j1);
                itemstack.count = k1;
            }
        }

        // If we have 'true' and no explicit deny *or* an explicit allow -- run the item part of the hook
        if (itemstack != null && ((!result && event.useItemInHand() != Event.Result.DENY) || event.useItemInHand() == Event.Result.ALLOW)) {
            this.useItem(entityhuman, world, itemstack);
        }
    }
    return result;
    // CraftBukkit end
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:40,代码来源:PlayerInteractManager.java

示例5: a

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:38,代码来源:PlayerConnection.java

示例6: dig

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public void dig(int i, int j, int k, int l) {
    // CraftBukkit start
    PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, i, j, k, l, this.player.inventory.getItemInHand());
    if (!this.gamemode.isAdventure() || this.player.d(i, j, k)) {
        if (event.isCancelled()) {
            // Let the client know the block still exists
            ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world));
            // Update any tile entity data for this block
            TileEntity tileentity = this.world.getTileEntity(i, j, k);
            if (tileentity != null) {
                this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
            }
            return;
        }
        // CraftBukkit end
        if (this.isCreative()) {
            if (!this.world.douseFire((EntityHuman) null, i, j, k, l)) {
                this.breakBlock(i, j, k);
            }
        } else {
            // this.world.douseFire((EntityHuman) null, i, j, k, l); // CraftBukkit - Moved down
            this.lastDigTick = this.currentTick;
            float f = 1.0F;
            Block block = this.world.getType(i, j, k);
            // CraftBukkit start - Swings at air do *NOT* exist.
            if (event.useInteractedBlock() == Event.Result.DENY) {
                // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
                if (block == Blocks.WOODEN_DOOR) {
                    // For some reason *BOTH* the bottom/top part have to be marked updated.
                    boolean bottom = (this.world.getData(i, j, k) & 8) == 0;
                    ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world));
                    ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j + (bottom ? 1 : -1), k, this.world));
                } else if (block == Blocks.TRAP_DOOR) {
                    ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world));
                }
            } else if (block.getMaterial() != Material.AIR) {
                block.attack(this.world, i, j, k, this.player);
                f = block.getDamage(this.player, this.player.world, i, j, k);
                // Allow fire punching to be blocked
                this.world.douseFire((EntityHuman) null, i, j, k, l);
            }

            if (event.useItemInHand() == Event.Result.DENY) {
                // If we 'insta destroyed' then the client needs to be informed.
                if (f > 1.0f) {
                    ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world));
                }
                return;
            }
            org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, i, j, k, this.player.inventory.getItemInHand(), f >= 1.0f);

            if (blockEvent.isCancelled()) {
                // Let the client know the block still exists
                ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, this.world));
                return;
            }

            if (blockEvent.getInstaBreak()) {
                f = 2.0f;
            }
            // CraftBukkit end

            if (block.getMaterial() != Material.AIR && f >= 1.0F) {
                this.breakBlock(i, j, k);
            } else {
                this.d = true;
                this.f = i;
                this.g = j;
                this.h = k;
                int i1 = (int) (f * 10.0F);

                this.world.d(this.player.getId(), i, j, k, i1);
                this.o = i1;
            }
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:78,代码来源:PlayerInteractManager.java

示例7: interact

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public boolean interact(EntityHuman entityhuman, World world, ItemStack itemstack, int i, int j, int k, int l, float f, float f1, float f2) {
    /* CraftBukkit start - whole method
    if ((!entityhuman.isSneaking() || entityhuman.be() == null) && world.getType(i, j, k).interact(world, i, j, k, entityhuman, l, f, f1, f2)) {
        return true;
    } else if (itemstack == null) {
        return false;
    } else if (this.isCreative()) {
        int i1 = itemstack.getData();
        int j1 = itemstack.count;
        boolean flag = itemstack.placeItem(entityhuman, world, i, j, k, l, f, f1, f2);

        itemstack.setData(i1);
        itemstack.count = j1;
        return flag;
    } else {
        return itemstack.placeItem(entityhuman, world, i, j, k, l, f, f1, f2);
    }
    // Interract event */
    Block block = world.getType(i, j, k);
    boolean result = false;
    if (block != Blocks.AIR) {
        PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, i, j, k, l, itemstack);
        if (event.useInteractedBlock() == Event.Result.DENY) {
            // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
            if (block == Blocks.WOODEN_DOOR) {
                boolean bottom = (world.getData(i, j, k) & 8) == 0;
                ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j + (bottom ? 1 : -1), k, world));
            }
            result = (event.useItemInHand() != Event.Result.ALLOW);
        } else if (!entityhuman.isSneaking() || itemstack == null) {
            result = block.interact(world, i, j, k, entityhuman, l, f, f1, f2);
        }

        if (itemstack != null && !result) {
            int j1 = itemstack.getData();
            int k1 = itemstack.count;

            result = itemstack.placeItem(entityhuman, world, i, j, k, l, f, f1, f2);

            // The item count should not decrement in Creative mode.
            if (this.isCreative()) {
                itemstack.setData(j1);
                itemstack.count = k1;
            }
        }

        // If we have 'true' and no explicit deny *or* an explicit allow -- run the item part of the hook
        if (itemstack != null && ((!result && event.useItemInHand() != Event.Result.DENY) || event.useItemInHand() == Event.Result.ALLOW)) {
            this.useItem(entityhuman, world, itemstack);
        }
    }
    return result;
    // CraftBukkit end
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:55,代码来源:PlayerInteractManager.java

示例8: processAnimation

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:63,代码来源:NetHandlerPlayServer.java


注:本文中的org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。