Skip to content

Commit c6e279c

Browse files
Fix Algorithm
(col + (row - 1) * 9) - 1 This would reproduce "0" when row is 1 and col is 1, but should be 8. Using this algorithm: ((col + (row - 1)) * 9) - 1 now math knows what to multiply, so "8" is returned as it should.
1 parent 17b42d6 commit c6e279c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/java/me/flame/menus/menu/Slot.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
import lombok.Getter;
44

5-
import javax.annotation.concurrent.NotThreadSafe;
6-
import javax.annotation.concurrent.ThreadSafe;
7-
8-
@ThreadSafe
95
public final class Slot {
10-
private static final int MAX_INVENTORY_SLOTS = 54;
116
private final @Getter int row;
127
private final int col;
13-
private final @Getter int slot;
8+
private @Getter int slot;
149

1510
public Slot(int row, int col) {
1611
this.row = row;
1712
this.col = col;
18-
this.slot = Math.min(((col + (row - 1) * 9) - 1), MAX_INVENTORY_SLOTS);
13+
this.slot = ((col + (row - 1)) * 9) - 1;;
14+
slot = slot >= 54 ? -1 : slot;
1915
}
2016

2117
public int getColumn() {
2218
return col;
2319
}
20+
21+
public boolean isSlot() {
22+
return slot >= 0;
23+
}
2424
}

0 commit comments

Comments
 (0)