aboutsummaryrefslogtreecommitdiff
path: root/api/src/main/java/me
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-10-21 23:36:28 +0800
committershedaniel <daniel@shedaniel.me>2021-10-22 01:41:20 +0800
commit62045c9cc0416557e6b57b6f4101b98a0da02dde (patch)
tree7361edee07b0fae370b0006de5c5e2b219a67408 /api/src/main/java/me
parent843a29c5fcf8d20f7073438d9fbed7039dead719 (diff)
downloadRoughlyEnoughItems-62045c9cc0416557e6b57b6f4101b98a0da02dde.tar.gz
RoughlyEnoughItems-62045c9cc0416557e6b57b6f4101b98a0da02dde.tar.bz2
RoughlyEnoughItems-62045c9cc0416557e6b57b6f4101b98a0da02dde.zip
Fix most of the issues in #643
Diffstat (limited to 'api/src/main/java/me')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java b/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java
index 97934437d..09511ac6f 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java
@@ -306,7 +306,20 @@ public class CollectionUtils {
@Override
public List<T> next() {
int cursor = i++ * size;
- return list.subList(cursor, cursor + Math.min(list.size() - cursor, size));
+ int realSize = Math.min(list.size() - cursor, size);
+ return new AbstractList<T>() {
+ @Override
+ public T get(int index) {
+ if (index < 0 || index >= realSize)
+ throw new IndexOutOfBoundsException(String.format("Index %s out of bounds for length %s", index, realSize));
+ return list.get(cursor + index);
+ }
+
+ @Override
+ public int size() {
+ return realSize;
+ }
+ };
}
};
}