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); } }
public GuiDialogBlockEntityQuern(string DialogTitle, InventoryBase inventory, BlockPos blockEntityPos, SyncedTreeAttribute tree, ICoreClientAPI capi) : base(DialogTitle, capi) { foreach (var val in capi.World.Player.InventoryManager.Inventories) { if (val.Value == inventory) { isduplicate = true; return; } } this.inventory = inventory; this.blockEntityPos = blockEntityPos; this.attributes = tree; attributes.OnModified.Add(new TreeModifiedListener() { listener = OnAttributesModified }); capi.World.Player.InventoryManager.OpenInventory(inventory); SetupDialog(); }
public GuiDialogBlockEntityFurnace(string dialogTitle, InventoryBase Inventory, BlockPos BlockEntityPosition, SyncedTreeAttribute tree, ICoreClientAPI capi) : base(dialogTitle, Inventory, BlockEntityPosition, capi) { if (IsDuplicate) { return; } tree.OnModified.Add(new TreeModifiedListener() { listener = OnAttributesModified }); Attributes = tree; }
public GuiDialogBlockEntityQuern(string DialogTitle, InventoryBase Inventory, BlockPos BlockEntityPosition, SyncedTreeAttribute tree, ICoreClientAPI capi) : base(DialogTitle, Inventory, BlockEntityPosition, capi) { if (IsDuplicate) { return; } tree.OnModified.Add(new TreeModifiedListener() { listener = OnAttributesModified }); Attributes = tree; capi.World.Player.InventoryManager.OpenInventory(Inventory); SetupDialog(); }
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); if (clientDialog != null) { clientDialog.TryClose(); clientDialog = null; } else { clientDialog = new GuiDialogBlockEntityFirepit(dialogTitle, Inventory, Pos, dtree, Api as ICoreClientAPI); clientDialog.OnClosed += () => { clientDialog?.Dispose(); clientDialog = null; }; clientDialog.TryOpen(); } } } if (packetid == (int)EnumBlockEntityPacketId.Close) { IClientWorldAccessor clientWorld = (IClientWorldAccessor)Api.World; clientWorld.Player.InventoryManager.CloseInventory(Inventory); } }