static void createUI()
        {
            if (m_controlsInit)
            {
                return;
            }

            m_controlsInit = true;

            MyAPIGateway.TerminalControls.CustomControlGetter -= customControlGetter;

            MyAPIGateway.TerminalControls.CustomControlGetter += customControlGetter;

            // sender/receiver switch
            m_controlSender         = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlOnOffSwitch, IMyRefinery>("Cython.OPT.SenderReceiver");
            m_controlSender.Enabled = (b) => true;
            m_controlSender.Visible = (b) => b.BlockDefinition.SubtypeId.Equals("LargeBlockSmallOpticalPowerTransmitter") || b.BlockDefinition.SubtypeId.Equals("SmallBlockSmallOpticalPowerTransmitter");
            m_controlSender.Title   = MyStringId.GetOrCompute("Mode");
            m_controlSender.Tooltip = MyStringId.GetOrCompute("Switches this transmitters mode to Sender or Receiver");
            m_controlSender.OnText  = MyStringId.GetOrCompute("Send");
            m_controlSender.OffText = MyStringId.GetOrCompute("Rec.");
            m_controlSender.Getter  = (b) => b.GameLogic.GetAs <OpticalPowerTransmitter>().m_sender;
            m_controlSender.Setter  = (b, v) => {
                b.GameLogic.GetAs <OpticalPowerTransmitter>().m_sender      = v;
                b.GameLogic.GetAs <OpticalPowerTransmitter>().m_info.sender = v;

                m_controlSender.UpdateVisual();
                m_controlPower.UpdateVisual();

                byte[] message   = new byte[13];
                byte[] messageId = BitConverter.GetBytes(3);
                byte[] entityId  = BitConverter.GetBytes(b.EntityId);

                for (int i = 0; i < 4; i++)
                {
                    message[i] = messageId[i];
                }

                for (int i = 0; i < 8; i++)
                {
                    message[i + 4] = entityId[i];
                }

                message[12] = BitConverter.GetBytes(v)[0];


                MyAPIGateway.Multiplayer.SendMessageToOthers(5910, message, true);
            };
            MyAPIGateway.TerminalControls.AddControl <IMyRefinery>(m_controlSender);

            // channel field
            m_controlId         = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlTextbox, IMyRefinery>("Cython.OPT.ID");
            m_controlId.Enabled = (b) => true;
            m_controlId.Visible = (b) => b.BlockDefinition.SubtypeId.Equals("LargeBlockSmallOpticalPowerTransmitter") || b.BlockDefinition.SubtypeId.Equals("SmallBlockSmallOpticalPowerTransmitter");
            m_controlId.Title   = MyStringId.GetOrCompute("ID");
            m_controlId.Tooltip = MyStringId.GetOrCompute("ID this transmitter is being identified as when being receiver or it is supposed to send to.");
            m_controlId.Getter  = (b) => {
                if (b.GameLogic.GetAs <OpticalPowerTransmitter>().m_sender)
                {
                    return((new StringBuilder()).Append(b.GameLogic.GetAs <OpticalPowerTransmitter>().m_targetId));
                }
                else
                {
                    return((new StringBuilder()).Append(b.GameLogic.GetAs <OpticalPowerTransmitter>().m_id));
                }
            };

            m_controlId.Setter = (b, s) => {
                uint id;

                if (uint.TryParse(s.ToString(), out id))
                {
                    var OPT = b.GameLogic.GetAs <OpticalPowerTransmitter>();
                    if (OPT.m_sender)
                    {
                        OPT.m_targetId = id;
                    }
                    else
                    {
                        OPT.m_id      = id;
                        OPT.m_info.id = id;
                    }

                    byte[] message   = new byte[16];
                    byte[] messageId = BitConverter.GetBytes(4);
                    byte[] entityId  = BitConverter.GetBytes(b.EntityId);
                    byte[] value     = BitConverter.GetBytes(id);

                    for (int i = 0; i < 4; i++)
                    {
                        message[i] = messageId[i];
                    }

                    for (int i = 0; i < 8; i++)
                    {
                        message[i + 4] = entityId[i];
                    }

                    for (int i = 0; i < 4; i++)
                    {
                        message[i + 12] = value[i];
                    }

                    MyAPIGateway.Multiplayer.SendMessageToOthers(5910, message, true);
                }
            };

            MyAPIGateway.TerminalControls.AddControl <Sandbox.ModAPI.Ingame.IMyRefinery>(m_controlId);


            // power field
            m_controlPower         = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlTextbox, Sandbox.ModAPI.Ingame.IMyRefinery>("Cython.OPT.Power");
            m_controlPower.Enabled = (b) => b.GameLogic.GetAs <OpticalPowerTransmitter>().m_sender;
            m_controlPower.Visible = (b) => b.BlockDefinition.SubtypeId.Equals("LargeBlockSmallOpticalPowerTransmitter") || b.BlockDefinition.SubtypeId.Equals("SmallBlockSmallOpticalPowerTransmitter");
            m_controlPower.Title   = MyStringId.GetOrCompute("Power");
            m_controlPower.Tooltip = MyStringId.GetOrCompute("Maximum power this transmitter is supposed to send.");
            m_controlPower.Getter  = (b) => (new StringBuilder()).Append(b.GameLogic.GetAs <OpticalPowerTransmitter>().m_transmittedPower);
            m_controlPower.Setter  = (b, s) => {
                float power;

                if (float.TryParse(s.ToString(), out power))
                {
                    var OPT = b.GameLogic.GetAs <OpticalPowerTransmitter>();

                    OPT.m_transmittedPower = power;

                    if (OPT.m_transmittedPower > OPT.m_currentMaxPower)
                    {
                        OPT.m_transmittedPower = OPT.m_currentMaxPower;
                    }

                    byte[] message   = new byte[16];
                    byte[] messageId = BitConverter.GetBytes(5);
                    byte[] entityId  = BitConverter.GetBytes(b.EntityId);
                    byte[] value     = BitConverter.GetBytes(OPT.m_transmittedPower);

                    for (int i = 0; i < 4; i++)
                    {
                        message[i] = messageId[i];
                    }

                    for (int i = 0; i < 8; i++)
                    {
                        message[i + 4] = entityId[i];
                    }

                    for (int i = 0; i < 4; i++)
                    {
                        message[i + 12] = value[i];
                    }

                    MyAPIGateway.Multiplayer.SendMessageToOthers(5910, message, true);
                }
            };

            MyAPIGateway.TerminalControls.AddControl <IMyRefinery>(m_controlPower);
        }