public override void OnBlockRemoved() { base.OnBlockRemoved(); renderer?.Dispose(); renderer = null; if (clientDialog != null) { clientDialog.TryClose(); clientDialog?.Dispose(); clientDialog = null; } }
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?.Dispose(); clientDialog = null; } else { clientDialog = new GuiDialogBlockEntityFirepit(dialogTitle, Inventory, pos, dtree, api as ICoreClientAPI); clientDialog.OnClosed += () => { clientDialog.Dispose(); clientDialog = null; }; clientDialog.TryOpen(); } } } if (packetid == (int)EnumBlockContainerPacketId.CloseInventory) { IClientWorldAccessor clientWorld = (IClientWorldAccessor)api.World; clientWorld.Player.InventoryManager.CloseInventory(Inventory); } }
public override void OnBlockRemoved() { base.OnBlockRemoved(); if (ambientSound != null) { ambientSound.Stop(); ambientSound.Dispose(); } renderer?.Dispose(); renderer = null; if (clientDialog != null) { clientDialog.TryClose(); clientDialog?.Dispose(); clientDialog = null; } }