Exemple #1
0
        /// <summary>
        /// The actual render method that is used in doRender
        /// </summary>
        public virtual void DoRenderFallingSand(EntityFallingSand par1EntityFallingSand, double par2, double par4, double par6, float par8, float par9)
        {
            //GL.PushMatrix();
            //GL.Translate((float)par2, (float)par4, (float)par6);
            LoadTexture("/terrain.png");
            Block block = Block.BlocksList[par1EntityFallingSand.BlockID];
            World world = par1EntityFallingSand.GetWorld();

            //GL.Disable(EnableCap.Lighting);

            if (block == Block.DragonEgg)
            {
                RenderBlocks.BlockAccess = world;
                Tessellator tessellator = Tessellator.Instance;
                tessellator.StartDrawingQuads();
                tessellator.SetTranslation((float)(-MathHelper2.Floor_double(par1EntityFallingSand.PosX)) - 0.5F, (float)(-MathHelper2.Floor_double(par1EntityFallingSand.PosY)) - 0.5F, (float)(-MathHelper2.Floor_double(par1EntityFallingSand.PosZ)) - 0.5F);
                RenderBlocks.RenderBlockByRenderType(block, MathHelper2.Floor_double(par1EntityFallingSand.PosX), MathHelper2.Floor_double(par1EntityFallingSand.PosY), MathHelper2.Floor_double(par1EntityFallingSand.PosZ));
                tessellator.SetTranslation(0.0F, 0.0F, 0.0F);
                tessellator.Draw();
            }
            else
            {
                RenderBlocks.RenderBlockFallingSand(block, world, MathHelper2.Floor_double(par1EntityFallingSand.PosX), MathHelper2.Floor_double(par1EntityFallingSand.PosY), MathHelper2.Floor_double(par1EntityFallingSand.PosZ));
            }

            //GL.Enable(EnableCap.Lighting);
            //GL.PopMatrix();
        }
