diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-02-15 01:44:20 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-02-15 01:44:20 +0800 |
| commit | f8e6de6909b4c9b4e725bd79e154374aeb0290f8 (patch) | |
| tree | df633e5c082e80d2dc921b70b19c8974e660e5b2 /api/src | |
| parent | 53da029b48084255103733b3a932948f84f58011 (diff) | |
| download | RoughlyEnoughItems-f8e6de6909b4c9b4e725bd79e154374aeb0290f8.tar.gz RoughlyEnoughItems-f8e6de6909b4c9b4e725bd79e154374aeb0290f8.tar.bz2 RoughlyEnoughItems-f8e6de6909b4c9b4e725bd79e154374aeb0290f8.zip | |
Support JEI API 9.3
Diffstat (limited to 'api/src')
4 files changed, 51 insertions, 7 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/config/FavoriteAddWidgetMode.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/config/FavoriteAddWidgetMode.java index 8a846d088..ba0418920 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/config/FavoriteAddWidgetMode.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/config/FavoriteAddWidgetMode.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.api.client.gui.config; import net.minecraft.client.resources.language.I18n; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java index 88ab72aa5..fee50c9d5 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Widgets.java @@ -185,8 +185,12 @@ public final class Widgets { } public static WidgetWithBounds wrapRenderer(Rectangle bounds, Renderer renderer) { + return wrapRenderer(() -> bounds, renderer); + } + + public static WidgetWithBounds wrapRenderer(Supplier<Rectangle> bounds, Renderer renderer) { if (renderer instanceof Widget widget) - return wrapWidgetWithBounds(widget, bounds); + return wrapWidgetWithBoundsSupplier(widget, bounds); return new RendererWrappedWidget(renderer, bounds); } @@ -195,6 +199,10 @@ public final class Widgets { } public static WidgetWithBounds wrapWidgetWithBounds(Widget widget, Rectangle bounds) { + return wrapWidgetWithBoundsSupplier(widget, bounds == null ? null : () -> bounds); + } + + public static WidgetWithBounds wrapWidgetWithBoundsSupplier(Widget widget, Supplier<Rectangle> bounds) { if (widget instanceof WidgetWithBounds withBounds) return withBounds; if (bounds == null) @@ -204,9 +212,9 @@ public final class Widgets { private static class RendererWrappedWidget extends WidgetWithBounds { private final Renderer renderer; - private final Rectangle bounds; + private final Supplier<Rectangle> bounds; - public RendererWrappedWidget(Renderer renderer, Rectangle bounds) { + public RendererWrappedWidget(Renderer renderer, Supplier<Rectangle> bounds) { this.renderer = Objects.requireNonNull(renderer); this.bounds = Objects.requireNonNull(bounds); } @@ -235,21 +243,21 @@ public final class Widgets { @Override public Rectangle getBounds() { - return bounds; + return bounds.get(); } } private static class DelegateWidgetWithBounds extends DelegateWidget { - private final Rectangle bounds; + private final Supplier<Rectangle> bounds; - public DelegateWidgetWithBounds(Widget widget, Rectangle bounds) { + public DelegateWidgetWithBounds(Widget widget, Supplier<Rectangle> bounds) { super(widget); this.bounds = bounds; } @Override public Rectangle getBounds() { - return bounds; + return bounds.get(); } } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java b/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java index cb426d6c1..0baa9d3d4 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/view/Views.java @@ -27,6 +27,8 @@ import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.registry.Reloadable; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import java.util.Collection; @@ -35,6 +37,11 @@ public interface Views extends Reloadable<REIClientPlugin> { return PluginManager.getClientInstance().get(Views.class); } + @Nullable + @ApiStatus.Internal + @ApiStatus.Experimental + ViewSearchBuilder getContext(); + /** * Returns all craftable items from materials. * diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java index 5f5e48bda..efdc401df 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java @@ -31,6 +31,8 @@ import org.jetbrains.annotations.ApiStatus; import java.util.List; import java.util.function.Predicate; import java.util.function.UnaryOperator; +import java.util.stream.Collector; +import java.util.stream.Collectors; /** * An immutable representation of a list of {@link EntryStack}. @@ -71,6 +73,10 @@ public interface EntryIngredient extends List<EntryStack<?>> { return Internals.getEntryIngredientProvider().of(stacks); } + static Collector<EntryStack<?>, ?, EntryIngredient> collector() { + return Collectors.collectingAndThen(Collectors.toList(), EntryIngredient::of); + } + ListTag save(); @SuppressWarnings("rawtypes") |
