@Override public void F_() { super.F_(); if (shake == 7) { this.die(); } }
@Override public void a(World world, int i, int j, int k, Entity entity) { if (entity instanceof EntityArrow && !world.isStatic) { EntityArrow entityarrow = (EntityArrow) entity; if (entityarrow.isBurning()) { // CraftBukkit start if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent( entityarrow, i, j, k, Blocks.AIR, 0) .isCancelled()) return; // CraftBukkit end this.a( world, i, j, k, 1, entityarrow.shooter instanceof EntityLiving ? (EntityLiving) entityarrow.shooter : null); world.setAir(i, j, k); } } }
/** * called when the player releases the use item button. Args: itemstack, world, entityplayer, * itemInUseCount */ public void a(ItemStack var1, World var2, EntityHuman var3, int var4) { // Forge start int var5 = this.a(var1) - var4; ArrowLooseEvent var6 = new ArrowLooseEvent(var3, var1, var5); MinecraftForge.EVENT_BUS.post(var6); if (var6.isCanceled()) { return; } var5 = var6.charge; // Forge end boolean var7 = var3.abilities.canInstantlyBuild || EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_INFINITE.id, var1) > 0; if (var7 || var3.inventory.e(Item.ARROW.id)) { float var8 = (float) var5 / 20.0F; var8 = (var8 * var8 + var8 * 2.0F) / 3.0F; if ((double) var8 < 0.1D) { return; } if (var8 > 1.0F) { var8 = 1.0F; } EntityArrow var9 = new EntityArrow(var2, var3, var8 * 2.0F); if (var8 == 1.0F) { var9.e(true); } int var10 = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, var1); if (var10 > 0) { var9.b(var9.c() + (double) var10 * 0.5D + 0.5D); } int var11 = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, var1); if (var11 > 0) { var9.a(var11); } if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, var1) > 0) { var9.setOnFire(100); } // CraftBukkit start org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent( var3, var1, var9, var8); if (event.isCancelled()) { event.getProjectile().remove(); return; } if (event.getProjectile() == var9.getBukkitEntity()) { var2.addEntity(var9); } // CraftBukkit end var1.damage(1, var3); var2.makeSound(var3, "random.bow", 1.0F, 1.0F / (d.nextFloat() * 0.4F + 1.2F) + var8 * 0.5F); if (var7) { var9.fromPlayer = 2; } else { var3.inventory.d(Item.ARROW.id); } } }
// 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); } } }
public void a(ItemStack itemstack, World world, EntityHuman entityhuman, int i) { boolean flag = entityhuman.abilities.canInstantlyBuild || EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_INFINITE.id, itemstack) > 0; if (flag || entityhuman.inventory.b(Items.ARROW)) { int j = this.d(itemstack) - i; float f = (float) j / 20.0F; f = (f * f + f * 2.0F) / 3.0F; if ((double) f < 0.1D) { return; } if (f > 1.0F) { f = 1.0F; } EntityArrow entityarrow = new EntityArrow(world, entityhuman, f * 2.0F); entityarrow.damage = 2.3D; if (f == 1.0F) { entityarrow.setCritical(true); } int k = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, itemstack); if (k > 0) { entityarrow.b(entityarrow.j() + (double) k * 0.5D + 0.5D); } int l = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, itemstack); if (l > 0) { entityarrow.a(l); } if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, itemstack) > 0) { EntityCombustEvent event = new EntityCombustEvent(entityarrow.getBukkitEntity(), 100); entityarrow.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { entityarrow.setOnFire(event.getDuration()); } } // CraftBukkit start EntityShootBowEvent event = CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, entityarrow, f); if (event.isCancelled()) { event.getProjectile().remove(); return; } if (event.getProjectile() == entityarrow.getBukkitEntity()) { world.addEntity(entityarrow); } // CraftBukkit end itemstack.damage(1, entityhuman); world.makeSound( entityhuman, "random.bow", 1.0F, 1.0F / (g.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (flag) { entityarrow.fromPlayer = 2; } else { entityhuman.inventory.a(Items.ARROW); } entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this)]); } }