Ejemplo n.º 1
0
        public override void OnBlockBroken()
        {
            base.OnBlockBroken();

            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.World.Side == EnumAppSide.Client)
            {
                if (invDialog == null)
                {
                    invDialog           = new GuiDialogDoubleSink("Cabinet Sink", 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);
                        animUtil.StopAnimation("lidopen");
                        Api.World.PlaySoundAt(new AssetLocation("game:sounds/block/largechestclose"), Pos.X, Pos.Y, Pos.Z);
                    };
                }

                if (Api.Side == EnumAppSide.Client)
                {
                    animUtil.StartAnimation(new AnimationMetaData()
                    {
                        Animation      = "lidopen",
                        Code           = "lidopen",
                        AnimationSpeed = 1.8f,
                        EaseOutSpeed   = 6,
                        EaseInSpeed    = 15
                    });

                    Api.World.PlaySoundAt(new AssetLocation("game:sounds/block/largechestopen"), Pos.X, Pos.Y, Pos.Z);
                }


                invDialog.TryOpen();


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