Exemple #1
0
        public override void FromTreeAttributes(ITreeAttribute tree, IWorldAccessor worldForResolving)
        {
            base.FromTreeAttributes(tree, worldForResolving);
            color = tree.GetInt("color");
            if (color == 0)
            {
                color = ColorUtil.BlackArgb;
            }

            text = tree.GetString("text", "");

            signRenderer?.SetNewText(text, color);
        }
Exemple #2
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, 160);
                    dlg.OnTextChanged = DidChangeTextClientSide;
                    dlg.OnCloseCancel = () =>
                    {
                        signRenderer.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 (signRenderer != null)
                    {
                        signRenderer.SetNewText(text, color);
                    }
                }
            }
        }
Exemple #3
0
        public override void Initialize(ICoreAPI coreapi)
        {
            base.Initialize(coreapi);

            if (coreapi is ICoreClientAPI)
            {
                signRenderer = new BlockEntitySignRenderer(pos, (ICoreClientAPI)coreapi);

                if (text.Length > 0)
                {
                    signRenderer.SetNewText(text);
                }
            }
        }
Exemple #4
0
        public override void Initialize(ICoreAPI api)
        {
            base.Initialize(api);

            if (api is ICoreClientAPI)
            {
                signRenderer = new BlockEntitySignRenderer(Pos, (ICoreClientAPI)api);

                if (text.Length > 0)
                {
                    signRenderer.SetNewText(text, color);
                }
            }
        }
Exemple #5
0
        public override void FromTreeAttributes(ITreeAttribute tree, IWorldAccessor worldForResolving)
        {
            base.FromTreeAttributes(tree, worldForResolving);
            color = tree.GetInt("color");
            if (color == 0)
            {
                color = ColorUtil.BlackArgb;
            }

            text = tree.GetString("text", "");

            if (!tree.HasAttribute("meshAngle"))
            {
                // Pre 1.16 behavior
                MeshAngleRad = Block.Shape.rotateY * GameMath.DEG2RAD;
            }
            else
            {
                MeshAngleRad = tree.GetFloat("meshAngle", 0);
            }

            signRenderer?.SetNewText(text, color);
        }
Exemple #6
0
        public override void Initialize(ICoreAPI api)
        {
            base.Initialize(api);

            if (api is ICoreClientAPI)
            {
                signRenderer = new BlockEntitySignRenderer(Pos, (ICoreClientAPI)api);

                if (text.Length > 0)
                {
                    signRenderer.SetNewText(text, color);
                }

                if (Block.Variant["attachment"] != "wall")
                {
                    signRenderer.rotY       = 180 + angleRad * GameMath.RAD2DEG;
                    signRenderer.translateX = 8f / 16f;
                    signRenderer.translateZ = 8f / 16f;
                    signRenderer.offsetZ    = -1.51f / 16f;
                }
            }
        }
Exemple #7
0
 private void DidChangeTextClientSide(string text)
 {
     signRenderer?.SetNewText(text);
 }