public InventoryItemControl(byte myslot,ref InventoryCollection inventoryCollection) { this.Slot = myslot; if (!inventoryCollection.ContainsKey(myslot)) { Item = new InventoryItem(); Item.Count = 0; Item.Damage = 0; Item.ID = 0; Item.Slot = myslot; } else Item = inventoryCollection[myslot]; Block b = Blocks.Get(0x00); try { b = Blocks.Get(Item.ID); } catch (Exception) { } Img = b.Image; _Name = b.Name; Render(); this.Inventory = inventoryCollection; this.Inventory.Changed += new InventoryCollection.InventoryChangedDelegate(inventoryCollection_Changed); this.AllowDrop = true; this.DragDrop += new System.Windows.Forms.DragEventHandler(this.InventoryItem_DragDrop); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.InventoryItem_DragEnter); this.MouseDown += new MouseEventHandler(InventoryItem_MouseDown); this.KeyDown += new KeyEventHandler(InventoryItem_KeyDown); this.KeyUp += new KeyEventHandler(InventoryItem_KeyUp); Changed += Render; }
public Furnace(int CX, int CY, int CS, LibNbt.Tags.NbtCompound c) : base(CX, CY, CS, c) { BurnTime = (c["BurnTime"] as NbtShort).Value; CookTime = (c["CookTime"] as NbtShort).Value; for (int i = 0; i < Slots.Length; i++) { try { if ((c["Items"] as NbtList).Tags[i]!=null) { NbtCompound cc = (NbtCompound)(c["Items"] as NbtList).Tags[i]; Slots[i] = new InventoryItem(); Slots[i].ID = cc.Get<NbtShort>("id").Value; Slots[i].Damage = cc.Get<NbtShort>("Damage").Value; Slots[i].Slot = 0; Slots[i].Count = cc.Get<NbtByte>("Count").Value; } } catch (Exception ex) { } } }
void inventoryCollection_Changed(byte slot) { if (Slot == 0) Console.WriteLine("[{0}] Slot {1} changed.", GetType().Name, slot); if (Slot == slot) { Item = Inventory[slot]; Block b = Blocks.Get(0x00); try { b = Blocks.Get(Item.ID); } catch (Exception) { } Img = b.Image; _Name = b.Name; Render(); Refresh(); } }
public Furnace(NbtCompound c) : base(c) { BurnTime = (c["BurnTime"] as NbtShort).Value; CookTime = (c["CookTime"] as NbtShort).Value; for (byte i = 0; i < 3; i++) { if ((c["Items"] as NbtList).Tags[i] != null) { NbtCompound cc = (NbtCompound)(c["Items"] as NbtList).Tags[i]; Slots[i]=new InventoryItem(); Slots[i].ID = cc.Get<NbtShort>("id").Value; Slots[i].Damage = cc.Get<NbtShort>("Damage").Value; Slots[i].Count = cc.Get<NbtByte>("Count").Value; Slots[i].Slot = i; } } }