本文整理汇总了Java中org.bukkit.event.block.BlockDispenseEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java BlockDispenseEvent.isCancelled方法的具体用法?Java BlockDispenseEvent.isCancelled怎么用?Java BlockDispenseEvent.isCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.block.BlockDispenseEvent
的用法示例。
在下文中一共展示了BlockDispenseEvent.isCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockDispense
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onBlockDispense(final BlockDispenseEvent event) {
if (!event.isCancelled()) {
if (PermissionInterface.CheckEnabledWorld(event.getBlock().getLocation()) && (event.getItem().getType() == Material.EMERALD)) {
event.setCancelled(true);
}
}
if(!event.isCancelled())
AimCannonPlayerListener.onBlockDispense(event);
}
示例2: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
World world = isourceblock.k();
IPosition iposition = BlockDispenser.a(isourceblock);
EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
IProjectile iprojectile = this.a(world, iposition);
// CraftBukkit start
ItemStack itemstack1 = itemstack.a(1);
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumfacing.getAdjacentX(), (double) ((float) enumfacing.getAdjacentY() + 0.1F), (double) enumfacing.getAdjacentZ()));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
itemstack.count++;
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
itemstack.count++;
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.b(), this.a());
((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
// CraftBukkit end
world.addEntity((Entity) iprojectile);
// itemstack.a(1); // CraftBukkit - Handled during event processing
return itemstack;
}
示例3: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
World world = isourceblock.k();
IPosition iposition = BlockDispenser.a(isourceblock);
EnumFacing enumfacing = BlockDispenser.l_(isourceblock.h());
IProjectile iprojectile = this.a(world, iposition);
// CraftBukkit start
ItemStack itemstack1 = itemstack.a(1);
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumfacing.c(), (double) ((float) enumfacing.d() + 0.1F), (double) enumfacing.e()));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
itemstack.count++;
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
itemstack.count++;
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.b(), this.a());
// CraftBukkit end
world.addEntity((Entity) iprojectile);
// itemstack.a(1); // CraftBukkit - Handled during event processing
return itemstack;
}
示例4: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
World world = isourceblock.getWorld();
IPosition iposition = BlockDispenser.a(isourceblock);
EnumDirection enumdirection = BlockDispenser.e(isourceblock.f());
IProjectile iprojectile = this.a(world, iposition, itemstack);
// iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.b(), this.a());
// CraftBukkit start
ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ()));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
itemstack.count++;
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
itemstack.count++;
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.getPower(), this.a());
((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
// CraftBukkit end
world.addEntity((Entity) iprojectile);
// itemstack.a(1); // CraftBukkit - Handled during event processing
return itemstack;
}
示例5: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
World world = isourceblock.k();
IPosition iposition = BlockDispenser.a(isourceblock);
EnumFacing enumfacing = BlockDispenser.j_(isourceblock.h());
IProjectile iprojectile = this.a(world, iposition);
// CraftBukkit start
ItemStack itemstack1 = itemstack.a(1);
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumfacing.c(), (double) ((float) enumfacing.d() + 0.1F), (double) enumfacing.e()));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
itemstack.count++;
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
itemstack.count++;
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.b(), this.a());
// CraftBukkit end
world.addEntity((Entity) iprojectile);
// itemstack.a(1); // CraftBukkit - Handled during event processing
return itemstack;
}
示例6: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
ItemBucket itembucket = (ItemBucket) itemstack.getItem();
int i = isourceblock.getBlockX();
int j = isourceblock.getBlockY();
int k = isourceblock.getBlockZ();
EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
// CraftBukkit start
World world = isourceblock.k();
int x = i + enumfacing.getAdjacentX();
int y = j + enumfacing.getAdjacentY();
int z = k + enumfacing.getAdjacentZ();
if (world.isEmpty(x, y, z) || !world.getType(x, y, z).getMaterial().isBuildable()) {
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem();
}
// CraftBukkit end
if (itembucket.a(isourceblock.k(), i + enumfacing.getAdjacentX(), j + enumfacing.getAdjacentY(), k + enumfacing.getAdjacentZ())) {
// CraftBukkit start - Handle stacked buckets
Item item = Items.BUCKET;
if (--itemstack.count == 0) {
itemstack.setItem(Items.BUCKET);
itemstack.count = 1;
} else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) {
this.b.a(isourceblock, new ItemStack(item));
}
// CraftBukkit end
return itemstack;
} else {
return this.b.a(isourceblock, itemstack);
}
}
示例7: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
int i = isourceblock.getBlockX() + enumfacing.getAdjacentX();
int j = isourceblock.getBlockY() + enumfacing.getAdjacentY();
int k = isourceblock.getBlockZ() + enumfacing.getAdjacentZ();
AxisAlignedBB axisalignedbb = AxisAlignedBB.a((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1));
List list = isourceblock.k().a(EntityLiving.class, axisalignedbb, (IEntitySelector) (new EntitySelectorEquipable(itemstack)));
if (list.size() > 0) {
EntityLiving entityliving = (EntityLiving) list.get(0);
int l = entityliving instanceof EntityHuman ? 1 : 0;
int i1 = EntityInsentient.b(itemstack);
// CraftBukkit start
ItemStack itemstack1 = itemstack.a(1);
World world = isourceblock.k();
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
itemstack.count++;
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
itemstack.count++;
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
// CraftBukkit end
itemstack1.count = 1;
entityliving.setEquipment(i1 - l, itemstack1);
if (entityliving instanceof EntityInsentient) {
((EntityInsentient) entityliving).a(i1, 2.0F);
}
// --itemstack.count; // CraftBukkit - handled above
return itemstack;
} else {
return super.b(isourceblock, itemstack);
}
}
示例8: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
IPosition iposition = BlockDispenser.a(isourceblock);
double d0 = iposition.getX() + (double) ((float) enumfacing.getAdjacentX() * 0.3F);
double d1 = iposition.getY() + (double) ((float) enumfacing.getAdjacentY() * 0.3F);
double d2 = iposition.getZ() + (double) ((float) enumfacing.getAdjacentZ() * 0.3F);
World world = isourceblock.k();
Random random = world.random;
double d3 = random.nextGaussian() * 0.05D + (double) enumfacing.getAdjacentX();
double d4 = random.nextGaussian() * 0.05D + (double) enumfacing.getAdjacentY();
double d5 = random.nextGaussian() * 0.05D + (double) enumfacing.getAdjacentZ();
// CraftBukkit start
ItemStack itemstack1 = itemstack.a(1);
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
itemstack.count++;
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
itemstack.count++;
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
world.addEntity(entitysmallfireball);
// itemstack.a(1); // Handled during event processing
// CraftBukkit end
return itemstack;
}
示例9: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
double d0 = isourceblock.getX() + (double) enumfacing.getAdjacentX();
double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F);
double d2 = isourceblock.getZ() + (double) enumfacing.getAdjacentZ();
// CraftBukkit start
World world = isourceblock.k();
ItemStack itemstack1 = itemstack.a(1);
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
itemstack.count++;
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
itemstack.count++;
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
EntityFireworks entityfireworks = new EntityFireworks(isourceblock.k(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), itemstack1);
isourceblock.k().addEntity(entityfireworks);
// itemstack.a(1); // Handled during event processing
// CraftBukkit end
return itemstack;
}
示例10: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
double d0 = isourceblock.getX() + (double) enumfacing.getAdjacentX();
double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F);
double d2 = isourceblock.getZ() + (double) enumfacing.getAdjacentZ();
// CraftBukkit start
World world = isourceblock.k();
ItemStack itemstack1 = itemstack.a(1);
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
itemstack.count++;
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
itemstack.count++;
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
Entity entity = ItemMonsterEgg.spawnCreature(isourceblock.k(), itemstack.getData(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG);
if (entity instanceof EntityLiving && itemstack.hasName()) {
((EntityInsentient) entity).setCustomName(itemstack.getName());
}
// itemstack.a(1); // Handled during event processing
// CraftBukkit end
return itemstack;
}
示例11: a
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
public static boolean a(World world, ItemStack itemstack, int i, EnumFacing enumfacing, ISourceBlock isourceblock) {
IPosition iposition = BlockDispenser.a(isourceblock);
// CraftBukkit end
double d0 = iposition.getX();
double d1 = iposition.getY();
double d2 = iposition.getZ();
EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack);
double d3 = world.random.nextDouble() * 0.1D + 0.2D;
entityitem.motX = (double) enumfacing.getAdjacentX() * d3;
entityitem.motY = 0.20000000298023224D;
entityitem.motZ = (double) enumfacing.getAdjacentZ() * d3;
entityitem.motX += world.random.nextGaussian() * 0.007499999832361937D * (double) i;
entityitem.motY += world.random.nextGaussian() * 0.007499999832361937D * (double) i;
entityitem.motZ += world.random.nextGaussian() * 0.007499999832361937D * (double) i;
// CraftBukkit start
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(entityitem.motX, entityitem.motY, entityitem.motZ));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
return false;
}
entityitem.setItemStack(CraftItemStack.asNMSCopy(event.getItem()));
entityitem.motX = event.getVelocity().getX();
entityitem.motY = event.getVelocity().getY();
entityitem.motZ = event.getVelocity().getZ();
if (!event.getItem().equals(craftItem)) {
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior.getClass() != DispenseBehaviorItem.class) {
idispensebehavior.a(isourceblock, eventStack);
} else {
world.addEntity(entityitem);
}
return false;
}
world.addEntity(entityitem);
return true;
// CraftBukkit end
}
示例12: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
ItemBucket itembucket = (ItemBucket) itemstack.getItem();
int i = isourceblock.getBlockX();
int j = isourceblock.getBlockY();
int k = isourceblock.getBlockZ();
EnumFacing enumfacing = BlockDispenser.l_(isourceblock.h());
// CraftBukkit start
World world = isourceblock.k();
int x = i + enumfacing.c();
int y = j + enumfacing.d();
int z = k + enumfacing.e();
if (world.isEmpty(x, y, z) || !world.getMaterial(x, y, z).isBuildable()) {
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem();
}
// CraftBukkit end
if (itembucket.a(isourceblock.k(), i + enumfacing.c(), j + enumfacing.d(), k + enumfacing.e())) {
// CraftBukkit start - Handle stacked buckets
Item item = Item.BUCKET;
if (--itemstack.count == 0) {
itemstack.id = item.id;
itemstack.count = 1;
} else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) {
this.b.a(isourceblock, new ItemStack(item));
}
// CraftBukkit end
return itemstack;
} else {
return this.b.a(isourceblock, itemstack);
}
}
示例13: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
EnumFacing enumfacing = BlockDispenser.l_(isourceblock.h());
int i = isourceblock.getBlockX() + enumfacing.c();
int j = isourceblock.getBlockY() + enumfacing.d();
int k = isourceblock.getBlockZ() + enumfacing.e();
AxisAlignedBB axisalignedbb = AxisAlignedBB.a().a((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1));
List list = isourceblock.k().a(EntityLiving.class, axisalignedbb, (IEntitySelector) (new EntitySelectorEquipable(itemstack)));
if (list.size() > 0) {
EntityLiving entityliving = (EntityLiving) list.get(0);
int l = entityliving instanceof EntityHuman ? 1 : 0;
int i1 = EntityInsentient.b(itemstack);
// CraftBukkit start
ItemStack itemstack1 = itemstack.a(1);
World world = isourceblock.k();
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
itemstack.count++;
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
itemstack.count++;
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
// CraftBukkit end
itemstack1.count = 1;
entityliving.setEquipment(i1 - l, itemstack1);
if (entityliving instanceof EntityInsentient) {
((EntityInsentient) entityliving).a(i1, 2.0F);
}
// --itemstack.count; // CraftBukkit - handled above
return itemstack;
} else {
return super.b(isourceblock, itemstack);
}
}
示例14: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
EnumFacing enumfacing = BlockDispenser.l_(isourceblock.h());
IPosition iposition = BlockDispenser.a(isourceblock);
double d0 = iposition.getX() + (double) ((float) enumfacing.c() * 0.3F);
double d1 = iposition.getY() + (double) ((float) enumfacing.c() * 0.3F);
double d2 = iposition.getZ() + (double) ((float) enumfacing.e() * 0.3F);
World world = isourceblock.k();
Random random = world.random;
double d3 = random.nextGaussian() * 0.05D + (double) enumfacing.c();
double d4 = random.nextGaussian() * 0.05D + (double) enumfacing.d();
double d5 = random.nextGaussian() * 0.05D + (double) enumfacing.e();
// CraftBukkit start
ItemStack itemstack1 = itemstack.a(1);
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
itemstack.count++;
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
itemstack.count++;
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
world.addEntity(new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()));
// itemstack.a(1); // Handled during event processing
// CraftBukkit end
return itemstack;
}
示例15: b
import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
EnumFacing enumfacing = BlockDispenser.l_(isourceblock.h());
double d0 = isourceblock.getX() + (double) enumfacing.c();
double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F);
double d2 = isourceblock.getZ() + (double) enumfacing.e();
// CraftBukkit start
World world = isourceblock.k();
ItemStack itemstack1 = itemstack.a(1);
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
itemstack.count++;
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
itemstack.count++;
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
EntityFireworks entityfireworks = new EntityFireworks(isourceblock.k(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), itemstack1);
isourceblock.k().addEntity(entityfireworks);
// itemstack.a(1); // Handled during event processing
// CraftBukkit end
return itemstack;
}