Ejemplo n.º 1
0
        public override void OnBlockBroken(IPlayer byPlayer = null)
        {
            base.OnBlockBroken(byPlayer);

            invDialog?.TryClose();
            invDialog = null;
        }
Ejemplo n.º 2
0
        public override void OnReceivedServerPacket(int packetid, byte[] data)
        {
            base.OnReceivedServerPacket(packetid, data);

            if (packetid == (int)EnumBlockEntityPacketId.Close)
            {
                (Api.World as IClientWorldAccessor).Player.InventoryManager.CloseInventory(Inventory);
                invDialog?.TryClose();
                invDialog?.Dispose();
                invDialog = null;
            }
        }
Ejemplo n.º 3
0
        public void OnBlockInteract(IPlayer byPlayer)
        {
            if (Api.Side == EnumAppSide.Client)
            {
                if (invDialog == null)
                {
                    invDialog           = new GuiDialogCauld("Cauld", Inventory, Pos, Api as ICoreClientAPI);
                    invDialog.OnClosed += () =>
                    {
                        invDialog = null;
                        (Api as ICoreClientAPI).Network.SendBlockEntityPacket(Pos.X, Pos.Y, Pos.Z, (int)EnumBlockEntityPacketId.Close, null);
                        byPlayer.InventoryManager.CloseInventory(inventory);
                    };
                }

                invDialog.TryOpen();

                (Api as ICoreClientAPI).Network.SendPacketClient(inventory.Open(byPlayer));
            }
            else
            {
                byPlayer.InventoryManager.OpenInventory(inventory);
            }
        }