本文整理汇总了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);
}
}
示例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);
}
}
示例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_);
}
}