Exemplo n.º 1
0
        private RenderManager()
        {
            EntityRenderMap = new Dictionary <Type, Render>();
            EntityRenderMap[typeof(EntitySpider)]        = new RenderSpider();
            EntityRenderMap[typeof(EntityCaveSpider)]    = new RenderSpider();
            EntityRenderMap[typeof(EntityPig)]           = new RenderPig(new ModelPig(), new ModelPig(0.5F), 0.7F);
            EntityRenderMap[typeof(EntitySheep)]         = new RenderSheep(new ModelSheep2(), new ModelSheep1(), 0.7F);
            EntityRenderMap[typeof(EntityCow)]           = new RenderCow(new ModelCow(), 0.7F);
            EntityRenderMap[typeof(EntityMooshroom)]     = new RenderMooshroom(new ModelCow(), 0.7F);
            EntityRenderMap[typeof(EntityWolf)]          = new RenderWolf(new ModelWolf(), 0.5F);
            EntityRenderMap[typeof(EntityChicken)]       = new RenderChicken(new ModelChicken(), 0.3F);
            EntityRenderMap[typeof(EntityOcelot)]        = new RenderOcelot(new ModelOcelot(), 0.4F);
            EntityRenderMap[typeof(EntitySilverfish)]    = new RenderSilverfish();
            EntityRenderMap[typeof(EntityCreeper)]       = new RenderCreeper();
            EntityRenderMap[typeof(EntityEnderman)]      = new RenderEnderman();
            EntityRenderMap[typeof(EntitySnowman)]       = new RenderSnowMan();
            EntityRenderMap[typeof(EntitySkeleton)]      = new RenderBiped(new ModelSkeleton(), 0.5F);
            EntityRenderMap[typeof(EntityBlaze)]         = new RenderBlaze();
            EntityRenderMap[typeof(EntityZombie)]        = new RenderBiped(new ModelZombie(), 0.5F);
            EntityRenderMap[typeof(EntitySlime)]         = new RenderSlime(new ModelSlime(16), new ModelSlime(0), 0.25F);
            EntityRenderMap[typeof(EntityMagmaCube)]     = new RenderMagmaCube();
            EntityRenderMap[typeof(EntityPlayer)]        = new RenderPlayer();
            EntityRenderMap[typeof(EntityGiantZombie)]   = new RenderGiantZombie(new ModelZombie(), 0.5F, 6F);
            EntityRenderMap[typeof(EntityGhast)]         = new RenderGhast();
            EntityRenderMap[typeof(EntitySquid)]         = new RenderSquid(new ModelSquid(), 0.7F);
            EntityRenderMap[typeof(EntityVillager)]      = new RenderVillager();
            EntityRenderMap[typeof(EntityIronGolem)]     = new RenderIronGolem();
            EntityRenderMap[typeof(EntityLiving)]        = new RenderLiving(new ModelBiped(), 0.5F);
            EntityRenderMap[typeof(EntityDragon)]        = new RenderDragon();
            EntityRenderMap[typeof(EntityEnderCrystal)]  = new RenderEnderCrystal();
            EntityRenderMap[typeof(Entity)]              = new RenderEntity();
            EntityRenderMap[typeof(EntityPainting)]      = new RenderPainting();
            EntityRenderMap[typeof(EntityArrow)]         = new RenderArrow();
            EntityRenderMap[typeof(EntitySnowball)]      = new RenderSnowball(Item.Snowball.GetIconFromDamage(0));
            EntityRenderMap[typeof(EntityEnderPearl)]    = new RenderSnowball(Item.EnderPearl.GetIconFromDamage(0));
            EntityRenderMap[typeof(EntityEnderEye)]      = new RenderSnowball(Item.EyeOfEnder.GetIconFromDamage(0));
            EntityRenderMap[typeof(EntityEgg)]           = new RenderSnowball(Item.Egg.GetIconFromDamage(0));
            EntityRenderMap[typeof(EntityPotion)]        = new RenderSnowball(154);
            EntityRenderMap[typeof(EntityExpBottle)]     = new RenderSnowball(Item.ExpBottle.GetIconFromDamage(0));
            EntityRenderMap[typeof(EntityFireball)]      = new RenderFireball(2.0F);
            EntityRenderMap[typeof(EntitySmallFireball)] = new RenderFireball(0.5F);
            EntityRenderMap[typeof(EntityItem)]          = new RenderItem();
            EntityRenderMap[typeof(EntityXPOrb)]         = new RenderXPOrb();
            EntityRenderMap[typeof(EntityTNTPrimed)]     = new RenderTNTPrimed();
            EntityRenderMap[typeof(EntityFallingSand)]   = new RenderFallingSand();
            EntityRenderMap[typeof(EntityMinecart)]      = new RenderMinecart();
            EntityRenderMap[typeof(EntityBoat)]          = new RenderBoat();
            EntityRenderMap[typeof(EntityFishHook)]      = new RenderFish();
            EntityRenderMap[typeof(EntityLightningBolt)] = new RenderLightningBolt();
            Render render;

            for (IEnumerator <Render> iterator = EntityRenderMap.Values.GetEnumerator(); iterator.MoveNext(); render.SetRenderManager(this))
            {
                render = iterator.Current;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Renders the active item in the player's hand when in first person mode. Args: partialTickTime
        /// </summary>
        public virtual void RenderItemInFirstPerson(float par1)
        {
            float          f = PrevEquippedProgress + (EquippedProgress - PrevEquippedProgress) * par1;
            EntityPlayerSP entityplayersp = Mc.ThePlayer;
            float          f1             = ((EntityPlayer)(entityplayersp)).PrevRotationPitch + (((EntityPlayer)(entityplayersp)).RotationPitch - ((EntityPlayer)(entityplayersp)).PrevRotationPitch) * par1;

            //GL.PushMatrix();
            //GL.Rotate(f1, 1.0F, 0.0F, 0.0F);
            //GL.Rotate(((EntityPlayer)(entityplayersp)).PrevRotationYaw + (((EntityPlayer)(entityplayersp)).RotationYaw - ((EntityPlayer)(entityplayersp)).PrevRotationYaw) * par1, 0.0F, 1.0F, 0.0F);
            RenderHelper.EnableStandardItemLighting();
            //GL.PopMatrix();

            if (entityplayersp is EntityPlayerSP)
            {
                EntityPlayerSP entityplayersp1 = (EntityPlayerSP)entityplayersp;
                float          f2 = entityplayersp1.PrevRenderArmPitch + (entityplayersp1.RenderArmPitch - entityplayersp1.PrevRenderArmPitch) * par1;
                float          f4 = entityplayersp1.PrevRenderArmYaw + (entityplayersp1.RenderArmYaw - entityplayersp1.PrevRenderArmYaw) * par1;
                //GL.Rotate((((EntityPlayer)(entityplayersp)).RotationPitch - f2) * 0.1F, 1.0F, 0.0F, 0.0F);
                //GL.Rotate((((EntityPlayer)(entityplayersp)).RotationYaw - f4) * 0.1F, 0.0F, 1.0F, 0.0F);
            }

            ItemStack itemstack = ItemToRender;
            float     f3        = Mc.TheWorld.GetLightBrightness(MathHelper2.Floor_double(((EntityPlayer)(entityplayersp)).PosX), MathHelper2.Floor_double(((EntityPlayer)(entityplayersp)).PosY), MathHelper2.Floor_double(((EntityPlayer)(entityplayersp)).PosZ));

            f3 = 1.0F;
            int i = Mc.TheWorld.GetLightBrightnessForSkyBlocks(MathHelper2.Floor_double(((EntityPlayer)(entityplayersp)).PosX), MathHelper2.Floor_double(((EntityPlayer)(entityplayersp)).PosY), MathHelper2.Floor_double(((EntityPlayer)(entityplayersp)).PosZ), 0);
            int k = i % 0x10000;
            int l = i / 0x10000;

            OpenGlHelper.SetLightmapTextureCoords(OpenGlHelper.LightmapTexUnit, (float)k / 1.0F, (float)l / 1.0F);
            //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);

            if (itemstack != null)
            {
                int   j   = Item.ItemsList[itemstack.ItemID].GetColorFromDamage(itemstack.GetItemDamage(), 0);
                float f8  = (float)(j >> 16 & 0xff) / 255F;
                float f13 = (float)(j >> 8 & 0xff) / 255F;
                float f19 = (float)(j & 0xff) / 255F;
                //GL.Color4(f3 * f8, f3 * f13, f3 * f19, 1.0F);
            }
            else
            {
                //GL.Color4(f3, f3, f3, 1.0F);
            }

            if (itemstack != null && itemstack.ItemID == Item.Map.ShiftedIndex)
            {
                //GL.PushMatrix();
                //	float f5 = 0.8F;
                float f9  = entityplayersp.GetSwingProgress(par1);
                float f14 = MathHelper2.Sin(f9 * (float)Math.PI);
                float f20 = MathHelper2.Sin(MathHelper2.Sqrt_float(f9) * (float)Math.PI);
                //GL.Translate(-f20 * 0.4F, MathHelper.Sin(MathHelper.Sqrt_float(f9) * (float)Math.PI * 2.0F) * 0.2F, -f14 * 0.2F);
                f9 = (1.0F - f1 / 45F) + 0.1F;

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

                if (f9 > 1.0F)
                {
                    f9 = 1.0F;
                }

                f9 = -MathHelper2.Cos(f9 * (float)Math.PI) * 0.5F + 0.5F;
                //GL.Translate(0.0F, (0.0F * f5 - (1.0F - f) * 1.2F - f9 * 0.5F) + 0.04F, -0.9F * f5);
                //GL.Rotate(90F, 0.0F, 1.0F, 0.0F);
                //GL.Rotate(f9 * -85F, 0.0F, 0.0F, 1.0F);
                //GL.Enable(EnableCap.RescaleNormal);
                //GL.BindTexture(TextureTarget.Texture2D, Mc.RenderEngineOld.GetTextureForDownloadableImage(Mc.ThePlayer.SkinUrl, Mc.ThePlayer.GetTexture()));

                for (f14 = 0; f14 < 2; f14++)
                {
                    f20 = f14 * 2 - 1;
                    //GL.PushMatrix();
                    //GL.Translate(-0F, -0.6F, 1.1F * (float)f20);
                    //GL.Rotate(-45 * f20, 1.0F, 0.0F, 0.0F);
                    //GL.Rotate(-90F, 0.0F, 0.0F, 1.0F);
                    //GL.Rotate(59F, 0.0F, 0.0F, 1.0F);
                    //GL.Rotate(-65 * f20, 0.0F, 1.0F, 0.0F);
                    Render       render1       = RenderManager.Instance.GetEntityRenderObject(Mc.ThePlayer);
                    RenderPlayer renderplayer1 = (RenderPlayer)render1;
                    //	float f34 = 1.0F;
                    //GL.Scale(f34, f34, f34);
                    renderplayer1.DrawFirstPersonHand();
                    //GL.PopMatrix();
                }

                f14 = entityplayersp.GetSwingProgress(par1);
                f20 = MathHelper2.Sin(f14 * f14 * (float)Math.PI);
                float f27 = MathHelper2.Sin(MathHelper2.Sqrt_float(f14) * (float)Math.PI);
                //GL.Rotate(-f20 * 20F, 0.0F, 1.0F, 0.0F);
                //GL.Rotate(-f27 * 20F, 0.0F, 0.0F, 1.0F);
                //GL.Rotate(-f27 * 80F, 1.0F, 0.0F, 0.0F);
                f14 = 0.38F;
                //GL.Scale(f14, f14, f14);
                //GL.Rotate(90F, 0.0F, 1.0F, 0.0F);
                //GL.Rotate(180F, 0.0F, 0.0F, 1.0F);
                //GL.Translate(-1F, -1F, 0.0F);
                f20 = 0.015625F;
                //GL.Scale(f20, f20, f20);
                Mc.RenderEngineOld.BindTexture(Mc.RenderEngineOld.GetTexture("/misc/mapbg.png"));
                Tessellator tessellator = Tessellator.Instance;
                //GL.Normal3(0.0F, 0.0F, -1F);
                tessellator.StartDrawingQuads();
                sbyte byte0 = 7;
                tessellator.AddVertexWithUV(0 - byte0, 128 + byte0, 0.0F, 0.0F, 1.0D);
                tessellator.AddVertexWithUV(128 + byte0, 128 + byte0, 0.0F, 1.0D, 1.0D);
                tessellator.AddVertexWithUV(128 + byte0, 0 - byte0, 0.0F, 1.0D, 0.0F);
                tessellator.AddVertexWithUV(0 - byte0, 0 - byte0, 0.0F, 0.0F, 0.0F);
                tessellator.Draw();
                MapData mapdata = Item.Map.GetMapData(itemstack, Mc.TheWorld);
                MapItemRenderer.RenderMap(Mc.ThePlayer, Mc.RenderEngineOld, mapdata);
                //GL.PopMatrix();
            }
            else if (itemstack != null)
            {
                //GL.PushMatrix();
                //	float f6 = 0.8F;

                if (entityplayersp.GetItemInUseCount() > 0)
                {
                    EnumAction enumaction = itemstack.GetItemUseAction();

                    if (enumaction == EnumAction.Eat || enumaction == EnumAction.Drink)
                    {
                        float f15 = ((float)entityplayersp.GetItemInUseCount() - par1) + 1.0F;
                        float f21 = 1.0F - f15 / (float)itemstack.GetMaxItemUseDuration();
                        float f28 = f21;
                        float f31 = 1.0F - f28;
                        f31 = f31 * f31 * f31;
                        f31 = f31 * f31 * f31;
                        f31 = f31 * f31 * f31;
                        float f35 = 1.0F - f31;
                        //GL.Translate(0.0F, MathHelper.Abs(MathHelper.Cos((f15 / 4F) * (float)Math.PI) * 0.1F) * (float)((double)f28 <= 0.20000000000000001D ? 0 : 1), 0.0F);
                        //GL.Translate(f35 * 0.6F, -f35 * 0.5F, 0.0F);
                        //GL.Rotate(f35 * 90F, 0.0F, 1.0F, 0.0F);
                        //GL.Rotate(f35 * 10F, 1.0F, 0.0F, 0.0F);
                        //GL.Rotate(f35 * 30F, 0.0F, 0.0F, 1.0F);
                    }
                }
                else
                {
                    float f10 = entityplayersp.GetSwingProgress(par1);
                    float f16 = MathHelper2.Sin(f10 * (float)Math.PI);
                    float f22 = MathHelper2.Sin(MathHelper2.Sqrt_float(f10) * (float)Math.PI);
                    //GL.Translate(-f22 * 0.4F, MathHelper.Sin(MathHelper.Sqrt_float(f10) * (float)Math.PI * 2.0F) * 0.2F, -f16 * 0.2F);
                }

                //GL.Translate(0.7F * f6, -0.65F * f6 - (1.0F - f) * 0.6F, -0.9F * f6);
                //GL.Rotate(45F, 0.0F, 1.0F, 0.0F);
                //GL.Enable(EnableCap.RescaleNormal);
                float f11 = entityplayersp.GetSwingProgress(par1);
                float f17 = MathHelper2.Sin(f11 * f11 * (float)Math.PI);
                float f23 = MathHelper2.Sin(MathHelper2.Sqrt_float(f11) * (float)Math.PI);
                //GL.Rotate(-f17 * 20F, 0.0F, 1.0F, 0.0F);
                //GL.Rotate(-f23 * 20F, 0.0F, 0.0F, 1.0F);
                //GL.Rotate(-f23 * 80F, 1.0F, 0.0F, 0.0F);
                f11 = 0.4F;
                //GL.Scale(f11, f11, f11);

                if (entityplayersp.GetItemInUseCount() > 0)
                {
                    EnumAction enumaction1 = itemstack.GetItemUseAction();

                    if (enumaction1 == EnumAction.Block)
                    {
                        //GL.Translate(-0.5F, 0.2F, 0.0F);
                        //GL.Rotate(30F, 0.0F, 1.0F, 0.0F);
                        //GL.Rotate(-80F, 1.0F, 0.0F, 0.0F);
                        //GL.Rotate(60F, 0.0F, 1.0F, 0.0F);
                    }
                    else if (enumaction1 == EnumAction.Bow)
                    {
                        //GL.Rotate(-18F, 0.0F, 0.0F, 1.0F);
                        //GL.Rotate(-12F, 0.0F, 1.0F, 0.0F);
                        //GL.Rotate(-8F, 1.0F, 0.0F, 0.0F);
                        //GL.Translate(-0.9F, 0.2F, 0.0F);
                        float f24 = (float)itemstack.GetMaxItemUseDuration() - (((float)entityplayersp.GetItemInUseCount() - par1) + 1.0F);
                        float f29 = f24 / 20F;
                        f29 = (f29 * f29 + f29 * 2.0F) / 3F;

                        if (f29 > 1.0F)
                        {
                            f29 = 1.0F;
                        }

                        if (f29 > 0.1F)
                        {
                            //GL.Translate(0.0F, MathHelper.Sin((f24 - 0.1F) * 1.3F) * 0.01F * (f29 - 0.1F), 0.0F);
                        }

                        //GL.Translate(0.0F, 0.0F, f29 * 0.1F);
                        //GL.Rotate(-335F, 0.0F, 0.0F, 1.0F);
                        //GL.Rotate(-50F, 0.0F, 1.0F, 0.0F);
                        //GL.Translate(0.0F, 0.5F, 0.0F);
                        float f32 = 1.0F + f29 * 0.2F;
                        //GL.Scale(1.0F, 1.0F, f32);
                        //GL.Translate(0.0F, -0.5F, 0.0F);
                        //GL.Rotate(50F, 0.0F, 1.0F, 0.0F);
                        //GL.Rotate(335F, 0.0F, 0.0F, 1.0F);
                    }
                }

                if (itemstack.GetItem().ShouldRotateAroundWhenRendering())
                {
                    //GL.Rotate(180F, 0.0F, 1.0F, 0.0F);
                }

                if (itemstack.GetItem().Func_46058_c())
                {
                    RenderItem(entityplayersp, itemstack, 0);
                    int   i1  = Item.ItemsList[itemstack.ItemID].GetColorFromDamage(itemstack.GetItemDamage(), 1);
                    float f25 = (float)(i1 >> 16 & 0xff) / 255F;
                    float f30 = (float)(i1 >> 8 & 0xff) / 255F;
                    float f33 = (float)(i1 & 0xff) / 255F;
                    //GL.Color4(f3 * f25, f3 * f30, f3 * f33, 1.0F);
                    RenderItem(entityplayersp, itemstack, 1);
                }
                else
                {
                    RenderItem(entityplayersp, itemstack, 0);
                }

                //GL.PopMatrix();
            }
            else
            {
                //GL.PushMatrix();
                //	float f7 = 0.8F;
                float f12 = entityplayersp.GetSwingProgress(par1);
                float f18 = MathHelper2.Sin(f12 * (float)Math.PI);
                float f26 = MathHelper2.Sin(MathHelper2.Sqrt_float(f12) * (float)Math.PI);
                //GL.Translate(-f26 * 0.3F, MathHelper.Sin(MathHelper.Sqrt_float(f12) * (float)Math.PI * 2.0F) * 0.4F, -f18 * 0.4F);
                //GL.Translate(0.8F * f7, -0.75F * f7 - (1.0F - f) * 0.6F, -0.9F * f7);
                //GL.Rotate(45F, 0.0F, 1.0F, 0.0F);
                //GL.Enable(EnableCap.RescaleNormal);
                f12 = entityplayersp.GetSwingProgress(par1);
                f18 = MathHelper2.Sin(f12 * f12 * (float)Math.PI);
                f26 = MathHelper2.Sin(MathHelper2.Sqrt_float(f12) * (float)Math.PI);
                //GL.Rotate(f26 * 70F, 0.0F, 1.0F, 0.0F);
                //GL.Rotate(-f18 * 20F, 0.0F, 0.0F, 1.0F);
                //GL.BindTexture(TextureTarget.Texture2D, Mc.RenderEngineOld.GetTextureForDownloadableImage(Mc.ThePlayer.SkinUrl, Mc.ThePlayer.GetTexture()));
                //GL.Translate(-1F, 3.6F, 3.5F);
                //GL.Rotate(120F, 0.0F, 0.0F, 1.0F);
                //GL.Rotate(200F, 1.0F, 0.0F, 0.0F);
                //GL.Rotate(-135F, 0.0F, 1.0F, 0.0F);
                //GL.Scale(1.0F, 1.0F, 1.0F);
                //GL.Translate(5.6F, 0.0F, 0.0F);
                Render       render       = RenderManager.Instance.GetEntityRenderObject(Mc.ThePlayer);
                RenderPlayer renderplayer = (RenderPlayer)render;
                f26 = 1.0F;
                //GL.Scale(f26, f26, f26);
                renderplayer.DrawFirstPersonHand();
                //GL.PopMatrix();
            }

            //GL.Disable(EnableCap.RescaleNormal);
            RenderHelper.DisableStandardItemLighting();
        }