public override void OnBlockBroken(IPlayer byPlayer = null) { base.OnBlockBroken(byPlayer); invDialog?.TryClose(); invDialog = null; }
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; } }
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); } }