private void f() { if (this.g == 1) { EntityArrow entityarrow = new EntityArrow(this.a, this.b, this.c, 1.6F, 12.0F); this.a.makeSound(this.b, "random.bow", 1.0F, 1.0F / (this.b.au().nextFloat() * 0.4F + 0.8F)); this.a.addEntity(entityarrow); } else if (this.g == 2) { EntitySnowball entitysnowball = new EntitySnowball(this.a, this.b); double d0 = this.c.locX - this.b.locX; double d1 = this.c.locY + this.c.getHeadHeight() - 1.100000023841858D - entitysnowball.locY; double d2 = this.c.locZ - this.b.locZ; float f = MathHelper.sqrt(d0 * d0 + d2 * d2) * 0.2F; entitysnowball.c(d0, d1 + f, d2, 1.6F, 12.0F); this.a.makeSound(this.b, "random.bow", 1.0F, 1.0F / (this.b.au().nextFloat() * 0.4F + 0.8F)); this.a.addEntity(entitysnowball); } }
// CraftBukkit - priv to public public void dispense(World world, int i, int j, int k, Random random) { int l = world.getData(i, j, k); byte b0 = 0; byte b1 = 0; if (l == 3) { b1 = 1; } else if (l == 2) { b1 = -1; } else if (l == 5) { b0 = 1; } else { b0 = -1; } TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k); if (tileentitydispenser != null) { // CraftBukkit start int dispenseSlot = tileentitydispenser.findDispenseSlot(); ItemStack itemstack = null; if (dispenseSlot > -1) { itemstack = tileentitydispenser.getContents()[dispenseSlot]; // Copy item stack, because we want it to have 1 item itemstack = new ItemStack(itemstack.id, 1, itemstack.getData(), itemstack.getEnchantments()); } // CraftBukkit end double d0 = (double) i + (double) b0 * 0.6D + 0.5D; double d1 = (double) j + 0.5D; double d2 = (double) k + (double) b1 * 0.6D + 0.5D; if (itemstack == null) { world.triggerEffect(1001, i, j, k, 0); } else { // CraftBukkit start double d3 = random.nextDouble() * 0.1D + 0.2D; double motX = (double) b0 * d3; double motY = 0.20000000298023224D; double motZ = (double) b1 * d3; motX += random.nextGaussian() * 0.007499999832361937D * 6.0D; motY += random.nextGaussian() * 0.007499999832361937D * 6.0D; motZ += random.nextGaussian() * 0.007499999832361937D * 6.0D; org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack).clone(); BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new Vector(motX, motY, motZ)); world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; } if (event.getItem().equals(bukkitItem)) { // Actually remove the item tileentitydispenser.splitStack(dispenseSlot, 1); } motX = event.getVelocity().getX(); motY = event.getVelocity().getY(); motZ = event.getVelocity().getZ(); itemstack = CraftItemStack.createNMSItemStack(event.getItem()); // CraftBukkit end if (itemstack.id == Item.ARROW.id) { EntityArrow entityarrow = new EntityArrow(world, d0, d1, d2); entityarrow.shoot((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F); entityarrow.fromPlayer = true; world.addEntity(entityarrow); world.triggerEffect(1002, i, j, k, 0); } else if (itemstack.id == Item.EGG.id) { EntityEgg entityegg = new EntityEgg(world, d0, d1, d2); entityegg.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F); world.addEntity(entityegg); world.triggerEffect(1002, i, j, k, 0); } else if (itemstack.id == Item.SNOW_BALL.id) { EntitySnowball entitysnowball = new EntitySnowball(world, d0, d1, d2); entitysnowball.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F); world.addEntity(entitysnowball); world.triggerEffect(1002, i, j, k, 0); } else if (itemstack.id == Item.POTION.id && ItemPotion.c(itemstack.getData())) { EntityPotion entitypotion = new EntityPotion(world, d0, d1, d2, itemstack.getData()); entitypotion.a((double) b0, 0.10000000149011612D, (double) b1, 1.375F, 3.0F); world.addEntity(entitypotion); world.triggerEffect(1002, i, j, k, 0); } else if (itemstack.id == Item.EXP_BOTTLE.id) { EntityThrownExpBottle entitythrownexpbottle = new EntityThrownExpBottle(world, d0, d1, d2); entitythrownexpbottle.a((double) b0, 0.10000000149011612D, (double) b1, 1.375F, 3.0F); world.addEntity(entitythrownexpbottle); world.triggerEffect(1002, i, j, k, 0); } else if (itemstack.id == Item.MONSTER_EGG.id) { ItemMonsterEgg.a( world, itemstack.getData(), d0 + (double) b0 * 0.3D, d1 - 0.3D, d2 + (double) b1 * 0.3D); world.triggerEffect(1002, i, j, k, 0); } else if (itemstack.id == Item.FIREBALL.id) { EntitySmallFireball entitysmallfireball = new EntitySmallFireball( world, d0 + (double) b0 * 0.3D, d1, d2 + (double) b1 * 0.3D, (double) b0 + random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, (double) b1 + random.nextGaussian() * 0.05D); world.addEntity(entitysmallfireball); world.triggerEffect(1009, i, j, k, 0); } else { EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack); // CraftBukkit start // double d3 = random.nextDouble() * 0.1D + 0.2D; // Moved up entityitem.motX = motX; entityitem.motY = motY; entityitem.motZ = motZ; // CraftBukkit end world.addEntity(entityitem); world.triggerEffect(1000, i, j, k, 0); } world.triggerEffect(2000, i, j, k, b0 + 1 + (b1 + 1) * 3); } } }