public EntityItem a(ItemStack itemstack, boolean flag, boolean flag1) { if (itemstack == null) { return null; } else if (itemstack.count == 0) { return null; } else { EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.getHeadHeight(), this.locZ, itemstack); entityitem.pickupDelay = 40; if (flag1) { entityitem.b(this.getName()); } float f = 0.1F; float f1; if (flag) { f1 = this.random.nextFloat() * 0.5F; float f2 = this.random.nextFloat() * 3.1415927F * 2.0F; entityitem.motX = (double) (-MathHelper.sin(f2) * f1); entityitem.motZ = (double) (MathHelper.cos(f2) * f1); entityitem.motY = 0.20000000298023224D; } else { f = 0.3F; entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F); f = 0.02F; f1 = this.random.nextFloat() * 3.1415927F * 2.0F; f *= this.random.nextFloat(); entityitem.motX += Math.cos((double) f1) * (double) f; entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F); entityitem.motZ += Math.sin((double) f1) * (double) f; } // CraftBukkit start - fire PlayerDropItemEvent Player player = (Player) this.getBukkitEntity(); CraftItem drop = new CraftItem(this.world.getServer(), entityitem); PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); if (flag1 && (cur == null || cur.getAmount() == 0)) { // The complete stack was dropped player.getInventory().setItemInHand(drop.getItemStack()); } else if (flag1 && cur.isSimilar(drop.getItemStack()) && drop.getItemStack().getAmount() == 1) { // Only one item is dropped cur.setAmount(cur.getAmount() + 1); player.getInventory().setItemInHand(cur); } else { // Fallback player.getInventory().addItem(drop.getItemStack()); } return null; } // CraftBukkit end this.a(entityitem); this.a(StatisticList.s, 1); return entityitem; } }
public EntityItem a(ItemStack itemstack, boolean flag) { if (itemstack == null) { return null; } else if (itemstack.count == 0) { return null; } else { EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.getHeadHeight(), this.locZ, itemstack); entityitem.pickupDelay = 40; float f = 0.1F; float f1; if (flag) { f1 = this.random.nextFloat() * 0.5F; float f2 = this.random.nextFloat() * 3.1415927F * 2.0F; entityitem.motX = (double) (-MathHelper.sin(f2) * f1); entityitem.motZ = (double) (MathHelper.cos(f2) * f1); entityitem.motY = 0.20000000298023224D; } else { f = 0.3F; entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F); f = 0.02F; f1 = this.random.nextFloat() * 3.1415927F * 2.0F; f *= this.random.nextFloat(); entityitem.motX += Math.cos((double) f1) * (double) f; entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F); entityitem.motZ += Math.sin((double) f1) * (double) f; } // CraftBukkit start Player player = (Player) this.getBukkitEntity(); CraftItem drop = new CraftItem(this.world.getServer(), entityitem); PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { player.getInventory().addItem(drop.getItemStack()); return null; } // CraftBukkit end this.a(entityitem); this.a(StatisticList.v, 1); return entityitem; } }
public EntityItem func_146097_a(ItemStack p_146097_1_, boolean p_146097_2_, boolean p_146097_3_) { if (p_146097_1_ == null) { return null; } else if (p_146097_1_.stackSize == 0) { return null; } else { EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY - 0.30000001192092896D + (double)this.getEyeHeight(), this.posZ, p_146097_1_); entityitem.delayBeforeCanPickup = 40; if (p_146097_3_) { entityitem.func_145799_b(this.getCommandSenderName()); } float f = 0.1F; float f1; if (p_146097_2_) { f1 = this.rand.nextFloat() * 0.5F; float f2 = this.rand.nextFloat() * (float)Math.PI * 2.0F; entityitem.motionX = (double)(-MathHelper.sin(f2) * f1); entityitem.motionZ = (double)(MathHelper.cos(f2) * f1); entityitem.motionY = 0.20000000298023224D; } else { f = 0.3F; entityitem.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f); entityitem.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f); entityitem.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI) * f + 0.1F); f = 0.02F; f1 = this.rand.nextFloat() * (float)Math.PI * 2.0F; f *= this.rand.nextFloat(); entityitem.motionX += Math.cos((double)f1) * (double)f; entityitem.motionY += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F); entityitem.motionZ += Math.sin((double)f1) * (double)f; } // CraftBukkit start Player player = (Player) this.getBukkitEntity(); CraftItem drop = new CraftItem(this.worldObj.getServer(), entityitem); PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); this.worldObj.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { player.getInventory().addItem(drop.getItemStack()); return null; } // CraftBukkit end this.joinEntityItemWithWorld(entityitem); this.addStat(StatList.dropStat, 1); return entityitem; } }
@Nullable public EntityItem a(@Nullable ItemStack itemstack, boolean flag, boolean flag1) { if (itemstack == null) { return null; } else if (itemstack.count == 0) { return null; } else { double d0 = this.locY - 0.30000001192092896D + (double) this.getHeadHeight(); EntityItem entityitem = new EntityItem(this.world, this.locX, d0, this.locZ, itemstack); entityitem.a(40); if (flag1) { entityitem.e(this.getName()); } float f; float f1; if (flag) { f = this.random.nextFloat() * 0.5F; f1 = this.random.nextFloat() * 6.2831855F; entityitem.motX = (double) (-MathHelper.sin(f1) * f); entityitem.motZ = (double) (MathHelper.cos(f1) * f); entityitem.motY = 0.20000000298023224D; } else { f = 0.3F; entityitem.motX = (double) (-MathHelper.sin(this.yaw * 0.017453292F) * MathHelper.cos(this.pitch * 0.017453292F) * f); entityitem.motZ = (double) (MathHelper.cos(this.yaw * 0.017453292F) * MathHelper.cos(this.pitch * 0.017453292F) * f); entityitem.motY = (double) (-MathHelper.sin(this.pitch * 0.017453292F) * f + 0.1F); f1 = this.random.nextFloat() * 6.2831855F; f = 0.02F * this.random.nextFloat(); entityitem.motX += Math.cos((double) f1) * (double) f; entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F); entityitem.motZ += Math.sin((double) f1) * (double) f; } // CraftBukkit start - fire PlayerDropItemEvent Player player = (Player) this.getBukkitEntity(); CraftItem drop = new CraftItem(this.world.getServer(), entityitem); PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); if (flag1 && (cur == null || cur.getAmount() == 0)) { // The complete stack was dropped player.getInventory().setItemInHand(drop.getItemStack()); } else if (flag1 && cur.isSimilar(drop.getItemStack()) && drop.getItemStack().getAmount() == 1) { // Only one item is dropped cur.setAmount(cur.getAmount() + 1); player.getInventory().setItemInHand(cur); } else { // Fallback player.getInventory().addItem(drop.getItemStack()); } return null; } // CraftBukkit end ItemStack itemstack1 = this.a(entityitem); if (flag1) { if (itemstack1 != null) { this.a(StatisticList.e(itemstack1.getItem()), itemstack.count); } this.b(StatisticList.x); } return entityitem; } }
public EntityItem a(ItemStack itemstack, boolean flag) { if (itemstack == null) { return null; } else { EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.getHeadHeight(), this.locZ, itemstack); entityitem.pickupDelay = 40; float f = 0.1F; float f1; if (flag) { f1 = this.random.nextFloat() * 0.5F; float f2 = this.random.nextFloat() * 3.1415927F * 2.0F; entityitem.motX = (double) (-MathHelper.sin(f2) * f1); entityitem.motZ = (double) (MathHelper.cos(f2) * f1); entityitem.motY = 0.20000000298023224D; } else { f = 0.3F; entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F); f = 0.02F; f1 = this.random.nextFloat() * 3.1415927F * 2.0F; f *= this.random.nextFloat(); entityitem.motX += Math.cos((double) f1) * (double) f; entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F); entityitem.motZ += Math.sin((double) f1) * (double) f; } // CraftBukkit start Player player = (Player) this.getBukkitEntity(); CraftItem drop = new CraftItem(this.world.getServer(), entityitem); PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { player.getInventory().addItem(drop.getItemStack()); return null; } // CraftBukkit end this.a(entityitem); this.a(StatisticList.v, 1); return entityitem; } }