public virtual void DropPlayerItemWithRandomChoice(net.minecraft.src.ItemStack itemstack, bool randomDirection) { if (itemstack == null) { return; } net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(worldObj, posX, (posY - 0.30000001192092896D) + (double)GetEyeHeight(), posZ, itemstack); entityitem.delayBeforeCanPickup = 40; float f = 0.1F; if (randomDirection) { float f2 = rand.NextFloat() * 0.5F; float f4 = rand.NextFloat() * 3.141593F * 2.0F; entityitem.motionX = -net.minecraft.src.MathHelper.Sin(f4) * f2; entityitem.motionZ = net.minecraft.src.MathHelper.Cos(f4) * f2; entityitem.motionY = 0.20000000298023224D; } else { float f1 = 0.3F; entityitem.motionX = -net.minecraft.src.MathHelper.Sin((rotationYaw / 180F) * 3.141593F) * net.minecraft.src.MathHelper.Cos((rotationPitch / 180F) * 3.141593F) * f1; entityitem.motionZ = net.minecraft.src.MathHelper.Cos((rotationYaw / 180F) * 3.141593F) * net.minecraft.src.MathHelper.Cos((rotationPitch / 180F) * 3.141593F) * f1; entityitem.motionY = -net.minecraft.src.MathHelper.Sin((rotationPitch / 180F) * 3.141593F) * f1 + 0.1F; f1 = 0.02F; float f3 = rand.NextFloat() * 3.141593F * 2.0F; f1 *= rand.NextFloat(); entityitem.motionX += System.Math.Cos(f3) * (double)f1; entityitem.motionY += (rand.NextFloat() - rand.NextFloat()) * 0.1F; entityitem.motionZ += System.Math.Sin(f3) * (double)f1; } JoinEntityItemWithWorld(entityitem); AddStat(net.minecraft.src.StatList.StatDrop, 1); }
public virtual net.minecraft.src.EntityItem EntityDropItem(net.minecraft.src.ItemStack itemstack, float f) { net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(worldObj , posX, posY + (double)f, posZ, itemstack); entityitem.delayBeforeCanPickup = 10; worldObj.AddEntity(entityitem); return(entityitem); }
public Packet21PickupSpawn(net.minecraft.src.EntityItem entityitem) { // Referenced classes of package net.minecraft.src: // Packet, EntityItem, ItemStack, MathHelper, // NetHandler entityId = entityitem.entityId; itemID = entityitem.item.itemID; count = entityitem.item.stackSize; itemDamage = entityitem.item.GetItemDamage(); xPosition = net.minecraft.src.MathHelper.Floor_double(entityitem.posX * 32D); yPosition = net.minecraft.src.MathHelper.Floor_double(entityitem.posY * 32D); zPosition = net.minecraft.src.MathHelper.Floor_double(entityitem.posZ * 32D); rotation = unchecked((byte)(int)(entityitem.motionX * 128D)); pitch = unchecked((byte)(int)(entityitem.motionY * 128D)); roll = unchecked((byte)(int)(entityitem.motionZ * 128D)); }
public override void OnBlockRemoval(net.minecraft.src.World world, int i, int j, int k) { if (!field_28034_c) { net.minecraft.src.TileEntityFurnace tileentityfurnace = (net.minecraft.src.TileEntityFurnace)world.GetBlockTileEntity(i, j, k); if (tileentityfurnace == null) { return; // CRAFTBUKKIT } for (int l = 0; l < tileentityfurnace.GetSizeInventory(); l++) { net.minecraft.src.ItemStack itemstack = tileentityfurnace.GetStackInSlot(l); if (itemstack == null) { continue; } float f = field_28033_a.NextFloat() * 0.8F + 0.1F; float f1 = field_28033_a.NextFloat() * 0.8F + 0.1F; float f2 = field_28033_a.NextFloat() * 0.8F + 0.1F; do { if (itemstack.stackSize <= 0) { goto label0_continue; } int i1 = field_28033_a.Next(21) + 10; if (i1 > itemstack.stackSize) { i1 = itemstack.stackSize; } itemstack.stackSize -= i1; net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world, (float)i + f, (float)j + f1, (float)k + f2, new net.minecraft.src.ItemStack(itemstack .itemID, i1, itemstack.GetItemDamage())); float f3 = 0.05F; entityitem.motionX = (float)field_28033_a.NextGaussian() * f3; entityitem.motionY = (float)field_28033_a.NextGaussian() * f3 + 0.2F; entityitem.motionZ = (float)field_28033_a.NextGaussian() * f3; world.AddEntity(entityitem); }while (true); label0_continue :; } label0_break :; } base.OnBlockRemoval(world, i, j, k); }
public override void HarvestBlock(net.minecraft.src.World world, net.minecraft.src.EntityPlayer entityplayer, int i, int j, int k, int l) { int i1 = net.minecraft.src.Item.SNOW_BALL.ID; float f = 0.7F; double d = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D; double d1 = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D; double d2 = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D; net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world, (double)i + d, (double)j + d1, (double)k + d2, new net.minecraft.src.ItemStack(i1 , 1, 0)); entityitem.delayBeforeCanPickup = 10; world.AddEntity(entityitem); world.SetBlockWithNotify(i, j, k, 0); entityplayer.AddStat(net.minecraft.src.StatList.StatMinedBlocks[ID], 1); }
public virtual int CatchFish() { byte byte0 = 0; if (bobber != null) { double d = angler.posX - posX; double d2 = angler.posY - posY; double d4 = angler.posZ - posZ; double d6 = net.minecraft.src.MathHelper.Sqrt_double(d * d + d2 * d2 + d4 * d4); double d8 = 0.10000000000000001D; bobber.motionX += d * d8; bobber.motionY += d2 * d8 + (double)net.minecraft.src.MathHelper.Sqrt_double(d6) * 0.080000000000000002D; bobber.motionZ += d4 * d8; byte0 = 3; } else { if (ticksCatchable > 0) { net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(worldObj , posX, posY, posZ, new net.minecraft.src.ItemStack(net.minecraft.src.Item.RAW_FISH )); double d1 = angler.posX - posX; double d3 = angler.posY - posY; double d5 = angler.posZ - posZ; double d7 = net.minecraft.src.MathHelper.Sqrt_double(d1 * d1 + d3 * d3 + d5 * d5); double d9 = 0.10000000000000001D; entityitem.motionX = d1 * d9; entityitem.motionY = d3 * d9 + (double)net.minecraft.src.MathHelper.Sqrt_double(d7 ) * 0.080000000000000002D; entityitem.motionZ = d5 * d9; worldObj.AddEntity(entityitem); angler.AddStat(net.minecraft.src.StatList.StatFishCaught, 1); byte0 = 1; } } if (inGround) { byte0 = 2; } SetEntityDead(); angler.fishEntity = null; return(byte0); }
protected internal virtual void DropBlockAsItem_do(net.minecraft.src.World world, int i, int j, int k, net.minecraft.src.ItemStack itemstack) { if (world.singleplayerWorld) { return; } else { float f = 0.7F; double d = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D; double d1 = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D; double d2 = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D; net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world, (double)i + d, (double)j + d1, (double)k + d2, itemstack); entityitem.delayBeforeCanPickup = 10; world.AddEntity(entityitem); return; } }
public override void OnBlockRemoval(net.minecraft.src.World world, int i, int j, int k) { net.minecraft.src.TileEntityChest tileentitychest = (net.minecraft.src.TileEntityChest )world.GetBlockTileEntity(i, j, k); for (int l = 0; l < tileentitychest.GetSizeInventory(); l++) { net.minecraft.src.ItemStack itemstack = tileentitychest.GetStackInSlot(l); if (itemstack == null) { continue; } float f = ((float)random.NextDouble()) * 0.8F + 0.1F; float f1 = ((float)random.NextDouble()) * 0.8F + 0.1F; float f2 = ((float)random.NextDouble()) * 0.8F + 0.1F; do { if (itemstack.stackSize <= 0) { goto label0_continue; } int i1 = random.Next(21) + 10; if (i1 > itemstack.stackSize) { i1 = itemstack.stackSize; } itemstack.stackSize -= i1; net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world, (float)i + f, (float)j + f1, (float)k + f2, new net.minecraft.src.ItemStack(itemstack .itemID, i1, itemstack.GetItemDamage())); float f3 = 0.05F; entityitem.motionX = (float)random.NextGaussian() * f3; entityitem.motionY = (float)random.NextGaussian() * f3 + 0.2F; entityitem.motionZ = (float)random.NextGaussian() * f3; world.AddEntity(entityitem); }while (true); label0_continue :; } label0_break :; base.OnBlockRemoval(world, i, j, k); }
public virtual void Func_28035_b_(net.minecraft.src.World world, int i, int j, int k) { if (world.singleplayerWorld) { return; } net.minecraft.src.TileEntityRecordPlayer tileentityrecordplayer = (net.minecraft.src.TileEntityRecordPlayer)world.GetBlockTileEntity(i, j, k); if (tileentityrecordplayer == null) { return; // CRAFTBUKKIT } int l = tileentityrecordplayer.field_28009_a; if (l == 0) { return; } else { world.SendSoundEffectToAllPlayersWithin64(1005, i, j, k, 0); world.PlayRecord(null, i, j, k); tileentityrecordplayer.field_28009_a = 0; tileentityrecordplayer.OnInventoryChanged(); world.SetBlockMetadataWithNotify(i, j, k, 0); int i1 = l; float f = 0.7F; double d = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D; double d1 = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.20000000000000001D + 0.59999999999999998D; double d2 = (double)(world.rand.NextFloat() * f) + (double)(1.0F - f) * 0.5D; net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world, (double)i + d, (double)j + d1, (double)k + d2, new net.minecraft.src.ItemStack(i1 , 1, 0)); entityitem.delayBeforeCanPickup = 10; world.AddEntity(entityitem); return; } }
public override void SetEntityDead() { for (int i = 0; i < GetSizeInventory(); i++) { net.minecraft.src.ItemStack itemstack = GetStackInSlot(i); if (itemstack == null) { continue; } float f = rand.NextFloat() * 0.8F + 0.1F; float f1 = rand.NextFloat() * 0.8F + 0.1F; float f2 = rand.NextFloat() * 0.8F + 0.1F; do { if (itemstack.stackSize <= 0) { goto label0_continue; } int j = rand.Next(21) + 10; if (j > itemstack.stackSize) { j = itemstack.stackSize; } itemstack.stackSize -= j; net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(worldObj , posX + (double)f, posY + (double)f1, posZ + (double)f2, new net.minecraft.src.ItemStack (itemstack.itemID, j, itemstack.GetItemDamage())); float f3 = 0.05F; entityitem.motionX = (float)rand.NextGaussian() * f3; entityitem.motionY = (float)rand.NextGaussian() * f3 + 0.2F; entityitem.motionZ = (float)rand.NextGaussian() * f3; worldObj.AddEntity(entityitem); }while (true); label0_continue :; } label0_break :; base.SetEntityDead(); }
public override bool Interact(net.minecraft.src.EntityPlayer entityplayer) { net.minecraft.src.ItemStack itemstack = entityplayer.inventory.GetCurrentItem(); if (itemstack != null && itemstack.itemID == net.minecraft.src.Item.SHEARS .ID && !Func_21069_f_()) { if (!worldObj.singleplayerWorld) { SetSheared(true); int i = 2 + rand.Next(3); for (int j = 0; j < i; j++) { net.minecraft.src.EntityItem entityitem = EntityDropItem(new net.minecraft.src.ItemStack (net.minecraft.src.Block.WOOL.ID, 1, GetFleeceColor()), 1.0F); entityitem.motionY += rand.NextFloat() * 0.05F; entityitem.motionX += (rand.NextFloat() - rand.NextFloat()) * 0.1F; entityitem.motionZ += (rand.NextFloat() - rand.NextFloat()) * 0.1F; } } itemstack.DamageItem(1, entityplayer); } return(false); }
public override void DropBlockAsItemWithChance(net.minecraft.src.World world, int i, int j, int k, int l, float f) { base.DropBlockAsItemWithChance(world, i, j, k, l, f); if (world.singleplayerWorld) { return; } for (int i1 = 0; i1 < 3; i1++) { if (world.rand.Next(15) <= l) { float f1 = 0.7F; float f2 = world.rand.NextFloat() * f1 + (1.0F - f1) * 0.5F; float f3 = world.rand.NextFloat() * f1 + (1.0F - f1) * 0.5F; float f4 = world.rand.NextFloat() * f1 + (1.0F - f1) * 0.5F; net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world, (float)i + f2, (float)j + f3, (float)k + f4, new net.minecraft.src.ItemStack(net.minecraft.src.Item .SEEDS)); entityitem.delayBeforeCanPickup = 10; world.AddEntity(entityitem); } } }
public override bool AttackEntityFrom(net.minecraft.src.Entity entity, int i) { if (worldObj.singleplayerWorld || isDead) { return(true); } forwardDirection = -forwardDirection; field_9167_b = 10; SetBeenAttacked(); damageTaken += i * 10; if (damageTaken > 40) { if (riddenByEntity != null) { riddenByEntity.MountEntity(this); } SetEntityDead(); DropItemWithOffset(net.minecraft.src.Item.MINECART.ID, 1, 0.0F); if (minecartType == 1) { net.minecraft.src.EntityMinecart entityminecart = this; for (int j = 0; j < entityminecart.GetSizeInventory(); j++) { net.minecraft.src.ItemStack itemstack = entityminecart.GetStackInSlot(j); if (itemstack == null) { continue; } float f = rand.NextFloat() * 0.8F + 0.1F; float f1 = rand.NextFloat() * 0.8F + 0.1F; float f2 = rand.NextFloat() * 0.8F + 0.1F; do { if (itemstack.stackSize <= 0) { goto label0_continue; } int k = rand.Next(21) + 10; if (k > itemstack.stackSize) { k = itemstack.stackSize; } itemstack.stackSize -= k; net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(worldObj , posX + (double)f, posY + (double)f1, posZ + (double)f2, new net.minecraft.src.ItemStack (itemstack.itemID, k, itemstack.GetItemDamage())); float f3 = 0.05F; entityitem.motionX = (float)rand.NextGaussian() * f3; entityitem.motionY = (float)rand.NextGaussian() * f3 + 0.2F; entityitem.motionZ = (float)rand.NextGaussian() * f3; worldObj.AddEntity(entityitem); }while (true); label0_continue :; } label0_break :; DropItemWithOffset(net.minecraft.src.Block.CHEST.ID, 1, 0.0F); } else { if (minecartType == 2) { DropItemWithOffset(net.minecraft.src.Block.FURNACE.ID, 1, 0.0F); } } } return(true); }
private net.minecraft.src.Packet GetSpawnPacket() { if (trackedEntity is net.minecraft.src.EntityItem) { net.minecraft.src.EntityItem entityitem = (net.minecraft.src.EntityItem)trackedEntity; net.minecraft.src.Packet21PickupSpawn packet21pickupspawn = new net.minecraft.src.Packet21PickupSpawn (entityitem); entityitem.posX = (double)packet21pickupspawn.xPosition / 32D; entityitem.posY = (double)packet21pickupspawn.yPosition / 32D; entityitem.posZ = (double)packet21pickupspawn.zPosition / 32D; return(packet21pickupspawn); } if (trackedEntity is net.minecraft.src.EntityPlayerMP) { // CRAFTBUKKIT start - limit name length to 16 characters if (((EntityPlayerMP)this.trackedEntity).username.Length > 16) { ((EntityPlayerMP)this.trackedEntity).username = ((EntityPlayerMP)this.trackedEntity).username.Substring(0, 16); } // CRAFTBUKKIT end return(new net.minecraft.src.Packet20NamedEntitySpawn((net.minecraft.src.EntityPlayer)trackedEntity)); } if (trackedEntity is net.minecraft.src.EntityMinecart) { net.minecraft.src.EntityMinecart entityminecart = (net.minecraft.src.EntityMinecart )trackedEntity; if (entityminecart.minecartType == 0) { return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 10)); } if (entityminecart.minecartType == 1) { return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 11)); } if (entityminecart.minecartType == 2) { return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 12)); } } if (trackedEntity is net.minecraft.src.EntityBoat) { return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 1)); } if (trackedEntity is net.minecraft.src.IAnimals) { return(new net.minecraft.src.Packet24MobSpawn((net.minecraft.src.EntityLiving)trackedEntity )); } if (trackedEntity is net.minecraft.src.EntityFish) { return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 90)); } if (trackedEntity is net.minecraft.src.EntityArrow) { net.minecraft.src.EntityLiving entityliving = ((net.minecraft.src.EntityArrow)trackedEntity ).owner; return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 60, entityliving == null ? trackedEntity.entityId : entityliving.entityId)); } if (trackedEntity is net.minecraft.src.EntitySnowball) { return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 61)); } if (trackedEntity is net.minecraft.src.EntityFireball) { net.minecraft.src.EntityFireball entityfireball = (net.minecraft.src.EntityFireball)trackedEntity; net.minecraft.src.Packet23VehicleSpawn packet23vehiclespawn = new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 63, ((net.minecraft.src.EntityFireball)trackedEntity).owner?.entityId ?? 1); // CRAFTBUKKIT -- added check for null shooter packet23vehiclespawn.motionX = (int)(entityfireball.field_9199_b * 8000D); packet23vehiclespawn.motionY = (int)(entityfireball.field_9198_c * 8000D); packet23vehiclespawn.motionZ = (int)(entityfireball.field_9196_d * 8000D); return(packet23vehiclespawn); } if (trackedEntity is net.minecraft.src.EntityEgg) { return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 62)); } if (trackedEntity is net.minecraft.src.EntityTNTPrimed) { return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 50)); } if (trackedEntity is net.minecraft.src.EntityFallingSand) { net.minecraft.src.EntityFallingSand entityfallingsand = (net.minecraft.src.EntityFallingSand )trackedEntity; if (entityfallingsand.blockID == net.minecraft.src.Block.SAND.ID) { return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 70)); } if (entityfallingsand.blockID == net.minecraft.src.Block.GRAVEL.ID) { return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 71)); } } if (trackedEntity is net.minecraft.src.EntityPainting) { return(new net.minecraft.src.Packet25EntityPainting((net.minecraft.src.EntityPainting )trackedEntity)); } else { throw new System.ArgumentException((new java.lang.StringBuilder()).Append("Don't know how to add ").Append(trackedEntity.GetType()).Append("!").ToString()); } }
public void DispenseItem(net.minecraft.src.World world, int i, int j, int k, SharpBukkitLive.SharpBukkit.SharpRandom random) { //TODO: Implement dispenser fixes return; int l = world.GetBlockMetadata(i, j, k); int i1 = 0; int j1 = 0; if (l == 3) { j1 = 1; } else if (l == 2) { j1 = -1; } else if (l == 5) { i1 = 1; } else { i1 = -1; } net.minecraft.src.TileEntityDispenser tileentitydispenser = (net.minecraft.src.TileEntityDispenser)world.GetBlockTileEntity(i, j, k); net.minecraft.src.ItemStack itemstack = tileentitydispenser.GetRandomStackFromInventory(); double d = (double)i + (double)i1 * 0.59999999999999998D + 0.5D; double d1 = (double)j + 0.5D; double d2 = (double)k + (double)j1 * 0.59999999999999998D + 0.5D; if (itemstack == null) { world.SendSoundEffectToAllPlayersWithin64(1001, i, j, k, 0); } else { if (itemstack.itemID == net.minecraft.src.Item.ARROW.ID) { net.minecraft.src.EntityArrow entityarrow = new net.minecraft.src.EntityArrow(world, d, d1, d2); entityarrow.SetArrowHeading(i1, 0.10000000149011612D, j1, 1.1F, 6F); entityarrow.field_28012_a = true; world.AddEntity(entityarrow); world.SendSoundEffectToAllPlayersWithin64(1002, i, j, k, 0); } else if (itemstack.itemID == net.minecraft.src.Item.EGG.ID) { net.minecraft.src.EntityEgg entityegg = new net.minecraft.src.EntityEgg(world, d, d1, d2); entityegg.SetEggHeading(i1, 0.10000000149011612D, j1, 1.1F, 6F); world.AddEntity(entityegg); world.SendSoundEffectToAllPlayersWithin64(1002, i, j, k, 0); } else if (itemstack.itemID == net.minecraft.src.Item.SNOW_BALL.ID) { net.minecraft.src.EntitySnowball entitysnowball = new net.minecraft.src.EntitySnowball(world, d, d1, d2); entitysnowball.SetSnowballHeading(i1, 0.10000000149011612D, j1, 1.1F, 6F); world.AddEntity(entitysnowball); world.SendSoundEffectToAllPlayersWithin64(1002, i, j, k, 0); } else { net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(world, d, d1 - 0.29999999999999999D, d2, itemstack); double d3 = random.NextDouble() * 0.10000000000000001D + 0.20000000000000001D; entityitem.motionX = (double)i1 * d3; entityitem.motionY = 0.20000000298023224D; entityitem.motionZ = (double)j1 * d3; entityitem.motionX += random.NextGaussian() * 0.0074999998323619366D * 6D; entityitem.motionY += random.NextGaussian() * 0.0074999998323619366D * 6D; entityitem.motionZ += random.NextGaussian() * 0.0074999998323619366D * 6D; world.AddEntity(entityitem); world.SendSoundEffectToAllPlayersWithin64(1000, i, j, k, 0); } world.SendSoundEffectToAllPlayersWithin64(2000, i, j, k, i1 + 1 + (j1 + 1) * 3); } }
protected internal virtual void JoinEntityItemWithWorld(net.minecraft.src.EntityItem entityitem) { worldObj.AddEntity(entityitem); }