diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-08-04 23:53:04 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-08-04 23:53:04 +0800 |
| commit | 1ce5ca77bc2f98df6cc370c96547c2c39c1fd897 (patch) | |
| tree | 3d4e86a09eb58f5669ce004628addf72136b9ac7 | |
| parent | f4a31a563e7fae66ae63179ea0926c2c15e494c1 (diff) | |
| download | RoughlyEnoughItems-1ce5ca77bc2f98df6cc370c96547c2c39c1fd897.tar.gz RoughlyEnoughItems-1ce5ca77bc2f98df6cc370c96547c2c39c1fd897.tar.bz2 RoughlyEnoughItems-1ce5ca77bc2f98df6cc370c96547c2c39c1fd897.zip | |
limit the size
Signed-off-by: shedaniel <daniel@shedaniel.me>
3 files changed, 7 insertions, 14 deletions
diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java index 33f8ef457..7e46a05f6 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java @@ -34,6 +34,7 @@ import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; import java.util.stream.Collectors; +import java.util.stream.Stream; public class CollectionUtils { public static <A, B> List<B> getOrPutEmptyList(Map<A, List<B>> map, A key) { @@ -178,33 +179,25 @@ public class CollectionUtils { public static <T, R> Optional<R> mapAndMax(List<T> list, Function<T, R> function, Comparator<R> comparator) { if (list.isEmpty()) return Optional.empty(); - List<R> copyOf = CollectionUtils.map(list, function); - copyOf.sort(comparator); - return Optional.ofNullable(copyOf.get(copyOf.size() - 1)); + return list.stream().max(Comparator.comparing(function, comparator)).map(function); } public static <T, R> Optional<R> mapAndMax(T[] list, Function<T, R> function, Comparator<R> comparator) { if (list.length <= 0) return Optional.empty(); - List<R> copyOf = CollectionUtils.map(list, function); - copyOf.sort(comparator); - return Optional.ofNullable(copyOf.get(copyOf.size() - 1)); + return Stream.of(list).max(Comparator.comparing(function, comparator)).map(function); } public static <T> Optional<T> max(List<T> list, Comparator<T> comparator) { if (list.isEmpty()) return Optional.empty(); - ArrayList<T> ts = new ArrayList<>(list); - ts.sort(comparator); - return Optional.ofNullable(ts.get(ts.size() - 1)); + return list.stream().max(comparator); } public static <T> Optional<T> max(T[] list, Comparator<T> comparator) { if (list.length <= 0) return Optional.empty(); - T[] copyOf = list.clone(); - Arrays.sort(copyOf, comparator); - return Optional.ofNullable(copyOf[copyOf.length - 1]); + return Stream.of(list).max(comparator); } public static String joinToString(List<String> list, String separator) { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java index fd286c539..62fb8328e 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java @@ -227,7 +227,7 @@ public class RecipeViewingScreen extends Screen implements RecipeScreen { this.largestWidth = width - 100; this.largestHeight = Math.max(height - 34 - 30, 100); int maxWidthDisplay = CollectionUtils.mapAndMax(getCurrentDisplayed(), selectedCategory::getDisplayWidth, Comparator.naturalOrder()).orElse(150); - this.guiWidth = Math.max(maxWidthDisplay + 40, 0); + this.guiWidth = Math.max(maxWidthDisplay + 40, 190); this.guiHeight = MathHelper.floor(MathHelper.clamp((double) (selectedCategory.getDisplayHeight() + 4) * (getRecipesPerPage() + 1) + 36, 100, largestHeight)); if (!ConfigObject.getInstance().shouldResizeDynamically()) this.guiHeight = largestHeight; this.tabsPerPage = Math.max(5, MathHelper.floor((guiWidth - 20d) / tabSize)); diff --git a/gradle.properties b/gradle.properties index 25fa13bbb..5c3a63261 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx3G -mod_version=5.0.2-unstable +mod_version=5.0.3-unstable supported_version=1.16.2+ minecraft_version=1.16.2-pre1 yarn_version=1.16.2-pre1+build.1+legacy.20w09a+build.8 |
