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


Java PlayerShearEntityEvent.isCancelled方法代码示例

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


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

示例1: a

import org.bukkit.event.player.PlayerShearEntityEvent; //导入方法依赖的package包/类
public boolean a(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) {
        if (!this.world.isStatic) {
            // CraftBukkit start
            PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return false;
            }
            // CraftBukkit end

            this.setSheared(true);
            int i = 1 + this.random.nextInt(3);

            for (int j = 0; j < i; ++j) {
                EntityItem entityitem = this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor()), 1.0F);

                entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
                entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
                entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            }
        }

        itemstack.damage(1, entityhuman);
        this.makeSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.a(entityhuman);
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:33,代码来源:EntitySheep.java

示例2: a

import org.bukkit.event.player.PlayerShearEntityEvent; //导入方法依赖的package包/类
public boolean a(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.id == Item.SHEARS.id && !this.isSheared() && !this.isBaby()) {
        if (!this.world.isStatic) {
            // CraftBukkit start
            PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return false;
            }
            // CraftBukkit end

            this.setSheared(true);
            int i = 1 + this.random.nextInt(3);

            for (int j = 0; j < i; ++j) {
                EntityItem entityitem = this.a(new ItemStack(Block.WOOL.id, 1, this.getColor()), 1.0F);

                entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
                entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
                entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            }
        }

        itemstack.damage(1, entityhuman);
        this.makeSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.a(entityhuman);
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:33,代码来源:EntitySheep.java

示例3: itemInteractionForEntity

import org.bukkit.event.player.PlayerShearEntityEvent; //导入方法依赖的package包/类
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity)
{
    if (entity.worldObj.isRemote)
    {
        return false;
    }
    if (entity instanceof IShearable)
    {
        IShearable target = (IShearable)entity;
        if (target.isShearable(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ))
        {
            // Cauldron start
            PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) player.getBukkitEntity(), entity.getBukkitEntity());
            player.worldObj.getServer().getPluginManager().callEvent(event);

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

            // Cauldron end
            ArrayList<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ,
                    EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));

            Random rand = new Random();
            for(ItemStack stack : drops)
            {
                EntityItem ent = entity.entityDropItem(stack, 1.0F);
                ent.motionY += rand.nextFloat() * 0.05F;
                ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
                ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
            }
            itemstack.damageItem(1, entity);
        }
        return true;
    }
    return false;
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:40,代码来源:ItemShears.java

示例4: a

import org.bukkit.event.player.PlayerShearEntityEvent; //导入方法依赖的package包/类
public boolean a(EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack) {
    if (itemstack != null && itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) {
        if (!this.world.isClientSide) {
            // CraftBukkit start
            PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return false;
            }
            // CraftBukkit end

            this.setSheared(true);
            int i = 1 + this.random.nextInt(3);

            for (int j = 0; j < i; ++j) {
                this.forceDrops = true; // CraftBukkit
                EntityItem entityitem = this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor().getColorIndex()), 1.0F);
                this.forceDrops = false; // CraftBukkit

                entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
                entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
                entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            }
        }

        itemstack.damage(1, entityhuman);
        this.a(SoundEffects.eP, 1.0F, 1.0F);
    }

    return super.a(entityhuman, enumhand, itemstack);
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:33,代码来源:EntitySheep.java

示例5: a_

import org.bukkit.event.player.PlayerShearEntityEvent; //导入方法依赖的package包/类
public boolean a_(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.id == Item.SHEARS.id && !this.isSheared() && !this.isBaby()) {
        if (!this.world.isStatic) {
            // CraftBukkit start
            PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return false;
            }
            // CraftBukkit end

            this.setSheared(true);
            int i = 1 + this.random.nextInt(3);

            for (int j = 0; j < i; ++j) {
                EntityItem entityitem = this.a(new ItemStack(Block.WOOL.id, 1, this.getColor()), 1.0F);

                entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
                entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
                entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            }
        }

        itemstack.damage(1, entityhuman);
        this.makeSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.a_(entityhuman);
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:33,代码来源:EntitySheep.java

示例6: a

