aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-03-23 00:02:16 +0800
committershedaniel <daniel@shedaniel.me>2021-03-23 00:02:16 +0800
commitc027169dfe9503a9d913589eb322cc11ddad0baa (patch)
treecea2db418d26b0ba9f054445891f272264ae3d30
parent7bbef49785f594dfe3d6eac0cfc6ee84841aae80 (diff)
downloadRoughlyEnoughItems-c027169dfe9503a9d913589eb322cc11ddad0baa.tar.gz
RoughlyEnoughItems-c027169dfe9503a9d913589eb322cc11ddad0baa.tar.bz2
RoughlyEnoughItems-c027169dfe9503a9d913589eb322cc11ddad0baa.zip
Improve UncertainDisplayViewingScreen
Signed-off-by: shedaniel <daniel@shedaniel.me>
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/config/ConfigObject.java6
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/gui/AbstractContainerEventHandler.java36
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/gui/config/DisplayScreenType.java (renamed from api/src/main/java/me/shedaniel/rei/api/gui/config/RecipeScreenType.java)4
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/gui/widgets/DelegateWidget.java1
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widget.java2
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/gui/widgets/WidgetWithBounds.java2
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widgets.java40
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/registry/display/DisplayCategory.java2
-rw-r--r--api/src/main/java/me/shedaniel/rei/impl/Internals.java6
-rw-r--r--forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java20
-rw-r--r--forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java22
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringRulesScreen.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java24
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/AbstractDisplayViewingScreen.java (renamed from runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java)4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/CompositeDisplayViewingScreen.java (renamed from runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java)14
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/DefaultDisplayViewingScreen.java (renamed from runtime/src/main/java/me/shedaniel/rei/gui/RecipeViewingScreen.java)40
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/UncertainDisplayViewingScreen.java (renamed from runtime/src/main/java/me/shedaniel/rei/gui/PreRecipeViewingScreen.java)137
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java12
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/widget/DefaultDisplayChoosePageWidget.java (renamed from runtime/src/main/java/me/shedaniel/rei/gui/widget/RecipeChoosePageWidget.java)22
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java20
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/ConfigManagerImpl.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/ConfigObjectImpl.java14
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/DynamicErrorFreeEntryListWidget.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/widgets/PanelWidget.java4
-rw-r--r--runtime/src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot.pngbin25515 -> 0 bytes
-rw-r--r--runtime/src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot_composite.pngbin0 -> 28497 bytes
-rw-r--r--runtime/src/main/resources/assets/roughlyenoughitems/textures/gui/screenshot_default.pngbin0 -> 24441 bytes
-rwxr-xr-xsrc/main/resources/assets/roughlyenoughitems/lang/en_us.json15
30 files changed, 319 insertions, 142 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/config/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/config/ConfigObject.java
index d7cfb2023..649ce4ddf 100644
--- a/api/src/main/java/me/shedaniel/rei/api/config/ConfigObject.java
+++ b/api/src/main/java/me/shedaniel/rei/api/config/ConfigObject.java
@@ -70,9 +70,9 @@ public interface ConfigObject {
boolean shouldAppendModNames();
- RecipeScreenType getRecipeScreenType();
+ DisplayScreenType getRecipeScreenType();
- void setRecipeScreenType(RecipeScreenType recipeScreenType);
+ void setRecipeScreenType(DisplayScreenType displayScreenType);
SearchFieldLocation getSearchFieldLocation();
@@ -103,7 +103,7 @@ public interface ConfigObject {
RecipeBorderType getRecipeBorderType();
- boolean doesVillagerScreenHavePermanentScrollBar();
+ boolean isCompositeScrollBarPermanent();
boolean doesRegisterRecipesInAnotherThread();
diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/AbstractContainerEventHandler.java b/api/src/main/java/me/shedaniel/rei/api/gui/AbstractContainerEventHandler.java
new file mode 100644
index 000000000..3a271194c
--- /dev/null
+++ b/api/src/main/java/me/shedaniel/rei/api/gui/AbstractContainerEventHandler.java
@@ -0,0 +1,36 @@
+package me.shedaniel.rei.api.gui;
+
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.components.events.ContainerEventHandler;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import org.jetbrains.annotations.Nullable;
+
+@Environment(value = EnvType.CLIENT)
+public abstract class AbstractContainerEventHandler extends GuiComponent implements ContainerEventHandler {
+ @Nullable
+ private GuiEventListener focused;
+ private boolean isDragging;
+
+ @Override
+ public boolean isDragging() {
+ return this.isDragging;
+ }
+
+ @Override
+ public void setDragging(boolean isDragging) {
+ this.isDragging = isDragging;
+ }
+
+ @Override
+ @Nullable
+ public GuiEventListener getFocused() {
+ return this.focused;
+ }
+
+ @Override
+ public void setFocused(@Nullable GuiEventListener focused) {
+ this.focused = focused;
+ }
+} \ No newline at end of file
diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/config/RecipeScreenType.java b/api/src/main/java/me/shedaniel/rei/api/gui/config/DisplayScreenType.java
index 63ebd814c..507fa2c28 100644
--- a/api/src/main/java/me/shedaniel/rei/api/gui/config/RecipeScreenType.java
+++ b/api/src/main/java/me/shedaniel/rei/api/gui/config/DisplayScreenType.java
@@ -32,10 +32,10 @@ import java.util.Locale;
@ApiStatus.Internal
@Environment(EnvType.CLIENT)
-public enum RecipeScreenType {
+public enum DisplayScreenType {
UNSET,
ORIGINAL,
- VILLAGER;
+ COMPOSITE;
@Override
public String toString() {
diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/widgets/DelegateWidget.java b/api/src/main/java/me/shedaniel/rei/api/gui/widgets/DelegateWidget.java
index ece1ab092..83965b426 100644
--- a/api/src/main/java/me/shedaniel/rei/api/gui/widgets/DelegateWidget.java
+++ b/api/src/main/java/me/shedaniel/rei/api/gui/widgets/DelegateWidget.java
@@ -23,7 +23,6 @@
package me.shedaniel.rei.api.gui.widgets;
-import com.google.common.base.MoreObjects;
import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.math.Rectangle;
import net.minecraft.client.gui.components.events.GuiEventListener;
diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widget.java b/api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widget.java
index 5639acf1b..fb15a8850 100644
--- a/api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widget.java
+++ b/api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widget.java
@@ -26,10 +26,10 @@ package me.shedaniel.rei.api.gui.widgets;
import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
+import me.shedaniel.rei.api.gui.AbstractContainerEventHandler;
import me.shedaniel.rei.api.gui.Renderer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
-import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
/**
* The base class for a screen widget
diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/widgets/WidgetWithBounds.java b/api/src/main/java/me/shedaniel/rei/api/gui/widgets/WidgetWithBounds.java
index b427d8a47..bf43ca215 100644
--- a/api/src/main/java/me/shedaniel/rei/api/gui/widgets/WidgetWithBounds.java
+++ b/api/src/main/java/me/shedaniel/rei/api/gui/widgets/WidgetWithBounds.java
@@ -24,10 +24,8 @@
package me.shedaniel.rei.api.gui.widgets;
import me.shedaniel.math.Rectangle;
-import org.jetbrains.annotations.NotNull;
public abstract class WidgetWithBounds extends Widget {
- @NotNull
public abstract Rectangle getBounds();
@Override
diff --git a/api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widgets.java b/api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widgets.java
index ac9423e4d..4df43934f 100644
--- a/api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widgets.java
+++ b/api/src/main/java/me/shedaniel/rei/api/gui/widgets/Widgets.java
@@ -36,6 +36,7 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.components.events.ContainerEventHandler;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.network.chat.Component;
@@ -48,6 +49,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Supplier;
@Environment(EnvType.CLIENT)
public final class Widgets {
@@ -69,13 +72,23 @@ public final class Widgets {
public static WidgetWithBounds withTranslate(Widget widget, Matrix4f translate) {
WidgetWithBounds widgetWithBounds = wrapWidgetWithBounds(widget);
+ return new WidgetWithBoundsWithTranslate(widgetWithBounds, () -> translate);
+ }
+
+ public static <T extends Widget> WidgetWithBounds withTranslate(T widget, Function<T, Matrix4f> translate) {
+ WidgetWithBounds widgetWithBounds = wrapWidgetWithBounds(widget);
+ return new WidgetWithBoundsWithTranslate(widgetWithBounds, () -> translate.apply(widget));
+ }
+
+ public static WidgetWithBounds withTranslate(Widget widget, Supplier<Matrix4f> translate) {
+ WidgetWithBounds widgetWithBounds = wrapWidgetWithBounds(widget);
return new WidgetWithBoundsWithTranslate(widgetWithBounds, translate);
}
private static class WidgetWithBoundsWithTranslate extends DelegateWidget {
- private final Matrix4f translate;
+ private final Supplier<Matrix4f> translate;
- private WidgetWithBoundsWithTranslate(WidgetWithBounds widget, Matrix4f translate) {
+ private WidgetWithBoundsWithTranslate(WidgetWithBounds widget, Supplier<Matrix4f> translate) {
super(widget);
this.translate = translate;
}
@@ -83,7 +96,7 @@ public final class Widgets {
@Override
public void render(PoseStack poseStack, int i, int j, float f) {
poseStack.pushPose();
- poseStack.last().pose().multiply(translate);
+ poseStack.last().pose().multiply(translate.get());
super.render(poseStack, i, j, f);
poseStack.popPose();
}
@@ -94,6 +107,7 @@ public final class Widgets {
public VanillaWrappedWidget(GuiEventListener element) {
this.element = Objects.requireNonNull(element);
+ setFocused(element);
}
@Override
@@ -108,6 +122,26 @@ public final class Widgets {
public List<? extends GuiEventListener> children() {
return Collections.singletonList(element);
}
+
+ @Nullable
+ @Override
+ public GuiEventListener getFocused() {
+ return element;
+ }
+
+ @Override
+ public void setFocused(@Nullable GuiEventListener guiEventListener) {
+ if (guiEventListener == element) {
+ super.setFocused(element);
+ } else if (element instanceof ContainerEventHandler) {
+ ((ContainerEventHandler) element).setFocused(guiEventListener);
+ }
+ }
+
+ @Override
+ public boolean containsMouse(double mouseX, double mouseY) {
+ return element.isMouseOver(mouseX, mouseY);
+ }
}
public static WidgetWithBounds wrapRenderer(Rectangle bounds, Renderer renderer) {
diff --git a/api/src/main/java/me/shedaniel/rei/api/registry/display/DisplayCategory.java b/api/src/main/java/me/shedaniel/rei/api/registry/display/DisplayCategory.java
index 5e19b8d0b..db381c1c2 100644
--- a/api/src/main/java/me/shedaniel/rei/api/registry/display/DisplayCategory.java
+++ b/api/src/main/java/me/shedaniel/rei/api/registry/display/DisplayCategory.java
@@ -55,7 +55,7 @@ public interface DisplayCategory<T extends Display> extends Identifiable {
Component getTitle();
/**
- * Gets the recipe renderer for the category, used in {@link me.shedaniel.rei.gui.VillagerRecipeViewingScreen} for rendering simple recipes
+ * Gets the recipe renderer for the category, used in {@link me.shedaniel.rei.gui.CompositeRecipeViewingScreen} for rendering simple recipes
*
* @param display the display to render
* @return the display renderer
diff --git a/api/src/main/java/me/shedaniel/rei/impl/Internals.java b/api/src/main/java/me/shedaniel/rei/impl/Internals.java
index 2f2b6325d..035a77bc3 100644
--- a/api/src/main/java/me/shedaniel/rei/impl/Internals.java
+++ b/api/src/main/java/me/shedaniel/rei/impl/Internals.java
@@ -54,6 +54,7 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.Collection;
+import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -76,6 +77,7 @@ public final class Internals {
private static Function<@NotNull Boolean, ClickArea.Result> clickAreaHandlerResult = (result) -> throwNotSetup();
private static BiFunction<@Nullable Point, Collection<Component>, Tooltip> tooltipProvider = (point, texts) -> throwNotSetup();
private static Supplier<BuiltinPlugin> builtinPlugin = Internals::throwNotSetup;
+ private static Supplier<List<String>> jeiCompatMods = Internals::throwNotSetup;
private static <T> T throwNotSetup() {
throw new AssertionError("REI Internals have not been initialized!");
@@ -162,6 +164,10 @@ public final class Internals {
return emptyEntryRenderer.get().cast();
}
+ public static List<String> getJeiCompatMods() {
+ return jeiCompatMods.get();
+ }
+
public interface EntryStackProvider {
EntryStack<Unit> empty();
diff --git a/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java
index 747a6d790..1a529311c 100644
--- a/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java
+++ b/forge/src/main/java/me/shedaniel/rei/forge/PluginDetectorImpl.java
@@ -23,16 +23,19 @@
package me.shedaniel.rei.forge;
-import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.api.plugins.PluginManager;
import me.shedaniel.rei.gui.plugin.DefaultRuntimePlugin;
+import me.shedaniel.rei.impl.Internals;
import me.shedaniel.rei.jeicompat.JEIPluginDetector;
import me.shedaniel.rei.plugin.DefaultPlugin;
import me.shedaniel.rei.plugin.DefaultServerContainerPlugin;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
-import java.util.function.Consumer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.BiConsumer;
+import java.util.function.Supplier;
public class PluginDetectorImpl {
public static void detectServerPlugins() {
@@ -43,10 +46,19 @@ public class PluginDetectorImpl {
public static void detectClientPlugins() {
PluginManager.getInstance().registerPlugin(new DefaultPlugin());
PluginManager.getInstance().registerPlugin(new DefaultRuntimePlugin());
- RoughlyEnoughItemsForge.scanAnnotation(REIPlugin.class, plugin -> {
+ RoughlyEnoughItemsForge.scanAnnotation(REIPlugin.class, (modId, plugin) -> {
PluginManager.getInstance().registerPlugin(((me.shedaniel.rei.api.plugins.REIPlugin) plugin));
});
- JEIPluginDetector.detect((aClass, consumer) -> RoughlyEnoughItemsForge.scanAnnotation((Class<Object>) aClass, (Consumer<Object>) consumer),
+ Internals.attachInstance((Supplier<List<String>>) () -> {
+ List<String> modIds = new ArrayList<>();
+ for (me.shedaniel.rei.api.plugins.REIPlugin plugin : PluginManager.getInstance().getPlugins()) {
+ if (plugin instanceof JEIPluginDetector.JEIPluginWrapper) {
+ modIds.addAll(((JEIPluginDetector.JEIPluginWrapper) plugin).modIds);
+ }
+ }
+ return modIds;
+ }, "jeiCompatMods");
+ JEIPluginDetector.detect((aClass, consumer) -> RoughlyEnoughItemsForge.scanAnnotation((Class<Object>) aClass, (BiConsumer<List<String>, Object>) consumer),
PluginManager.getInstance()::registerPlugin);
}
}
diff --git a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java
index 61b99c72e..3501970c3 100644
--- a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java
+++ b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsForge.java
@@ -31,14 +31,18 @@ import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
+import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.forgespi.language.ModFileScanData;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.ApiStatus;
import org.objectweb.asm.Type;
import java.util.List;
-import java.util.function.Consumer;
+import java.util.function.BiConsumer;
+import java.util.stream.Collectors;
@Mod("roughlyenoughitems")
@ApiStatus.Internal
@@ -51,18 +55,22 @@ public class RoughlyEnoughItemsForge {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> RoughlyEnoughItemsInitializer::onInitializeClient);
}
- public static <T> void scanAnnotation(Class<T> clazz, Consumer<T> consumer) {
+ public static <T> void scanAnnotation(Class<T> clazz, BiConsumer<List<String>, T> consumer) {
scanAnnotation(Type.getType(clazz), consumer);
}
- public static <T> void scanAnnotation(Type annotationType, Consumer<T> consumer) {
- List<T> instances = Lists.newArrayList();
+ public static <T> void scanAnnotation(Type annotationType, BiConsumer<List<String>, T> consumer) {
+ List<Pair<List<String>, T>> instances = Lists.newArrayList();
for (ModFileScanData data : ModList.get().getAllScanData()) {
+ List<String> modIds = data.getIModInfoData().stream()
+ .flatMap(info -> info.getMods().stream())
+ .map(IModInfo::getModId)
+ .collect(Collectors.toList());
for (ModFileScanData.AnnotationData annotation : data.getAnnotations()) {
if (annotationType.equals(annotation.getAnnotationType())) {
try {
T instance = (T) Class.forName(annotation.getMemberName()).getDeclaredConstructor().newInstance();
- instances.add(instance);
+ instances.add(new ImmutablePair<>(modIds, instance));
} catch (Throwable throwable) {
LOGGER.error("Failed to load plugin: " + annotation.getMemberName(), throwable);
}
@@ -70,8 +78,8 @@ public class RoughlyEnoughItemsForge {
}
}
- for (T instance : instances) {
- consumer.accept(instance);
+ for (Pair<List<String>, T> pair : instances) {
+ consumer.accept(pair.getLeft(), pair.getRight());
}
}
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringRulesScreen.java b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringRulesScreen.java
index daffac707..5cf8a567b 100644
--- a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringRulesScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringRulesScreen.java
@@ -45,7 +45,7 @@ import java.util.List;
import java.util.Objects;
import java.util.function.BiFunction;
-import static me.shedaniel.rei.gui.RecipeViewingScreen.CHEST_GUI_TEXTURE;
+import static me.shedaniel.rei.gui.DefaultDisplayViewingScreen.CHEST_GUI_TEXTURE;
public class FilteringRulesScreen extends Screen {
private final FilteringEntry entry;
diff --git a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java
index 3f32747e9..6da592c47 100644
--- a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java
+++ b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/RecipeScreenTypeEntry.java
@@ -27,8 +27,8 @@ import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.vertex.PoseStack;
import me.shedaniel.clothconfig2.gui.entries.TooltipListEntry;
-import me.shedaniel.rei.api.gui.config.RecipeScreenType;
-import me.shedaniel.rei.gui.PreRecipeViewingScreen;
+import me.shedaniel.rei.api.gui.config.DisplayScreenType;
+import me.shedaniel.rei.gui.UncertainDisplayViewingScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.chat.NarratorChatListener;
import net.minecraft.client.gui.components.AbstractButton;
@@ -41,18 +41,18 @@ import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
-public class RecipeScreenTypeEntry extends TooltipListEntry<RecipeScreenType> {
+public class RecipeScreenTypeEntry extends TooltipListEntry<DisplayScreenType> {
private int width;
- private final RecipeScreenType original;
- private RecipeScreenType type;
- private RecipeScreenType defaultValue;
- private Consumer<RecipeScreenType> save;
+ private final DisplayScreenType original;
+ private DisplayScreenType type;
+ private DisplayScreenType defaultValue;
+ private Consumer<DisplayScreenType> save;
private final AbstractWidget buttonWidget = new AbstractButton(0, 0, 0, 20, NarratorChatListener.NO_TITLE) {
@Override
public void onPress() {
- Minecraft.getInstance().setScreen(new PreRecipeViewingScreen(getConfigScreen(), type, false, original -> {
+ Minecraft.getInstance().setScreen(new UncertainDisplayViewingScreen(getConfigScreen(), type, false, original -> {
Minecraft.getInstance().setScreen(getConfigScreen());
- type = original ? RecipeScreenType.ORIGINAL : RecipeScreenType.VILLAGER;
+ type = original ? DisplayScreenType.ORIGINAL : DisplayScreenType.COMPOSITE;
}));
}
@@ -65,7 +65,7 @@ public class RecipeScreenTypeEntry extends TooltipListEntry<RecipeScreenType> {
private final List<GuiEventListener> children = ImmutableList.of(buttonWidget);
@SuppressWarnings("deprecation")
- public RecipeScreenTypeEntry(int width, Component fieldName, RecipeScreenType type, RecipeScreenType defaultValue, Consumer<RecipeScreenType> save) {
+ public RecipeScreenTypeEntry(int width, Component fieldName, DisplayScreenType type, DisplayScreenType defaultValue, Consumer<DisplayScreenType> save) {
super(fieldName, null);
this.original = type;
this.width = width;
@@ -80,12 +80,12 @@ public class RecipeScreenTypeEntry extends TooltipListEntry<RecipeScreenType> {
}
@Override
- public RecipeScreenType getValue() {
+ public DisplayScreenType getValue() {
return type;
}
@Override
- public Optional<RecipeScreenType> getDefaultValue() {
+ public Optional<DisplayScreenType> getDefaultValue() {
return Optional.ofNullable(defaultValue);
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/gui/AbstractDisplayViewingScreen.java
index c7fdcfc54..bfa985be7 100644
--- a/runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/gui/AbstractDisplayViewingScreen.java
@@ -43,7 +43,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
-public abstract class AbstractRecipeViewingScreen extends Screen implements RecipeScreen {
+public abstract class AbstractDisplayViewingScreen extends Screen implements RecipeScreen {
protected final Map<DisplayCategory<?>, List<Display>> categoryMap;
protected final List<DisplayCategory<?>> categories;
protected EntryStack<?> ingredientStackToNotice = EntryStack.empty();
@@ -52,7 +52,7 @@ public abstract class AbstractRecipeViewingScreen extends Screen implements Reci
protected int tabsPerPage;
protected Rectangle bounds;
- protected AbstractRecipeViewingScreen(Map<DisplayCategory<?>, List<Display>> categoryMap, @Nullable ResourceLocation category, int tabsPerPage) {
+ protected AbstractDisplayViewingScreen(Map<DisplayCategory<?>, List<Display>> categoryMap, @Nullable ResourceLocation category, int tabsPerPage) {
super(NarratorChatListener.NO_TITLE);
this.categoryMap = categoryMap;
this.categories = Lists.newArrayList(categoryMap.keySet());
diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/gui/CompositeDisplayViewingScreen.java
index 6bdd6beee..40826d9f3 100644
--- a/runtime/src/main/java/me/shedaniel/rei/gui/VillagerRecipeViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/gui/CompositeDisplayViewingScreen.java
@@ -68,7 +68,7 @@ import java.util.Map;
import java.util.Optional;
@ApiStatus.Internal
-public class VillagerRecipeViewingScreen extends AbstractRecipeViewingScreen {
+public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen {
private final List<Widget> widgets = Lists.newArrayList();
private final List<Button> buttonList = Lists.newArrayList();
private final List<DisplayRenderer> displayRenderers = Lists.newArrayList();
@@ -95,7 +95,7 @@ public class VillagerRecipeViewingScreen extends AbstractRecipeViewingScreen {
private long scrollBarAlphaFutureTime = -1;
private int tabsPage = -1;
- public VillagerRecipeViewingScreen(Map<DisplayCategory<?>, List<Display>> categoryMap, @Nullable ResourceLocation category) {
+ public CompositeDisplayViewingScreen(Map<DisplayCategory<?>, List<Display>> categoryMap, @Nullable ResourceLocation category) {
super(categoryMap, category, 8);
}
@@ -138,7 +138,7 @@ public class VillagerRecipeViewingScreen extends AbstractRecipeViewingScreen {
widgets.add(Widgets.createSlotBase(new Rectangle(xx - 1, yy - 1, 2 + w * 16, 2 + h * 16)));
int index = 0;
for (EntryIngredient workingStation : workstations) {
- widgets.add(new RecipeViewingScreen.WorkstationSlotWidget(xx, yy, workingStation));
+ widgets.add(new DefaultDisplayViewingScreen.WorkstationSlotWidget(xx, yy, workingStation));
index++;
xx += 16;
if (index >= ww) {
@@ -170,7 +170,7 @@ public class VillagerRecipeViewingScreen extends AbstractRecipeViewingScreen {
buttonList.add(Widgets.createButton(new Rectangle(bounds.x + 5, 0, displayRenderer.getWidth(), displayRenderer.getHeight()), NarratorChatListener.NO_TITLE)
.onClick(button -> {
selectedRecipeIndex = finalIndex;
- VillagerRecipeViewingScreen.this.init();
+ CompositeDisplayViewingScreen.this.init();
})
.containsMousePredicate((button, point) -> {
return (button.getBounds().contains(point) && scrollListBounds.contains(point)) || button.isFocused();
@@ -199,7 +199,7 @@ public class VillagerRecipeViewingScreen extends AbstractRecipeViewingScreen {
tabsPage--;
if (tabsPage < 0)
tabsPage = Mth.ceil(categories.size() / (float) tabsPerPage) - 1;
- VillagerRecipeViewingScreen.this.init();
+ CompositeDisplayViewingScreen.this.init();