/// <summary> /// Performs a ranged attack according to the AI's rangedAttackID. /// </summary> private void DoRangedAttack() { if (RangedAttackID == 1) { EntityArrow entityarrow = new EntityArrow(WorldObj, EntityHost, AttackTarget, 1.6F, 12F); WorldObj.PlaySoundAtEntity(EntityHost, "random.bow", 1.0F, 1.0F / (EntityHost.GetRNG().NextFloat() * 0.4F + 0.8F)); WorldObj.SpawnEntityInWorld(entityarrow); } else if (RangedAttackID == 2) { EntitySnowball entitysnowball = new EntitySnowball(WorldObj, EntityHost); float d = AttackTarget.PosX - EntityHost.PosX; float d1 = (AttackTarget.PosY + AttackTarget.GetEyeHeight()) - 1.1000000238418579F - entitysnowball.PosY; float d2 = AttackTarget.PosZ - EntityHost.PosZ; float f = MathHelper2.Sqrt_double(d * d + d2 * d2) * 0.2F; entitysnowball.SetThrowableHeading(d, d1 + f, d2, 1.6F, 12F); WorldObj.PlaySoundAtEntity(EntityHost, "random.bow", 1.0F, 1.0F / (EntityHost.GetRNG().NextFloat() * 0.4F + 0.8F)); WorldObj.SpawnEntityInWorld(entitysnowball); } }
public override void HandleVehicleSpawn(Packet23VehicleSpawn par1Packet23VehicleSpawn) { float d = par1Packet23VehicleSpawn.XPosition / 3F; float d1 = par1Packet23VehicleSpawn.YPosition / 3F; float d2 = par1Packet23VehicleSpawn.ZPosition / 3F; Entity obj = null; if (par1Packet23VehicleSpawn.Type == 10) { obj = new EntityMinecart(WorldClient, d, d1, d2, 0); } else if (par1Packet23VehicleSpawn.Type == 11) { obj = new EntityMinecart(WorldClient, d, d1, d2, 1); } else if (par1Packet23VehicleSpawn.Type == 12) { obj = new EntityMinecart(WorldClient, d, d1, d2, 2); } else if (par1Packet23VehicleSpawn.Type == 90) { obj = new EntityFishHook(WorldClient, d, d1, d2); } else if (par1Packet23VehicleSpawn.Type == 60) { obj = new EntityArrow(WorldClient, d, d1, d2); } else if (par1Packet23VehicleSpawn.Type == 61) { obj = new EntitySnowball(WorldClient, d, d1, d2); } else if (par1Packet23VehicleSpawn.Type == 65) { obj = new EntityEnderPearl(WorldClient, d, d1, d2); } else if (par1Packet23VehicleSpawn.Type == 72) { obj = new EntityEnderEye(WorldClient, d, d1, d2); } else if (par1Packet23VehicleSpawn.Type == 63) { obj = new EntityFireball(WorldClient, d, d1, d2, par1Packet23VehicleSpawn.SpeedX / 8000F, par1Packet23VehicleSpawn.SpeedY / 8000F, par1Packet23VehicleSpawn.SpeedZ / 8000F); par1Packet23VehicleSpawn.ThrowerEntityId = 0; } else if (par1Packet23VehicleSpawn.Type == 64) { obj = new EntitySmallFireball(WorldClient, d, d1, d2, par1Packet23VehicleSpawn.SpeedX / 8000F, par1Packet23VehicleSpawn.SpeedY / 8000F, par1Packet23VehicleSpawn.SpeedZ / 8000F); par1Packet23VehicleSpawn.ThrowerEntityId = 0; } else if (par1Packet23VehicleSpawn.Type == 62) { obj = new EntityEgg(WorldClient, d, d1, d2); } else if (par1Packet23VehicleSpawn.Type == 73) { obj = new EntityPotion(WorldClient, d, d1, d2, par1Packet23VehicleSpawn.ThrowerEntityId); par1Packet23VehicleSpawn.ThrowerEntityId = 0; } else if (par1Packet23VehicleSpawn.Type == 75) { obj = new EntityExpBottle(WorldClient, d, d1, d2); par1Packet23VehicleSpawn.ThrowerEntityId = 0; } else if (par1Packet23VehicleSpawn.Type == 1) { obj = new EntityBoat(WorldClient, d, d1, d2); } else if (par1Packet23VehicleSpawn.Type == 50) { obj = new EntityTNTPrimed(WorldClient, d, d1, d2); } else if (par1Packet23VehicleSpawn.Type == 51) { obj = new EntityEnderCrystal(WorldClient, d, d1, d2); } else if (par1Packet23VehicleSpawn.Type == 70) { obj = new EntityFallingSand(WorldClient, d, d1, d2, Block.Sand.BlockID); } else if (par1Packet23VehicleSpawn.Type == 71) { obj = new EntityFallingSand(WorldClient, d, d1, d2, Block.Gravel.BlockID); } else if (par1Packet23VehicleSpawn.Type == 74) { obj = new EntityFallingSand(WorldClient, d, d1, d2, Block.DragonEgg.BlockID); } if (obj != null) { obj.ServerPosX = par1Packet23VehicleSpawn.XPosition; obj.ServerPosY = par1Packet23VehicleSpawn.YPosition; obj.ServerPosZ = par1Packet23VehicleSpawn.ZPosition; obj.RotationYaw = 0.0F; obj.RotationPitch = 0.0F; Entity[] aentity = ((Entity)(obj)).GetParts(); if (aentity != null) { int i = par1Packet23VehicleSpawn.EntityId - ((Entity)(obj)).EntityId; for (int j = 0; j < aentity.Length; j++) { aentity[j].EntityId += i; } } obj.EntityId = par1Packet23VehicleSpawn.EntityId; WorldClient.AddEntityToWorld(par1Packet23VehicleSpawn.EntityId, ((Entity)(obj))); if (par1Packet23VehicleSpawn.ThrowerEntityId > 0) { if (par1Packet23VehicleSpawn.Type == 60) { Entity entity = GetEntityByID(par1Packet23VehicleSpawn.ThrowerEntityId); if (entity is EntityLiving) { ((EntityArrow)obj).ShootingEntity = (EntityLiving)entity; } } ((Entity)(obj)).SetVelocity(par1Packet23VehicleSpawn.SpeedX / 8000F, par1Packet23VehicleSpawn.SpeedY / 8000F, par1Packet23VehicleSpawn.SpeedZ / 8000F); } } }
/// <summary> /// dispenses an item from a randomly selected item stack from the blocks inventory into the game world. /// </summary> private void DispenseItem(World par1World, int par2, int par3, int par4, Random par5Random) { int i = par1World.GetBlockMetadata(par2, par3, par4); int j = 0; int k = 0; if (i == 3) { k = 1; } else if (i == 2) { k = -1; } else if (i == 5) { j = 1; } else { j = -1; } TileEntityDispenser tileentitydispenser = (TileEntityDispenser)par1World.GetBlockTileEntity(par2, par3, par4); if (tileentitydispenser != null) { ItemStack itemstack = tileentitydispenser.GetRandomStackFromInventory(); float d = par2 + j * 0.59999999999999998F + 0.5F; float d1 = par3 + 0.5F; float d2 = par4 + k * 0.59999999999999998F + 0.5F; if (itemstack == null) { par1World.PlayAuxSFX(1001, par2, par3, par4, 0); } else { if (itemstack.ItemID == Item.Arrow.ShiftedIndex) { EntityArrow entityarrow = new EntityArrow(par1World, d, d1, d2); entityarrow.SetArrowHeading(j, 0.10000000149011612F, k, 1.1F, 6F); entityarrow.DoesArrowBelongToPlayer = true; par1World.SpawnEntityInWorld(entityarrow); par1World.PlayAuxSFX(1002, par2, par3, par4, 0); } else if (itemstack.ItemID == Item.Egg.ShiftedIndex) { EntityEgg entityegg = new EntityEgg(par1World, d, d1, d2); entityegg.SetThrowableHeading(j, 0.10000000149011612F, k, 1.1F, 6F); par1World.SpawnEntityInWorld(entityegg); par1World.PlayAuxSFX(1002, par2, par3, par4, 0); } else if (itemstack.ItemID == Item.Snowball.ShiftedIndex) { EntitySnowball entitysnowball = new EntitySnowball(par1World, d, d1, d2); entitysnowball.SetThrowableHeading(j, 0.10000000149011612F, k, 1.1F, 6F); par1World.SpawnEntityInWorld(entitysnowball); par1World.PlayAuxSFX(1002, par2, par3, par4, 0); } else if (itemstack.ItemID == Item.Potion.ShiftedIndex && ItemPotion.IsSplash(itemstack.GetItemDamage())) { EntityPotion entitypotion = new EntityPotion(par1World, d, d1, d2, itemstack.GetItemDamage()); entitypotion.SetThrowableHeading(j, 0.10000000149011612F, k, 1.375F, 3F); par1World.SpawnEntityInWorld(entitypotion); par1World.PlayAuxSFX(1002, par2, par3, par4, 0); } else if (itemstack.ItemID == Item.ExpBottle.ShiftedIndex) { EntityExpBottle entityexpbottle = new EntityExpBottle(par1World, d, d1, d2); entityexpbottle.SetThrowableHeading(j, 0.10000000149011612F, k, 1.375F, 3F); par1World.SpawnEntityInWorld(entityexpbottle); par1World.PlayAuxSFX(1002, par2, par3, par4, 0); } else if (itemstack.ItemID == Item.MonsterPlacer.ShiftedIndex) { ItemMonsterPlacer.Func_48440_a(par1World, itemstack.GetItemDamage(), d + j * 0.29999999999999999F, d1 - 0.29999999999999999F, d2 + k * 0.29999999999999999F); par1World.PlayAuxSFX(1002, par2, par3, par4, 0); } else if (itemstack.ItemID == Item.FireballCharge.ShiftedIndex) { EntitySmallFireball entitysmallfireball = new EntitySmallFireball(par1World, d + j * 0.29999999999999999F, d1, d2 + k * 0.29999999999999999F, j + par5Random.NextGaussian() * 0.050000000000000003F, par5Random.NextGaussian() * 0.050000000000000003F, k + par5Random.NextGaussian() * 0.050000000000000003F); par1World.SpawnEntityInWorld(entitysmallfireball); par1World.PlayAuxSFX(1009, par2, par3, par4, 0); } else { EntityItem entityitem = new EntityItem(par1World, d, d1 - 0.29999999999999999F, d2, itemstack); float d3 = par5Random.NextFloat() * 0.10000000000000001F + 0.20000000000000001F; entityitem.MotionX = j * d3; entityitem.MotionY = 0.20000000298023224F; entityitem.MotionZ = k * d3; entityitem.MotionX += par5Random.NextGaussian() * 0.0074999998323619366F * 6; entityitem.MotionY += par5Random.NextGaussian() * 0.0074999998323619366F * 6; entityitem.MotionZ += par5Random.NextGaussian() * 0.0074999998323619366F * 6; par1World.SpawnEntityInWorld(entityitem); par1World.PlayAuxSFX(1000, par2, par3, par4, 0); } par1World.PlayAuxSFX(2000, par2, par3, par4, j + 1 + (k + 1) * 3); } } }