public int getBlockTextureFromSideAndMetadata(int par1, int par2)
    {
        if (par1 == 0)
        {
            return Block.planks.blockIndexInTexture;
        }

        int i = getDirection(par2);
        int j = Direction.bedDirection[i][par1];

        if (isBlockFootOfBed(par2))
        {
            if (j == 2)
            {
                return blockIndexInTexture + 2 + 16;
            }

            if (j == 5 || j == 4)
            {
                return blockIndexInTexture + 1 + 16;
            }
            else
            {
                return blockIndexInTexture + 1;
            }
        }

        if (j == 3)
        {
            return (blockIndexInTexture - 1) + 16;
        }

        if (j == 5 || j == 4)
        {
            return blockIndexInTexture + 16;
        }
        else
        {
            return blockIndexInTexture;
        }
    }