Exemple #2
0
        public virtual void RenderPiston(TileEntityPiston par1TileEntityPiston, double par2, double par4, double par6, float par8)
        {
            Block block = Block.BlocksList[par1TileEntityPiston.GetStoredBlockID()];

            if (block != null && par1TileEntityPiston.GetProgress(par8) < 1.0F)
            {
                Tessellator tessellator = Tessellator.Instance;
                BindTextureByName("/terrain.png");
                RenderHelper.DisableStandardItemLighting();
                //GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
                //GL.Enable(EnableCap.Blend);
                //GL.Disable(EnableCap.CullFace);

                if (Minecraft.IsAmbientOcclusionEnabled())
                {
                    //GL.ShadeModel(ShadingModel.Smooth);
                }
                else
                {
                    //GL.ShadeModel(ShadingModel.Flat);
                }

                tessellator.StartDrawingQuads();
                tessellator.SetTranslation(((float)par2 - (float)par1TileEntityPiston.XCoord) + par1TileEntityPiston.GetOffsetX(par8), ((float)par4 - (float)par1TileEntityPiston.YCoord) + par1TileEntityPiston.GetOffsetY(par8), ((float)par6 - (float)par1TileEntityPiston.ZCoord) + par1TileEntityPiston.GetOffsetZ(par8));
                tessellator.SetColorOpaque(1, 1, 1);

                if (block == Block.PistonExtension && par1TileEntityPiston.GetProgress(par8) < 0.5F)
                {
                    BlockRenderer.RenderPistonExtensionAllFaces(block, par1TileEntityPiston.XCoord, par1TileEntityPiston.YCoord, par1TileEntityPiston.ZCoord, false);
                }
                else if (par1TileEntityPiston.ShouldRenderHead() && !par1TileEntityPiston.IsExtending())
                {
                    Block.PistonExtension.SetHeadTexture(((BlockPistonBase)block).GetPistonExtensionTexture());
                    BlockRenderer.RenderPistonExtensionAllFaces(Block.PistonExtension, par1TileEntityPiston.XCoord, par1TileEntityPiston.YCoord, par1TileEntityPiston.ZCoord, par1TileEntityPiston.GetProgress(par8) < 0.5F);
                    Block.PistonExtension.ClearHeadTexture();
                    tessellator.SetTranslation((float)par2 - (float)par1TileEntityPiston.XCoord, (float)par4 - (float)par1TileEntityPiston.YCoord, (float)par6 - (float)par1TileEntityPiston.ZCoord);
                    BlockRenderer.RenderPistonBaseAllFaces(block, par1TileEntityPiston.XCoord, par1TileEntityPiston.YCoord, par1TileEntityPiston.ZCoord);
                }
                else
                {
                    BlockRenderer.RenderBlockAllFaces(block, par1TileEntityPiston.XCoord, par1TileEntityPiston.YCoord, par1TileEntityPiston.ZCoord);
                }

                tessellator.SetTranslation(0.0F, 0.0F, 0.0F);
                tessellator.Draw();
                RenderHelper.EnableStandardItemLighting();
            }
        }
        /// <summary>
        /// Renders a white box with the bounds of the AABB translated by the offset. Args: aabb, x, y, z
        /// </summary>
        public static void RenderOffsetAABB(AxisAlignedBB par0AxisAlignedBB, double par1, double par3, double par5)
        {
            //GL.Disable(EnableCap.Texture2D);
            Tessellator tessellator = Tessellator.Instance;

            //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
            tessellator.StartDrawingQuads();
            tessellator.SetTranslation(par1, par3, par5);
            tessellator.SetNormal(0.0F, 0.0F, -1F);
            tessellator.AddVertex(par0AxisAlignedBB.MinX, par0AxisAlignedBB.MaxY, par0AxisAlignedBB.MinZ);
            tessellator.AddVertex(par0AxisAlignedBB.MaxX, par0AxisAlignedBB.MaxY, par0AxisAlignedBB.MinZ);
            tessellator.AddVertex(par0AxisAlignedBB.MaxX, par0AxisAlignedBB.MinY, par0AxisAlignedBB.MinZ);
            tessellator.AddVertex(par0AxisAlignedBB.MinX, par0AxisAlignedBB.MinY, par0AxisAlignedBB.MinZ);
            tessellator.SetNormal(0.0F, 0.0F, 1.0F);
            tessellator.AddVertex(par0AxisAlignedBB.MinX, par0AxisAlignedBB.MinY, par0AxisAlignedBB.MaxZ);
            tessellator.AddVertex(par0AxisAlignedBB.MaxX, par0AxisAlignedBB.MinY, par0AxisAlignedBB.MaxZ);
            tessellator.AddVertex(par0AxisAlignedBB.MaxX, par0AxisAlignedBB.MaxY, par0AxisAlignedBB.MaxZ);
            tessellator.AddVertex(par0AxisAlignedBB.MinX, par0AxisAlignedBB.MaxY, par0AxisAlignedBB.MaxZ);
            tessellator.SetNormal(0.0F, -1F, 0.0F);
            tessellator.AddVertex(par0AxisAlignedBB.MinX, par0AxisAlignedBB.MinY, par0AxisAlignedBB.MinZ);
            tessellator.AddVertex(par0AxisAlignedBB.MaxX, par0AxisAlignedBB.MinY, par0AxisAlignedBB.MinZ);
            tessellator.AddVertex(par0AxisAlignedBB.MaxX, par0AxisAlignedBB.MinY, par0AxisAlignedBB.MaxZ);
            tessellator.AddVertex(par0AxisAlignedBB.MinX, par0AxisAlignedBB.MinY, par0AxisAlignedBB.MaxZ);
            tessellator.SetNormal(0.0F, 1.0F, 0.0F);
            tessellator.AddVertex(par0AxisAlignedBB.MinX, par0AxisAlignedBB.MaxY, par0AxisAlignedBB.MaxZ);
            tessellator.AddVertex(par0AxisAlignedBB.MaxX, par0AxisAlignedBB.MaxY, par0AxisAlignedBB.MaxZ);
            tessellator.AddVertex(par0AxisAlignedBB.MaxX, par0AxisAlignedBB.MaxY, par0AxisAlignedBB.MinZ);
            tessellator.AddVertex(par0AxisAlignedBB.MinX, par0AxisAlignedBB.MaxY, par0AxisAlignedBB.MinZ);
            tessellator.SetNormal(-1F, 0.0F, 0.0F);
            tessellator.AddVertex(par0AxisAlignedBB.MinX, par0AxisAlignedBB.MinY, par0AxisAlignedBB.MaxZ);
            tessellator.AddVertex(par0AxisAlignedBB.MinX, par0AxisAlignedBB.MaxY, par0AxisAlignedBB.MaxZ);
            tessellator.AddVertex(par0AxisAlignedBB.MinX, par0AxisAlignedBB.MaxY, par0AxisAlignedBB.MinZ);
            tessellator.AddVertex(par0AxisAlignedBB.MinX, par0AxisAlignedBB.MinY, par0AxisAlignedBB.MinZ);
            tessellator.SetNormal(1.0F, 0.0F, 0.0F);
            tessellator.AddVertex(par0AxisAlignedBB.MaxX, par0AxisAlignedBB.MinY, par0AxisAlignedBB.MinZ);
            tessellator.AddVertex(par0AxisAlignedBB.MaxX, par0AxisAlignedBB.MaxY, par0AxisAlignedBB.MinZ);
            tessellator.AddVertex(par0AxisAlignedBB.MaxX, par0AxisAlignedBB.MaxY, par0AxisAlignedBB.MaxZ);
            tessellator.AddVertex(par0AxisAlignedBB.MaxX, par0AxisAlignedBB.MinY, par0AxisAlignedBB.MaxZ);
            tessellator.SetTranslation(0.0F, 0.0F, 0.0F);
            tessellator.Draw();
            //GL.Enable(EnableCap.Texture2D);
        }
        /// <summary>
        /// Will update this chunk renderer
        /// </summary>
        public void UpdateRenderer()
        {
            if (!NeedsUpdate)
            {
                return;
            }

            NeedsUpdate = false;
            int i  = PosX;
            int j  = PosY;
            int k  = PosZ;
            int l  = PosX + 16;
            int i1 = PosY + 16;
            int j1 = PosZ + 16;

            for (int k1 = 0; k1 < 2; k1++)
            {
                SkipRenderPass[k1] = true;
            }

            Chunk.IsLit = false;
            List <TileEntity> hashset = new List <TileEntity>();

            hashset.AddRange(TileEntityRenderers);
            TileEntityRenderers.Clear();
            int        l1         = 1;
            ChunkCache chunkcache = new ChunkCache(WorldObj, i - l1, j - l1, k - l1, l + l1, i1 + l1, j1 + l1);

            if (!chunkcache.Func_48452_a())
            {
                ChunksUpdated++;
                RenderBlocks renderblocks = new RenderBlocks(chunkcache);
                BytesDrawn = 0;
                int i2 = 0;

                do
                {
                    if (i2 >= 2)
                    {
                        break;
                    }

                    bool flag  = false;
                    bool flag1 = false;
                    bool flag2 = false;

                    for (int j2 = j; j2 < i1; j2++)
                    {
                        for (int k2 = k; k2 < j1; k2++)
                        {
                            for (int l2 = i; l2 < l; l2++)
                            {
                                int i3 = chunkcache.GetBlockId(l2, j2, k2);

                                if (i3 <= 0)
                                {
                                    continue;
                                }

                                if (!flag2)
                                {
                                    flag2 = true;
                                    //GL.NewList(GlRenderList + i2, ListMode.Compile);
                                    //GL.PushMatrix();
                                    SetupGLTranslation();
                                    float f = 1.000001F;
                                    //GL.Translate(-8F, -8F, -8F);
                                    //GL.Scale(f, f, f);
                                    //GL.Translate(8F, 8F, 8F);
                                    Tessellator.StartDrawingQuads();
                                    Tessellator.SetTranslation(-PosX, -PosY, -PosZ);
                                }

                                if (i2 == 0 && Block.BlocksList[i3].HasTileEntity())
                                {
                                    TileEntity tileentity = chunkcache.GetBlockTileEntity(l2, j2, k2);

                                    if (TileEntityRenderer.Instance.HasSpecialRenderer(tileentity))
                                    {
                                        TileEntityRenderers.Add(tileentity);
                                    }
                                }

                                Block block = Block.BlocksList[i3];
                                int   j3    = block.GetRenderBlockPass();

                                if (j3 != i2)
                                {
                                    flag = true;
                                    continue;
                                }

                                if (j3 == i2)
                                {
                                    flag1 |= renderblocks.RenderBlockByRenderType(block, l2, j2, k2);
                                }
                            }
                        }
                    }

                    if (flag2)
                    {
                        BytesDrawn += Tessellator.Draw();
                        //GL.PopMatrix();
                        //GL.EndList();
                        Tessellator.SetTranslation(0.0F, 0.0F, 0.0F);
                    }
                    else
                    {
                        flag1 = false;
                    }

                    if (flag1)
                    {
                        SkipRenderPass[i2] = false;
                    }

                    if (!flag)
                    {
                        break;
                    }

                    i2++;
                }while (true);
            }

            List <TileEntity> hashset1 = new List <TileEntity>();

            hashset1.AddRange(TileEntityRenderers);

            foreach (TileEntity te in hashset)
            {
                hashset1.Remove(te);
            }

            TileEntities.AddRange(hashset1);

            foreach (TileEntity te in TileEntityRenderers)
            {
                hashset.Remove(te);
            }

            foreach (TileEntity te in hashset)
            {
                TileEntities.Remove(te);
            }

            IsChunkLit    = Chunk.IsLit;
            IsInitialized = true;
        }