aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-05-16 19:26:43 +0800
committershedaniel <daniel@shedaniel.me>2021-05-16 19:26:43 +0800
commit7ebb226c85529ef9de4c93ce91f24c9ca6f608a7 (patch)
tree71d653419fc54f0b04215970c76480a7cb1a73b7
parentb657842bcddcb65fb658d4cd9835e7fa15e1c236 (diff)
downloadRoughlyEnoughItems-7ebb226c85529ef9de4c93ce91f24c9ca6f608a7.tar.gz
RoughlyEnoughItems-7ebb226c85529ef9de4c93ce91f24c9ca6f608a7.tar.bz2
RoughlyEnoughItems-7ebb226c85529ef9de4c93ce91f24c9ca6f608a7.zip
Add abstraction for IRecipesGui, fix #529
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/REIHelper.java5
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/screen/DisplayScreen.java10
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TextField.java4
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java39
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/overlay/ScreenOverlay.java (renamed from api/src/main/java/me/shedaniel/rei/api/client/REIOverlay.java)10
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java17
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/view/Views.java33
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java90
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/REIHelperImpl.java8
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ContainerScreenOverlay.java28
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java45
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java38
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java8
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/FavoritesListWidget.java41
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/TabWidget.java14
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/basewidgets/TextFieldWidget.java10
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/search/OverlaySearchField.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java7
22 files changed, 237 insertions, 190 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/REIHelper.java b/api/src/main/java/me/shedaniel/rei/api/client/REIHelper.java
index b8066133b..94d57de3b 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/REIHelper.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/REIHelper.java
@@ -27,6 +27,7 @@ import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.config.SearchFieldLocation;
import me.shedaniel.rei.api.client.gui.widgets.TextField;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
+import me.shedaniel.rei.api.client.overlay.ScreenOverlay;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.common.plugins.PluginManager;
import me.shedaniel.rei.api.common.registry.Reloadable;
@@ -52,11 +53,11 @@ public interface REIHelper extends Reloadable<REIClientPlugin> {
void toggleOverlayVisible();
- default Optional<REIOverlay> getOverlay() {
+ default Optional<ScreenOverlay> getOverlay() {
return getOverlay(false);
}
- Optional<REIOverlay> getOverlay(boolean reset);
+ Optional<ScreenOverlay> getOverlay(boolean reset);
@Nullable
AbstractContainerScreen<?> getPreviousContainerScreen();
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/screen/DisplayScreen.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/screen/DisplayScreen.java
index 68c4a0205..9174d9112 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/screen/DisplayScreen.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/screen/DisplayScreen.java
@@ -29,16 +29,18 @@ import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.entry.EntryStack;
+import java.util.List;
+
public interface DisplayScreen {
Rectangle getBounds();
- void setIngredientStackToNotice(EntryStack<?> stack);
+ void addIngredientToNotice(EntryStack<?> stack);
- void setResultStackToNotice(EntryStack<?> stack);
+ void addResultToNotice(EntryStack<?> stack);
- EntryStack<?> getIngredientStackToNotice();
+ List<EntryStack<?>> getIngredientsToNotice();
- EntryStack<?> getResultStackToNotice();
+ List<EntryStack<?>> getResultsToNotice();
default CategoryIdentifier<?> getCurrentCategoryId() {
return getCurrentCategory().getCategoryIdentifier();
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TextField.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TextField.java
index 0f1c55142..51f039421 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TextField.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/TextField.java
@@ -52,9 +52,9 @@ public interface TextField {
void setEditableColor(int editableColor);
- void setNotEditableColor(int int_1);
+ void setNotEditableColor(int notEditableColor);
boolean isFocused();
- void setFocused(boolean boolean_1);
+ void setFocused(boolean focused);
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java b/api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java
new file mode 100644
index 000000000..b3752af2e
--- /dev/null
+++ b/api/src/main/java/me/shedaniel/rei/api/client/overlay/OverlayListWidget.java
@@ -0,0 +1,39 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021 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.overlay;
+
+import me.shedaniel.rei.api.common.entry.EntryStack;
+
+import java.util.stream.Stream;
+
+public interface OverlayListWidget {
+ /**
+ * Returns the mouse hovered stack within the overlay list widget.
+ *
+ * @return the mouse hovered stack, returns {@link EntryStack#empty()} if none is hovered
+ */
+ EntryStack<?> getFocusedStacK();
+
+ Stream<EntryStack<?>> getEntries();
+}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/REIOverlay.java b/api/src/main/java/me/shedaniel/rei/api/client/overlay/ScreenOverlay.java
index 9d6778237..01aa56e38 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/REIOverlay.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/overlay/ScreenOverlay.java
@@ -21,13 +21,15 @@
* SOFTWARE.
*/
-package me.shedaniel.rei.api.client;
+package me.shedaniel.rei.api.client.overlay;
import me.shedaniel.rei.api.client.gui.drag.DraggingContext;
import me.shedaniel.rei.api.client.gui.widgets.WidgetWithBounds;
import org.jetbrains.annotations.ApiStatus;
-public abstract class REIOverlay extends WidgetWithBounds {
+import java.util.Optional;
+
+public abstract class ScreenOverlay extends WidgetWithBounds {
@ApiStatus.Internal
public abstract void closeOverlayMenu();
@@ -36,4 +38,8 @@ public abstract class REIOverlay extends WidgetWithBounds {
public abstract DraggingContext<?> getDraggingContext();
public abstract boolean isNotInExclusionZones(double mouseX, double mouseY);
+
+ public abstract OverlayListWidget getEntryList();
+
+ public abstract Optional<OverlayListWidget> getFavoritesList();
}
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java b/api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java
index 2dd4b0cff..589970db9 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/view/ViewSearchBuilder.java
@@ -23,6 +23,7 @@
package me.shedaniel.rei.api.client.view;
+import me.shedaniel.rei.api.client.ClientHelper;
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
@@ -65,19 +66,9 @@ public interface ViewSearchBuilder {
@Nullable
CategoryIdentifier<?> getPreferredOpenedCategory();
- ViewSearchBuilder fillPreferredOpenedCategory();
-
- <T> ViewSearchBuilder setInputNotice(@Nullable EntryStack<T> stack);
-
- @Nullable
- EntryStack<?> getInputNotice();
-
- <T> ViewSearchBuilder setOutputNotice(@Nullable EntryStack<T> stack);
-
- @Nullable
- EntryStack<?> getOutputNotice();
-
Map<DisplayCategory<?>, List<Display>> buildMap();
-
+ default boolean open() {
+ return ClientHelper.getInstance().openView(this);
+ }
} \ No newline at end of file
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 731c94f15..6ddd1b416 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
@@ -24,26 +24,17 @@
package me.shedaniel.rei.api.client.view;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
-import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
-import me.shedaniel.rei.api.common.display.Display;
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 java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
public interface Views extends Reloadable<REIClientPlugin> {
static Views getInstance() {
return PluginManager.getClientInstance().get(Views.class);
}
- @ApiStatus.Internal
- Map<DisplayCategory<?>, List<Display>> buildMapFor(ViewSearchBuilder builder);
-
/**
* Returns all craftable items from materials.
*
@@ -51,28 +42,4 @@ public interface Views extends Reloadable<REIClientPlugin> {
* @return the list of craftable entries
*/
Collection<EntryStack<?>> findCraftableEntriesByMaterials(Iterable<? extends EntryStack<?>> inventoryItems);
-
- /**
- * Returns a map of recipes for an entry
- *
- * @param stack the stack to be crafted
- * @return the map of recipes
- */
- default <T> Map<DisplayCategory<?>, List<Display>> getRecipesFor(EntryStack<T> stack) {
- return ViewSearchBuilder.builder().addRecipesFor(stack).setInputNotice(stack).buildMap();
- }
-
- /**
- * Returns a map of usages for an entry
- *
- * @param stack the stack to be used
- * @return the map of recipes
- */
- default <T> Map<DisplayCategory<?>, List<Display>> getUsagesFor(EntryStack<T> stack) {
- return ViewSearchBuilder.builder().addUsagesFor(stack).setInputNotice(stack).buildMap();
- }
-
- default Map<DisplayCategory<?>, List<Display>> getAllRecipes() {
- return ViewSearchBuilder.builder().addAllCategories().buildMap();
- }
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
index 819c4be51..b63d5de93 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
@@ -229,7 +229,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
}
EntryIngredient arrowStack = EntryIngredient.of(EntryStacks.of(Items.ARROW));
ReferenceSet<Potion> registeredPotions = new ReferenceOpenHashSet<>();
- EntryRegistry.getInstance().getEntryStacks().filter(entry -> entry.getType() == VanillaEntryTypes.ITEM && entry.<ItemStack>cast().getValue().getItem() == Items.LINGERING_POTION).forEach(entry -> {
+ EntryRegistry.getInstance().getEntryStacks().filter(entry -> entry.getValueType() == ItemStack.class && entry.<ItemStack>cast().getValue().getItem() == Items.LINGERING_POTION).forEach(entry -> {
ItemStack itemStack = (ItemStack) entry.getValue();
Potion potion = PotionUtils.getPotion(itemStack);
if (registeredPotions.add(potion)) {
diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
index 312957985..1edb3c221 100644
--- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
+++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
@@ -34,7 +34,7 @@ import me.shedaniel.architectury.registry.ReloadListeners;
import me.shedaniel.architectury.utils.Env;
import me.shedaniel.math.Point;
import me.shedaniel.rei.api.client.REIHelper;
-import me.shedaniel.rei.api.client.REIOverlay;
+import me.shedaniel.rei.api.client.overlay.ScreenOverlay;
import me.shedaniel.rei.api.client.config.ConfigObject;
import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer;
import me.shedaniel.rei.api.client.favorites.FavoriteEntry;
@@ -52,7 +52,6 @@ import me.shedaniel.rei.api.client.registry.screen.OverlayDecider;
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry;
import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.entry.EntryStack;
-import me.shedaniel.rei.api.common.entry.comparison.EntryComparatorRegistry;
import me.shedaniel.rei.api.common.entry.comparison.FluidComparatorRegistry;
import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry;
import me.shedaniel.rei.api.common.entry.type.BuiltinEntryTypes;
@@ -87,7 +86,6 @@ import me.shedaniel.rei.impl.common.display.DisplaySerializerRegistryImpl;
import me.shedaniel.rei.impl.common.entry.EmptyEntryStack;
import me.shedaniel.rei.impl.common.entry.EntryIngredientImpl;
import me.shedaniel.rei.impl.common.entry.TypedEntryStack;
-import me.shedaniel.rei.impl.common.entry.comparison.EntryComparatorRegistryImpl;
import me.shedaniel.rei.impl.common.entry.comparison.FluidComparatorRegistryImpl;
import me.shedaniel.rei.impl.common.entry.comparison.ItemComparatorRegistryImpl;
import me.shedaniel.rei.impl.common.entry.comparison.NbtHasherProviderImpl;
@@ -609,7 +607,7 @@ public class RoughlyEnoughItemsCore {
@Environment(EnvType.CLIENT)
private boolean resetFocused(Screen screen) {
- if (screen.getFocused() instanceof REIOverlay || screen.getFocused() == screen) {
+ if (screen.getFocused() instanceof ScreenOverlay || screen.getFocused() == screen) {
screen.setFocused(null);
}
return true;
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java
index 659a410f2..849856165 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java
@@ -45,6 +45,7 @@ import me.shedaniel.rei.impl.ClientInternals;
import me.shedaniel.rei.impl.client.gui.screen.CompositeDisplayViewingScreen;
import me.shedaniel.rei.impl.client.gui.screen.DefaultDisplayViewingScreen;
import me.shedaniel.rei.impl.client.gui.screen.UncertainDisplayViewingScreen;
+import me.shedaniel.rei.impl.client.view.ViewsImpl;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
@@ -63,7 +64,6 @@ import org.jetbrains.annotations.Nullable;
import java.time.LocalDateTime;
import java.util.*;
-import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@@ -103,7 +103,7 @@ public class ClientHelperImpl implements ClientHelper {
return (ClientHelperImpl) ClientHelper.getInstance();
}
- public boolean hasPermissionToUsePackets() {
+ public boolean hasPermissionToUsePackets() {
try {
Minecraft.getInstance().getConnection().getSuggestionsProvider().hasPermission(0);
return hasOperatorPermission() && canUsePackets();
@@ -223,8 +223,15 @@ public class ClientHelperImpl implements ClientHelper {
}
@ApiStatus.Internal
- public void openRecipeViewingScreen(Map<DisplayCategory<?>, List<Display>> map, @Nullable CategoryIdentifier<?> category, @Nullable EntryStack<?> ingredientNotice, @Nullable EntryStack<?> resultNotice) {
- openView(new LegacyWrapperViewSearchBuilder(map).setPreferredOpenedCategory(category).setInputNotice(ingredientNotice).setOutputNotice(resultNotice).fillPreferredOpenedCategory());
+ public void openRecipeViewingScreen(Map<DisplayCategory<?>, List<Display>> map, @Nullable CategoryIdentifier<?> category, List<EntryStack<?>> ingredientNotice, List<EntryStack<?>> resultNotice) {
+ LegacyWrapperViewSearchBuilder builder = new LegacyWrapperViewSearchBuilder(map);
+ for (EntryStack<?> stack : ingredientNotice) {
+ builder.addInputNotice(stack);
+ }
+ for (EntryStack<?> stack : resultNotice) {
+ builder.addOutputNotice(stack);
+ }
+ openView(builder.setPreferredOpenedCategory(category));
}
@Override
@@ -244,11 +251,11 @@ public class ClientHelperImpl implements ClientHelper {
screen = new DefaultDisplayViewingScreen(map, builder.getPreferredOpenedCategory());
}
if (screen instanceof DisplayScreen) {
- if (builder.getInputNotice() != null) {
- ((DisplayScreen) screen).setIngredientStackToNotice(builder.getInputNotice());
+ for (EntryStack<?> stack : builder.getUsagesFor()) {
+ ((DisplayScreen) screen).addIngredientToNotice(stack);
}
- if (builder.getOutputNotice() != null) {
- ((DisplayScreen) screen).setResultStackToNotice(builder.getOutputNotice());
+ for (EntryStack<?> stack : builder.getRecipesFor()) {
+ ((DisplayScreen) screen).addResultToNotice(stack);
}
}
if (Minecraft.getInstance().screen instanceof DisplayScreen) {
@@ -269,7 +276,6 @@ public class ClientHelperImpl implements ClientHelper {
}
private static abstract class AbstractViewSearchBuilder implements ViewSearchBuilder {
- @Override
public ViewSearchBuilder fillPreferredOpenedCategory() {
if (getPreferredOpenedCategory() == null) {
Screen currentScreen = Minecraft.getInstance().screen;
@@ -285,10 +291,9 @@ public class ClientHelperImpl implements ClientHelper {
private final Set<CategoryIdentifier<?>> categories = new HashSet<>();
private final List<EntryStack<?>> recipesFor = new ArrayList<>();
private final List<EntryStack<?>> usagesFor = new ArrayList<>();
- @Nullable private CategoryIdentifier<?> preferredOpenedCategory = null;
- @Nullable private EntryStack<?> inputNotice;
- @Nullable private EntryStack<?> outputNotice;
- private final LazyLoadedValue<Map<DisplayCategory<?>, List<Display>>> map = new LazyLoadedValue<>(() -> Views.getInstance().buildMapFor(this));
+ @Nullable
+ private CategoryIdentifier<?> preferredOpenedCategory = null;
+ private final LazyLoadedValue<Map<DisplayCategory<?>, List<Display>>> map = new LazyLoadedValue<>(() -> ((ViewsImpl) Views.getInstance()).buildMapFor(this));
@Override
public ViewSearchBuilder addCategory(CategoryIdentifier<?> category) {
@@ -342,40 +347,20 @@ public class ClientHelperImpl implements ClientHelper {
}
@Override
- public <T> ViewSearchBuilder setInputNotice(@Nullable EntryStack<T> stack) {
- this.inputNotice = stack;
- return this;
- }
-
- @Nullable
- @Override
- public EntryStack<?> getInputNotice() {
- return inputNotice;
- }
-
- @Override
- public <T> ViewSearchBuilder setOutputNotice(@Nullable EntryStack<T> stack) {
- this.outputNotice = stack;
- return this;
- }
-
- @Nullable
- @Override
- public EntryStack<?> getOutputNotice() {
- return outputNotice;
- }
-
- @Override
public Map<DisplayCategory<?>, List<Display>> buildMap() {
+ fillPreferredOpenedCategory();
return this.map.get();
}
}
public static final class LegacyWrapperViewSearchBuilder extends AbstractViewSearchBuilder {
private final Map<DisplayCategory<?>, List<Display>> map;
- @Nullable private CategoryIdentifier<?> preferredOpenedCategory = null;
- @Nullable private EntryStack<?> inputNotice;
- @Nullable private EntryStack<?> outputNotice;
+ @Nullable
+ private EntryStack<?> inputNotice;
+ @Nullable
+ private EntryStack<?> outputNotice;
+ @Nullable
+ private CategoryIdentifier<?> preferredOpenedCategory = null;
public LegacyWrapperViewSearchBuilder(Map<DisplayCategory<?>, List<Display>> map) {
this.map = map;
@@ -403,7 +388,7 @@ public class ClientHelperImpl implements ClientHelper {
@Override
public List<EntryStack<?>> getRecipesFor() {
- return Collections.emptyList();
+ return inputNotice == null ? Collections.emptyList() : Collections.singletonList(outputNotice);
}
@Override
@@ -413,7 +398,7 @@ public class ClientHelperImpl implements ClientHelper {
@Override
public List<EntryStack<?>> getUsagesFor() {
- return Collections.emptyList();
+ return inputNotice == null ? Collections.emptyList() : Collections.singletonList(inputNotice);
}
@Override
@@ -421,39 +406,26 @@ public class ClientHelperImpl implements ClientHelper {
this.preferredOpenedCategory = category;
return this;
}
-
+
@Override
@Nullable
public CategoryIdentifier<?> getPreferredOpenedCategory() {
return this.preferredOpenedCategory;
}
- @Override
- public <T> ViewSearchBuilder setInputNotice(@Nullable EntryStack<T> stack) {
+ public <T> LegacyWrapperViewSearchBuilder addInputNotice(@Nullable EntryStack<T> stack) {
this.inputNotice = stack;
return this;
}
- @Nullable
- @Override
- public EntryStack<?> getInputNotice() {
- return inputNotice;
- }
-
- @Override
- public <T> ViewSearchBuilder setOutputNotice(@Nullable EntryStack<T> stack) {
+ public <T> LegacyWrapperViewSearchBuilder addOutputNotice(@Nullable EntryStack<T> stack) {
this.outputNotice = stack;
return this;
}
- @Nullable
- @Override
- public EntryStack<?> getOutputNotice() {
- return outputNotice;
- }
-
@Override
public Map<DisplayCategory<?>, List<Display>> buildMap() {
+ fillPreferredOpenedCategory();
return this.map;
}
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/REIHelperImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/REIHelperImpl.java
index fc91a3bc5..4f44c5fe4 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/REIHelperImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/REIHelperImpl.java
@@ -30,7 +30,7 @@ import me.shedaniel.architectury.event.events.GuiEvent;
import me.shedaniel.architectury.event.events.client.ClientTickEvent;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.REIHelper;
-import me.shedaniel.rei.api.client.REIOverlay;
+import me.shedaniel.rei.api.client.overlay.ScreenOverlay;
import me.shedaniel.rei.api.client.config.ConfigManager;
import me.shedaniel.rei.api.client.config.ConfigObject;
import me.shedaniel.rei.api.client.gui.config.SearchFieldLocation;
@@ -126,7 +126,7 @@ public class REIHelperImpl implements REIHelper {
}
@Override
- public Optional<REIOverlay> getOverlay(boolean reset) {
+ public Optional<ScreenOverlay> getOverlay(boolean reset) {
if (overlay == null || reset) {
overlay = new ContainerScreenOverlay();
overlay.init();
@@ -207,13 +207,13 @@ public class REIHelperImpl implements REIHelper {
@Override
public void startReload() {
- getOverlay().ifPresent(REIOverlay::queueReloadOverlay);
+ getOverlay().ifPresent(ScreenOverlay::queueReloadOverlay);
lastDisplayScreen.clear();
}
@Override
public void endReload() {
- getOverlay().ifPresent(REIOverlay::queueReloadOverlay);
+ getOverlay().ifPresent(ScreenOverlay::queueReloadOverlay);
}
public void onInitializeClient() {
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ContainerScreenOverlay.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ContainerScreenOverlay.java
index ed321c055..f25bb13da 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ContainerScreenOverlay.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ContainerScreenOverlay.java
@@ -34,7 +34,8 @@ import me.shedaniel.math.Rectangle;
import me.shedaniel.math.impl.PointHelper;
import me.shedaniel.rei.api.client.ClientHelper;
import me.shedaniel.rei.api.client.REIHelper;
-import me.shedaniel.rei.api.client.REIOverlay;
+import me.shedaniel.rei.api.client.overlay.OverlayListWidget;
+import me.shedaniel.rei.api.client.overlay.ScreenOverlay;
import me.shedaniel.rei.api.client.config.ConfigManager;
import me.shedaniel.rei.api.client.config.ConfigObject;
import me.shedaniel.rei.api.client.favorites.FavoriteEntry;
@@ -99,7 +100,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
@ApiStatus.Internal
-public class ContainerScreenOverlay extends REIOverlay {
+public class ContainerScreenOverlay extends ScreenOverlay {
private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png");
private static final List<Tooltip> TOOLTIPS = Lists.newArrayList();
private static final List<Runnable> AFTER_RENDER = Lists.newArrayList();
@@ -211,7 +212,7 @@ public class ContainerScreenOverlay extends REIOverlay {
public void init() {
Argument.SEARCH_CACHE.clear();
- draggingStack.set(DraggableStackProvider.from(() -> ScreenRegistry.getInstance().getDraggableProviders()),
+ draggingStack.set(DraggableStackProvider.from(() -> ScreenRegistry.getInstance().getDraggableProviders()),
DraggableStackVisitor.from(() -> ScreenRegistry.getInstance().getDraggableVisitors()));
this.shouldReload = false;
@@ -254,7 +255,7 @@ public class ContainerScreenOverlay extends REIOverlay {
.tooltipLine(new TranslatableComponent("text.rei.next_page"))
.focusable(false));
}
-
+
final Rectangle configButtonArea = getConfigButtonArea();
widgets.add(configButton = InternalWidgets.wrapLateRenderable(
Widgets.withTranslate(
@@ -683,9 +684,9 @@ public class ContainerScreenOverlay extends REIOverlay {
if (stack != null && !stack.isEmpty()) {
stack = stack.copy();
if (ConfigObject.getInstance().getRecipeKeybind().matchesKey(keyCode, scanCode)) {
- return ClientHelper.getInstance().openView(ViewSearchBuilder.builder().addRecipesFor(stack).setOutputNotice(stack).fillPreferredOpenedCategory());
+ return ViewSearchBuilder.builder().addRecipesFor(stack).open();
} else if (ConfigObject.getInstance().getUsageKeybind().matchesKey(keyCode, scanCode)) {
- return ClientHelper.getInstance().openView(ViewSearchBuilder.builder().addUsagesFor(stack).setInputNotice(stack).fillPreferredOpenedCategory());
+ return ViewSearchBuilder.builder().addUsagesFor(stack).open();
} else if (ConfigObject.getInstance().getFavoriteKeyCode().matchesKey(keyCode, scanCode)) {
FavoriteEntry favoriteEntry = FavoriteEntry.fromEntryStack(stack);
if (!ConfigObject.getInstance().getFavoriteEntries().contains(favoriteEntry)) {
@@ -744,9 +745,9 @@ public class ContainerScreenOverlay extends REIOverlay {
if (stack != null && !stack.isEmpty()) {
stack = stack.copy();
if (ConfigObject.getInstance().getRecipeKeybind().matchesMouse(button)) {
- return ClientHelper.getInstance().openView(ViewSearchBuilder.builder().addRecipesFor(stack).setOutputNotice(stack).fillPreferredOpenedCategory());
+ return ViewSearchBuilder.builder().addRecipesFor(stack).open();
} else if (ConfigObject.getInstance().getUsageKeybind().matchesMouse(button)) {
- return ClientHelper.getInstance().openView(ViewSearchBuilder.builder().addUsagesFor(stack).setInputNotice(stack).fillPreferredOpenedCategory());
+ return ViewSearchBuilder.builder().addUsagesFor(stack).open();
} else if (visible && ConfigObject.getInstance().getFavoriteKeyCode().matchesMouse(button)) {