public override void OnReceivedServerPacket(int packetid, byte[] data) { if (packetid == (int)EnumBlockStovePacket.OpenGUI) { using (MemoryStream memoryStream = new MemoryStream(data)) { BinaryReader stream = new BinaryReader((Stream)memoryStream); stream.ReadString(); string DialogTitle = stream.ReadString(); TreeAttribute treeAttribute = new TreeAttribute(); treeAttribute.FromBytes(stream); Inventory.FromTreeAttributes(treeAttribute); Inventory.ResolveBlocksOrItems(); IClientWorldAccessor world = (IClientWorldAccessor)api.World; SyncedTreeAttribute tree = new SyncedTreeAttribute(); SetDialogValues(tree); clientDialog = new GuiDialogBlockEntityQuern(DialogTitle, Inventory, pos, tree, api as ICoreClientAPI); clientDialog.TryOpen(); clientDialog.OnClosed += (Vintagestory.API.Common.Action)(() => clientDialog = null); } } if (packetid == (int)EnumBlockContainerPacketId.CloseInventory) { IClientWorldAccessor clientWorld = (IClientWorldAccessor)api.World; clientWorld.Player.InventoryManager.CloseInventory(Inventory); } }
public override void OnReceivedServerPacket(int packetid, byte[] data) { if (packetid == (int)EnumBlockStovePacket.OpenGUI) { using (MemoryStream ms = new MemoryStream(data)) { BinaryReader reader = new BinaryReader(ms); string dialogClassName = reader.ReadString(); string dialogTitle = reader.ReadString(); TreeAttribute tree = new TreeAttribute(); tree.FromBytes(reader); Inventory.FromTreeAttributes(tree); Inventory.ResolveBlocksOrItems(); IClientWorldAccessor clientWorld = (IClientWorldAccessor)api.World; SyncedTreeAttribute dtree = new SyncedTreeAttribute(); SetDialogValues(dtree); clientDialog = new GuiDialogBlockEntityQuern(dialogTitle, Inventory, pos, dtree, api as ICoreClientAPI); clientDialog.TryOpen(); } } if (packetid == (int)Vintagestory.API.Client.EnumBlockContainerPacketId.CloseInventory) { IClientWorldAccessor clientWorld = (IClientWorldAccessor)api.World; clientWorld.Player.InventoryManager.CloseInventory(Inventory); } }