public Item this[int index] { get { if (index < 0 || index >= Slots.Length) { throw new IndexOutOfRangeException(); } return(Slots[index]); } set { if (index < 0 || index >= Slots.Length) { throw new IndexOutOfRangeException(); } if (value.Count == 0) { value = new ItemAir() { Count = 0 }; } Slots[index] = value; if ((index == 36 + _selectedSlot && !IsPeInventory) || (index == _selectedSlot && IsPeInventory)) { MainHand = value; } SlotChanged?.Invoke(this, new SlotChangedEventArgs(index, value)); } }
public void SetSlot(int index, Item value, bool isServerTransaction) { if (index < 0 || index >= Slots.Length) { throw new IndexOutOfRangeException(); } if (value.Count == 0) { value = new ItemAir() { Count = 0 }; } var oldValue = Slots[index]; Slots[index] = value; /*if ((index == 36 + _selectedSlot && !IsPeInventory) || (index == _selectedSlot && IsPeInventory)) * { * MainHand = value; * }*/ SlotChanged?.Invoke(this, new SlotChangedEventArgs(InventoryId, index, value, oldValue, isServerTransaction)); }
protected virtual void OnSlotChanged(int n, ItemStack slot) { SlotChanged?.Invoke(this, n, slot); }
protected void InvokeSlotChanged(SlotChangedEventArgs eventArgs) { SlotChanged?.Invoke(this, eventArgs); }