Пример #1
0
        public override void OnReceivedServerPacket(int packetid, byte[] data)
        {
            if (packetid == (int)EnumSignPacketId.OpenDialog)
            {
                using (MemoryStream ms = new MemoryStream(data))
                {
                    BinaryReader reader = new BinaryReader(ms);

                    string dialogClassName = reader.ReadString();
                    string dialogTitle     = reader.ReadString();
                    text = reader.ReadString();
                    if (text == null)
                    {
                        text = "";
                    }

                    IClientWorldAccessor clientWorld = (IClientWorldAccessor)api.World;

                    GuiDialogBlockEntityTextInput dlg = new GuiDialogBlockEntityTextInput(dialogTitle, pos, text, api as ICoreClientAPI, 3);
                    dlg.OnTextChanged = DidChangeTextClientSide;
                    dlg.OnCloseCancel = () =>
                    {
                        labelrenderer.SetNewText(text, color);
                        (api as ICoreClientAPI).Network.SendBlockEntityPacket(pos.X, pos.Y, pos.Z, (int)EnumSignPacketId.CancelEdit, null);
                    };
                    dlg.TryOpen();
                }
            }


            if (packetid == (int)EnumSignPacketId.NowText)
            {
                using (MemoryStream ms = new MemoryStream(data))
                {
                    BinaryReader reader = new BinaryReader(ms);
                    text = reader.ReadString();
                    if (text == null)
                    {
                        text = "";
                    }

                    if (labelrenderer != null)
                    {
                        labelrenderer.SetNewText(text, color);
                    }
                }
            }

            base.OnReceivedServerPacket(packetid, data);
        }
Пример #2
0
        public override void Initialize(ICoreAPI api)
        {
            base.Initialize(api);

            if (api is ICoreClientAPI)
            {
                labelrenderer = new ChestLabelRenderer(pos, api as ICoreClientAPI);
                labelrenderer.SetNewText(text, color);
            }
        }
Пример #3
0
 private void DidChangeTextClientSide(string text)
 {
     labelrenderer?.SetNewText(text, tempColor);
 }