Ejemplo n.º 1
0
        public void OnBlockInteract(IPlayer byPlayer)
        {
            if (Sealed)
            {
                return;
            }

            FindMatchingRecipe();

            if (api.Side == EnumAppSide.Client)
            {
                if (invDialog == null)
                {
                    invDialog           = new GuiDialogBarrel("Barrel", Inventory, pos, api as ICoreClientAPI);
                    invDialog.OnClosed += () =>
                    {
                        (api as ICoreClientAPI).Network.SendBlockEntityPacket(pos.X, pos.Y, pos.Z, (int)EnumBlockContainerPacketId.CloseInventory, null);
                        byPlayer.InventoryManager.CloseInventory(inventory);
                    };
                }

                invDialog.TryOpen();

                (api as ICoreClientAPI).Network.SendPacketClient(inventory.Open(byPlayer));
            }
            else
            {
                byPlayer.InventoryManager.OpenInventory(inventory);
            }
        }
Ejemplo n.º 2
0
        public override void OnBlockBroken()
        {
            if (!Sealed)
            {
                base.OnBlockBroken();
            }

            invDialog?.TryClose();
            invDialog = null;
        }
Ejemplo n.º 3
0
        public override void OnBlockBroken(IPlayer byPlayer = null)
        {
            if (!Sealed)
            {
                base.OnBlockBroken(byPlayer);
            }

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

            if (packetid == (int)EnumBlockContainerPacketId.CloseInventory)
            {
                (api.World as IClientWorldAccessor).Player.InventoryManager.CloseInventory(Inventory);
                invDialog?.TryClose();
                invDialog?.Dispose();
                invDialog = null;
            }
        }