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


Java CraftEventFactory.callPlayerBucketFillEvent方法代码示例

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


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

示例1: a

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

    if (itemstack != null && itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild) {
        // CraftBukkit start - Got milk?
        org.bukkit.Location loc = this.getBukkitEntity().getLocation();
        org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Items.MILK_BUCKET);

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

        if (--itemstack.count <= 0) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, CraftItemStack.asNMSCopy(event.getItemStack()));
        } else if (!entityhuman.inventory.pickup(new ItemStack(Items.MILK_BUCKET))) {
            entityhuman.drop(CraftItemStack.asNMSCopy(event.getItemStack()), false);
        }
        // CraftBukkit end

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

示例2: a

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

    if (itemstack != null && itemstack.id == Item.BUCKET.id && !entityhuman.abilities.canInstantlyBuild) {
        // CraftBukkit start - Got milk?
        org.bukkit.Location loc = this.getBukkitEntity().getLocation();
        org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Item.MILK_BUCKET);

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

        if (--itemstack.count <= 0) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, CraftItemStack.asNMSCopy(event.getItemStack()));
        } else if (!entityhuman.inventory.pickup(new ItemStack(Item.MILK_BUCKET))) {
            entityhuman.drop(CraftItemStack.asNMSCopy(event.getItemStack()));
        }
        // CraftBukkit end

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

示例3: interact

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public boolean interact(EntityPlayer p_70085_1_)
{
    ItemStack itemstack = p_70085_1_.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() == Items.bucket && !p_70085_1_.capabilities.isCreativeMode)
    {
        // CraftBukkit start - Got milk?
        org.bukkit.Location loc = this.getBukkitEntity().getLocation();
        org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(p_70085_1_, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Items.milk_bucket);

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

        if (itemstack.stackSize-- == 1)
        {
            p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, CraftItemStack.asNMSCopy(event.getItemStack()));
        }
        else if (!p_70085_1_.inventory.addItemStackToInventory(new ItemStack(Items.milk_bucket)))
        {
            p_70085_1_.dropPlayerItemWithRandomChoice(CraftItemStack.asNMSCopy(event.getItemStack()), false);
        }

        // CraftBukkit end
        return true;
    }
    else
    {
        return super.interact(p_70085_1_);
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:33,代码来源:EntityCow.java


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