Пример #1
0
        /// <summary>
        /// Renders the entity shadows at the position, shadow alpha and partialTickTime. Args: entity, x, y, z, shadowAlpha,
        /// partialTickTime
        /// </summary>
        private void RenderShadow(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
        {
            //GL.Enable(EnableCap.Blend);
            //GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            RenderEngine renderengine = RenderManager.RenderEngine;

            renderengine.BindTexture("misc.shadow.png", TextureMode.Clamp);
            World world = GetWorldFromRenderManager();
            //GL.DepthMask(false);
            float f = ShadowSize;

            if (par1Entity is EntityLiving)
            {
                EntityLiving entityliving = (EntityLiving)par1Entity;
                f *= entityliving.GetRenderSizeModifier();

                if (entityliving is EntityAnimal)
                {
                    EntityAnimal entityanimal = (EntityAnimal)entityliving;

                    if (entityanimal.IsChild())
                    {
                        f *= 0.5F;
                    }
                }
            }

            double      d           = par1Entity.LastTickPosX + (par1Entity.PosX - par1Entity.LastTickPosX) * (double)par9;
            double      d1          = par1Entity.LastTickPosY + (par1Entity.PosY - par1Entity.LastTickPosY) * (double)par9 + (double)par1Entity.GetShadowSize();
            double      d2          = par1Entity.LastTickPosZ + (par1Entity.PosZ - par1Entity.LastTickPosZ) * (double)par9;
            int         i           = MathHelper2.Floor_double(d - (double)f);
            int         j           = MathHelper2.Floor_double(d + (double)f);
            int         k           = MathHelper2.Floor_double(d1 - (double)f);
            int         l           = MathHelper2.Floor_double(d1);
            int         i1          = MathHelper2.Floor_double(d2 - (double)f);
            int         j1          = MathHelper2.Floor_double(d2 + (double)f);
            double      d3          = par2 - d;
            double      d4          = par4 - d1;
            double      d5          = par6 - d2;
            Tessellator tessellator = Tessellator.Instance;

            tessellator.StartDrawingQuads();

            for (int k1 = i; k1 <= j; k1++)
            {
                for (int l1 = k; l1 <= l; l1++)
                {
                    for (int i2 = i1; i2 <= j1; i2++)
                    {
                        int j2 = world.GetBlockId(k1, l1 - 1, i2);

                        if (j2 > 0 && world.GetBlockLightValue(k1, l1, i2) > 3)
                        {
                            RenderShadowOnBlock(Block.BlocksList[j2], par2, par4 + (double)par1Entity.GetShadowSize(), par6, k1, l1, i2, par8, f, d3, d4 + (double)par1Entity.GetShadowSize(), d5);
                        }
                    }
                }
            }

            tessellator.Draw();
            //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
            //GL.Disable(EnableCap.Blend);
            //GL.DepthMask(true);
        }