public override void Render(double delta)
        {
            IGraphicsApi gfx = game.Graphics;

            gfx.Draw2DQuad(TableX, TableY, TableWidth, TableHeight, topBackCol, bottomBackCol);
            if (totalRows > MaxRowsDisplayed)
            {
                scroll.Render(delta);
            }

            if (SelectedIndex != -1 && game.ClassicMode)
            {
                int x, y;
                GetCoords(SelectedIndex, out x, out y);
                float off  = blockSize * 0.1f;
                int   size = (int)(blockSize + off * 2);
                gfx.Draw2DQuad((int)(x - off), (int)(y - off),
                               size, size, topSelCol, bottomSelCol);
            }
            gfx.Texturing = true;
            gfx.SetBatchFormat(VertexFormat.P3fT2fC4b);

            drawer.BeginBatch(game, vertices, vb);
            for (int i = 0; i < Elements.Length; i++)
            {
                int x, y;
                if (!GetCoords(i, out x, out y))
                {
                    continue;
                }

                // We want to always draw the selected block on top of others
                if (i == SelectedIndex)
                {
                    continue;
                }
                drawer.DrawBatch(Elements[i], blockSize * 0.7f / 2f,
                                 x + blockSize / 2, y + blockSize / 2);
            }

            if (SelectedIndex != -1)
            {
                int x, y;
                GetCoords(SelectedIndex, out x, out y);
                drawer.DrawBatch(Elements[SelectedIndex], (blockSize + selBlockExpand) * 0.7f / 2,
                                 x + blockSize / 2, y + blockSize / 2);
            }
            drawer.EndBatch();

            if (descTex.IsValid)
            {
                descTex.Render(gfx);
            }
            gfx.Texturing = false;
        }
        public override void Render(double delta)
        {
            IGraphicsApi gfx = game.Graphics;

            gfx.Draw2DQuad(TableX, TableY, TableWidth, TableHeight, topBackCol, bottomBackCol);
            if (totalRows > MaxRowsDisplayed)
            {
                scroll.Render(delta);
            }

            if (SelectedIndex != -1 && !CraftingSelected && !CraftedSelected)
            {
                int x, y;
                GetCoords(SelectedIndex, out x, out y);
                float off  = blockSize * 0.1f;
                int   size = (int)(blockSize + off * 2);
                gfx.Draw2DQuad((int)(x - off), (int)(y - off),
                               size, size, topSelCol, bottomSelCol);
            }
            else if (SelectedIndex != -1 && CraftingSelected)
            {
                int x, y;
                GetCoords2(SelectedIndex, out x, out y);
                float off  = blockSize * 0.1f;
                int   size = (int)(blockSize + off * 2);
                gfx.Draw2DQuad((int)(x - off), (int)(y - off),
                               size, size, topSelCol, bottomSelCol);
            }
            else if (SelectedIndex != -1 && CraftedSelected)
            {
                int x, y;
                GetCoords3(SelectedIndex, out x, out y);
                float off  = blockSize * 0.1f;
                int   size = (int)(blockSize + off * 2);
                gfx.Draw2DQuad((int)(x - off), (int)(y - off),
                               size, size, topSelCol, bottomSelCol);
            }
            gfx.Texturing = true;
            gfx.SetBatchFormat(VertexFormat.P3fT2fC4bN1v);

            drawer.BeginBatch(game, vertices, vb);
            for (int i = 0; i < game.SurvInv.ItemList.Length; i++)
            {
                int x, y;
                if (!GetCoords(i, out x, out y))
                {
                    continue;
                }

                // We want to always draw the selected block on top of others
                if (i == SelectedIndex && !CraftingSelected && !CraftedSelected)
                {
                    continue;
                }

                BlockID block;
                if (game.SurvInv.ItemList[i] != null)
                {
                    block = (BlockID)game.SurvInv.ItemList[i].id;
                }
                else
                {
                    block = Block.Air;
                }

                drawer.DrawBatch(block, blockSize * 0.7f / 2f,
                                 x + blockSize / 2, y + blockSize / 2);
            }

            for (int i = 0; i < CraftingItems.Length; i++)
            {
                int x, y;
                if (!GetCoords2(i, out x, out y))
                {
                    continue;
                }

                // We want to always draw the selected block on top of others
                if (i == SelectedIndex && CraftingSelected)
                {
                    continue;
                }

                BlockID block;
                if (CraftingItems[i] != null)
                {
                    block = (BlockID)CraftingItems[i].id;
                }
                else
                {
                    block = Block.Air;
                }

                drawer.DrawBatch(block, blockSize * 0.7f / 2f,
                                 x + blockSize / 2, y + blockSize / 2);
            }

            for (int i = 0; i == 0; i++)
            {
                int x, y;
                if (!GetCoords3(i, out x, out y))
                {
                    continue;
                }

                // We want to always draw the selected block on top of others
                if (i == SelectedIndex && CraftedSelected)
                {
                    continue;
                }

                BlockID block;
                if (CraftedItem != null)
                {
                    block = (BlockID)CraftedItem.id;
                }
                else
                {
                    block = Block.Air;
                }

                drawer.DrawBatch(block, blockSize * 0.7f / 2f,
                                 x + blockSize / 2, y + blockSize / 2);
            }

            if (SelectedIndex != -1 && !CraftingSelected && !CraftedSelected)
            {
                int x, y;
                GetCoords(SelectedIndex, out x, out y);

                BlockID block;
                if (game.SurvInv.ItemList[SelectedIndex] != null)
                {
                    block = (BlockID)game.SurvInv.ItemList[SelectedIndex].id;
                }
                else
                {
                    block = Block.Air;
                }

                drawer.DrawBatch(block, (blockSize + selBlockExpand) * 0.7f / 2,
                                 x + blockSize / 2, y + blockSize / 2);
            }
            else if (SelectedIndex != -1 && CraftingSelected)
            {
                int x, y;
                GetCoords2(SelectedIndex, out x, out y);

                BlockID block;
                if (CraftingItems[SelectedIndex] != null)
                {
                    block = (BlockID)CraftingItems[SelectedIndex].id;
                }
                else
                {
                    block = Block.Air;
                }

                drawer.DrawBatch(block, (blockSize + selBlockExpand) * 0.7f / 2,
                                 x + blockSize / 2, y + blockSize / 2);
            }
            else if (SelectedIndex != -1 && CraftedSelected)
            {
                int x, y;
                GetCoords3(SelectedIndex, out x, out y);

                BlockID block;
                if (CraftedItem != null)
                {
                    block = (BlockID)CraftedItem.id;
                }
                else
                {
                    block = Block.Air;
                }

                drawer.DrawBatch(block, (blockSize + selBlockExpand) * 0.7f / 2,
                                 x + blockSize / 2, y + blockSize / 2);
            }

            drawer.EndBatch();

            DrawCounts();

            drawer.BeginBatch(game, vertices, vb);

            if (cursorItem != null)
            {
                Point cursorPos = game.DesktopCursorPos;
                Point topLeft   = game.PointToScreen(Point.Empty);
                cursorPos.X -= topLeft.X; cursorPos.Y -= topLeft.Y;
                drawer.DrawBatch(cursorItem.id, (blockSize + selBlockExpand) * 0.7f / 2,
                                 cursorPos.X, cursorPos.Y);
            }

            drawer.EndBatch();

            DrawHeldCount();

            if (descTex.IsValid)
            {
                descTex.Render(gfx);
            }
            gfx.Texturing = false;
        }