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);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Called when the entity is attacked.
        /// </summary>
        public override bool AttackEntityFrom(DamageSource par1DamageSource, int par2)
        {
            if (WorldObj.IsRemote || IsDead)
            {
                return(true);
            }

            Func_41029_h(-Func_41030_m());
            Func_41028_c(10);
            SetBeenAttacked();
            Func_41024_b(Func_41025_i() + par2 * 10);

            if (Func_41025_i() > 40)
            {
                if (RiddenByEntity != null)
                {
                    RiddenByEntity.MountEntity(this);
                }

                SetDead();
                DropItemWithOffset(Item.MinecartEmpty.ShiftedIndex, 1, 0.0F);

                if (MinecartType == 1)
                {
                    EntityMinecart entityminecart = this;
label0:

                    for (int i = 0; i < entityminecart.GetSizeInventory(); i++)
                    {
                        ItemStack itemstack = entityminecart.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;
                            }

                            int j = Rand.Next(21) + 10;

                            if (j > itemstack.StackSize)
                            {
                                j = itemstack.StackSize;
                            }

                            itemstack.StackSize -= j;
                            EntityItem entityitem = new EntityItem(WorldObj, PosX + f, PosY + f1, PosZ + f2, new 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.SpawnEntityInWorld(entityitem);
                        }while (true);
                    }

                    DropItemWithOffset(Block.Chest.BlockID, 1, 0.0F);
                }
                else if (MinecartType == 2)
                {
                    DropItemWithOffset(Block.StoneOvenIdle.BlockID, 1, 0.0F);
                }
            }

            return(true);
        }
        public virtual void Func_152_a(EntityMinecart par1EntityMinecart, double par2, double par4, double par6, float par8, float par9)
        {
            //GL.PushMatrix();
            long l = (long)par1EntityMinecart.EntityId * 0x1d66f537L;

            l = l * l * 0x105cb26d1L + l * 0x181c9L;
            float f  = (((float)(l >> 16 & 7L) + 0.5F) / 8F - 0.5F) * 0.004F;
            float f1 = (((float)(l >> 20 & 7L) + 0.5F) / 8F - 0.5F) * 0.004F;
            float f2 = (((float)(l >> 24 & 7L) + 0.5F) / 8F - 0.5F) * 0.004F;
            //GL.Translate(f, f1, f2);
            double d     = par1EntityMinecart.LastTickPosX + (par1EntityMinecart.PosX - par1EntityMinecart.LastTickPosX) * (double)par9;
            double d1    = par1EntityMinecart.LastTickPosY + (par1EntityMinecart.PosY - par1EntityMinecart.LastTickPosY) * (double)par9;
            double d2    = par1EntityMinecart.LastTickPosZ + (par1EntityMinecart.PosZ - par1EntityMinecart.LastTickPosZ) * (double)par9;
            double d3    = 0.30000001192092896D;
            Vec3D  vec3d = par1EntityMinecart.Func_514_g(d, d1, d2);
            float  f3    = par1EntityMinecart.PrevRotationPitch + (par1EntityMinecart.RotationPitch - par1EntityMinecart.PrevRotationPitch) * par9;

            if (vec3d != null)
            {
                Vec3D vec3d1 = par1EntityMinecart.Func_515_a(d, d1, d2, d3);
                Vec3D vec3d2 = par1EntityMinecart.Func_515_a(d, d1, d2, -d3);

                if (vec3d1 == null)
                {
                    vec3d1 = vec3d;
                }

                if (vec3d2 == null)
                {
                    vec3d2 = vec3d;
                }

                par2 += vec3d.XCoord - d;
                par4 += (vec3d1.YCoord + vec3d2.YCoord) / 2D - d1;
                par6 += vec3d.ZCoord - d2;
                Vec3D vec3d3 = vec3d2.AddVector(-vec3d1.XCoord, -vec3d1.YCoord, -vec3d1.ZCoord);

                if (vec3d3.LengthVector() != 0.0F)
                {
                    vec3d3 = vec3d3.Normalize();
                    par8   = (float)((Math.Atan2(vec3d3.ZCoord, vec3d3.XCoord) * 180D) / Math.PI);
                    f3     = (float)(Math.Atan(vec3d3.YCoord) * 73D);
                }
            }

            //GL.Translate((float)par2, (float)par4, (float)par6);
            //GL.Rotate(180F - par8, 0.0F, 1.0F, 0.0F);
            //GL.Rotate(-f3, 0.0F, 0.0F, 1.0F);
            float f4 = (float)par1EntityMinecart.Func_41023_l() - par9;
            float f5 = (float)par1EntityMinecart.Func_41025_i() - par9;

            if (f5 < 0.0F)
            {
                f5 = 0.0F;
            }

            if (f4 > 0.0F)
            {
                //GL.Rotate(((MathHelper.Sin(f4) * f4 * f5) / 10F) * (float)par1EntityMinecart.Func_41030_m(), 1.0F, 0.0F, 0.0F);
            }

            if (par1EntityMinecart.MinecartType != 0)
            {
                LoadTexture("/terrain.png");
                float f6 = 0.75F;
                //GL.Scale(f6, f6, f6);

                if (par1EntityMinecart.MinecartType == 1)
                {
                    //GL.Translate(-0.5F, 0.0F, 0.5F);
                    //GL.Rotate(90F, 0.0F, 1.0F, 0.0F);
                    (new RenderBlocks()).RenderBlockAsItem(Block.Chest, 0, par1EntityMinecart.GetBrightness(par9));
                    //GL.Rotate(-90F, 0.0F, 1.0F, 0.0F);
                    //GL.Translate(0.5F, 0.0F, -0.5F);
                    //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
                }
                else if (par1EntityMinecart.MinecartType == 2)
                {
                    //GL.Translate(0.0F, 0.3125F, 0.0F);
                    //GL.Rotate(90F, 0.0F, 1.0F, 0.0F);
                    (new RenderBlocks()).RenderBlockAsItem(Block.StoneOvenIdle, 0, par1EntityMinecart.GetBrightness(par9));
                    //GL.Rotate(-90F, 0.0F, 1.0F, 0.0F);
                    //GL.Translate(0.0F, -0.3125F, 0.0F);
                    //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
                }

                //GL.Scale(1.0F / f6, 1.0F / f6, 1.0F / f6);
            }

            LoadTexture("/item/cart.png");
            //GL.Scale(-1F, -1F, 1.0F);
            ModelMinecart.Render(par1EntityMinecart, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
            //GL.PopMatrix();
        }