inv static method

Slot inv(
  1. int row, [
  2. int? col
])

Slot.inv takes in two numbers, like 2,6 The first number represents the row in the inventory, so the second row And the second number is the sixth slot of that row.

objD calculates the corresponding Slot. In this case inventory.14.

Notice: also the hotbar can be calculated with this. It is the 4th row

Implementation

static Slot inv(int row, [int? col]) {
  var res = 0;

  if (col != null) {
    if (col > 0) res = col - 1;
    if (row > 0) res += (row - 1) * 9;
  } else {
    res = row - 1;
  }

  if (res > 26) {
    return Slot(slot: 'hotbar.${res - 27}', id: res - 27);
  } else {
    return Slot(slot: 'inventory.$res', id: res + 9);
  }
}