Skip to content

Commit 9d264e1

Browse files
committed
replace a constructor with an of() method
don't throw in `getIndexOffset()`
1 parent f16a2cd commit 9d264e1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/java/gregtech/api/capability/impl/ItemHandlerList.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ public ItemHandlerList() {
3535
this(Collections.emptyList());
3636
}
3737

38-
public ItemHandlerList(ItemHandlerList parent, IItemHandler... additional) {
39-
this(parent);
40-
Collections.addAll(this, additional);
38+
public static ItemHandlerList of(IItemHandler... handlers) {
39+
ItemHandlerList list = new ItemHandlerList();
40+
if (handlers != null && handlers.length > 0) {
41+
Collections.addAll(list, handlers);
42+
}
43+
return list.toImmutable();
4144
}
4245

4346
/**
4447
* @param handler the handler to get the slot offset of
45-
* @return the slot offset
46-
* @throws IllegalArgumentException if the handler is not in this list
48+
* @return the slot offset, or {@code -1} if the handler does not exist
4749
*/
4850
public int getIndexOffset(IItemHandler handler) {
49-
int offset = baseIndexOffset.get(handler);
50-
if (offset == -1) throw new IllegalArgumentException();
51-
return offset;
51+
return baseIndexOffset.get(handler);
5252
}
5353

5454
@NotNull

0 commit comments

Comments
 (0)