import org.bukkit.event.player.PlayerShearEntityEvent; //导入方法依赖的package包/类
public boolean a(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.getItem() == Items.BOWL && this.getAge() >= 0) {
        if (itemstack.count == 1) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, new ItemStack(Items.MUSHROOM_SOUP));
            return true;
        }

        if (entityhuman.inventory.pickup(new ItemStack(Items.MUSHROOM_SOUP)) && !entityhuman.abilities.canInstantlyBuild) {
            entityhuman.inventory.splitStack(entityhuman.inventory.itemInHandIndex, 1);
            return true;
        }
    }

    if (itemstack != null && itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
        // CraftBukkit start
        PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        this.die();
        this.world.addParticle("largeexplode", this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D);
        if (!this.world.isStatic) {
            EntityCow entitycow = new EntityCow(this.world);

            entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
            entitycow.setHealth(this.getHealth());
            entitycow.aM = this.aM;
            this.world.addEntity(entitycow);

            for (int i = 0; i < 5; ++i) {
                this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Blocks.RED_MUSHROOM)));
            }

            itemstack.damage(1, entityhuman);
            this.makeSound("mob.sheep.shear", 1.0F, 1.0F);
        }

        return true;
    } else {
        return super.a(entityhuman);
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:49,代码来源:EntityMushroomCow.java

示例7: a

import org.bukkit.event.player.PlayerShearEntityEvent; //导入方法依赖的package包/类
public boolean a(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.id == Item.BOWL.id && this.getAge() >= 0) {
        if (itemstack.count == 1) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, new ItemStack(Item.MUSHROOM_SOUP));
            return true;
        }

        if (entityhuman.inventory.pickup(new ItemStack(Item.MUSHROOM_SOUP)) && !entityhuman.abilities.canInstantlyBuild) {
            entityhuman.inventory.splitStack(entityhuman.inventory.itemInHandIndex, 1);
            return true;
        }
    }

    if (itemstack != null && itemstack.id == Item.SHEARS.id && this.getAge() >= 0) {
        // CraftBukkit start
        PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        this.die();
        this.world.addParticle("largeexplode", this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D);
        if (!this.world.isStatic) {
            EntityCow entitycow = new EntityCow(this.world);

            entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
            entitycow.setHealth(this.getHealth());
            entitycow.aN = this.aN;
            this.world.addEntity(entitycow);

            for (int i = 0; i < 5; ++i) {
                this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Block.RED_MUSHROOM)));
            }
        }

        return true;
    } else {
        return super.a(entityhuman);
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:46,代码来源:EntityMushroomCow.java

示例8: a

import org.bukkit.event.player.PlayerShearEntityEvent; //导入方法依赖的package包/类
public boolean a(EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack) {
    if (itemstack != null && itemstack.getItem() == Items.BOWL && this.getAge() >= 0 && !entityhuman.abilities.canInstantlyBuild) {
        if (--itemstack.count == 0) {
            entityhuman.a(enumhand, new ItemStack(Items.MUSHROOM_STEW));
        } else if (!entityhuman.inventory.pickup(new ItemStack(Items.MUSHROOM_STEW))) {
            entityhuman.drop(new ItemStack(Items.MUSHROOM_STEW), false);
        }

        return true;
    } else if (itemstack != null && itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
        // CraftBukkit start
        PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end
        this.die();
        this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D, new int[0]);
        if (!this.world.isClientSide) {
            EntityCow entitycow = new EntityCow(this.world);

            entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
            entitycow.setHealth(this.getHealth());
            entitycow.aN = this.aN;
            if (this.hasCustomName()) {
                entitycow.setCustomName(this.getCustomName());
            }

            this.world.addEntity(entitycow);

            for (int i = 0; i < 5; ++i) {
                this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Blocks.RED_MUSHROOM)));
            }

            itemstack.damage(1, entityhuman);
            this.a(SoundEffects.dx, 1.0F, 1.0F);
        }

        return true;
    } else {
        return super.a(entityhuman, enumhand, itemstack);
    }
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:46,代码来源:EntityMushroomCow.java

示例9: a_

import org.bukkit.event.player.PlayerShearEntityEvent; //导入方法依赖的package包/类
public boolean a_(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.id == Item.BOWL.id && this.getAge() >= 0) {
        if (itemstack.count == 1) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, new ItemStack(Item.MUSHROOM_SOUP));
            return true;
        }

        if (entityhuman.inventory.pickup(new ItemStack(Item.MUSHROOM_SOUP)) && !entityhuman.abilities.canInstantlyBuild) {
            entityhuman.inventory.splitStack(entityhuman.inventory.itemInHandIndex, 1);
            return true;
        }
    }

    if (itemstack != null && itemstack.id == Item.SHEARS.id && this.getAge() >= 0) {
        // CraftBukkit start
        PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        this.die();
        this.world.addParticle("largeexplode", this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D);
        if (!this.world.isStatic) {
            EntityCow entitycow = new EntityCow(this.world);

            entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
            entitycow.setHealth(this.getHealth());
            entitycow.ay = this.ay;
            this.world.addEntity(entitycow);

            for (int i = 0; i < 5; ++i) {
                this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Block.RED_MUSHROOM)));
            }
        }

        return true;
    } else {
        return super.a_(entityhuman);
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:46,代码来源:EntityMushroomCow.java


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