aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/curseforge.yml10
-rw-r--r--.github/workflows/stale.yml20
-rw-r--r--api/build.gradle2
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/screen/DisplayScreen.java (renamed from runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/RecipeScreen.java)26
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java70
-rwxr-xr-xbuild.gradle31
-rw-r--r--default-plugin/build.gradle2
-rw-r--r--fabric/build.gradle27
-rw-r--r--forge/build.gradle28
-rw-r--r--forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java3
-rw-r--r--forge/src/main/resources/META-INF/mods.toml6
-rw-r--r--runtime/build.gradle2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java23
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/REIHelperImpl.java24
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java29
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java7
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java27
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/UncertainDisplayViewingScreen.java2
18 files changed, 196 insertions, 143 deletions
diff --git a/.github/workflows/curseforge.yml b/.github/workflows/curseforge.yml
index 00aa6971a..f22f5b7a2 100644
--- a/.github/workflows/curseforge.yml
+++ b/.github/workflows/curseforge.yml
@@ -11,6 +11,7 @@ on:
- 4.x-unstable
- 4.x
- 5.x
+ - 6.x
jobs:
build:
@@ -22,13 +23,8 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.8
- - name: Clean Gradle
- run: ./gradlew clean --refresh-dependencies --stacktrace
- env:
- danielshe_curse_api_key: ${{ secrets.CF_API_KEY }}
- BRANCH_NAME: ${{ github.ref }}
- - name: Upload to CurseForge and Maven
- run: ./gradlew build publish releaseOnCf --stacktrace
+ - name: Upload to CurseForge
+ run: ./gradlew build curseforge --stacktrace
env:
danielshe_curse_api_key: ${{ secrets.CF_API_KEY }}
BRANCH_NAME: ${{ github.ref }}
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
deleted file mode 100644
index 5bcf6e137..000000000
--- a/.github/workflows/stale.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-name: Mark stale issues and pull requests
-
-on:
- schedule:
- - cron: "0 0 * * *"
-
-jobs:
- stale:
-
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/stale@v1
- with:
- repo-token: ${{ secrets.GITHUB_TOKEN }}
- stale-issue-message: 'This issue is marked with stale as this issue had no activity in 60 days. This issue will not be automatically closed.'
- stale-pr-message: 'This pull request is marked with stale as this pull request had no activity in 60 days. This pull request will not be automatically closed.'
- stale-issue-label: 'stale'
- stale-pr-label: 'stale'
- days-before-close: 1000000000
diff --git a/api/build.gradle b/api/build.gradle
index 925fed277..3a332c299 100644
--- a/api/build.gradle
+++ b/api/build.gradle
@@ -1,5 +1,3 @@
-archivesBaseName = "api"
-
dependencies {
modCompileOnly("net.fabricmc:fabric-loader:${project.fabricloader_version}")
modCompileOnly("me.shedaniel.cloth:cloth-config:${cloth_config_version}")
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/RecipeScreen.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/screen/DisplayScreen.java
index 7309262e1..259088e2f 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/RecipeScreen.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/screen/DisplayScreen.java
@@ -21,22 +21,34 @@
* SOFTWARE.
*/
-package me.shedaniel.rei.impl.client.gui.screen;
+package me.shedaniel.rei.api.client.gui.screen;
import me.shedaniel.math.Rectangle;
+import me.shedaniel.rei.api.client.registry.display.DisplayCategory;
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 org.jetbrains.annotations.ApiStatus;
-@ApiStatus.Internal
-public interface RecipeScreen {
+public interface DisplayScreen {
Rectangle getBounds();
- void addIngredientStackToNotice(EntryStack<?> stack);
+ void setIngredientStackToNotice(EntryStack<?> stack);
- void addResultStackToNotice(EntryStack<?> stack);
+ void setResultStackToNotice(EntryStack<?> stack);
- CategoryIdentifier<?> getCurrentCategory();
+ EntryStack<?> getIngredientStackToNotice();
+
+ EntryStack<?> getResultStackToNotice();
+
+ default CategoryIdentifier<?> getCurrentCategoryId() {
+ return getCurrentCategory().getCategoryIdentifier();
+ }
+
+ DisplayCategory<Display> getCurrentCategory();
void recalculateCategoryPage();
+
+ void previousCategory();
+
+ void nextCategory();
} \ No newline at end of file
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 45d065ee6..a191d85ce 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
@@ -47,16 +47,18 @@ import java.util.stream.StreamSupport;
public class CollectionUtils {
public static <A, B> List<B> getOrPutEmptyList(Map<A, List<B>> map, A key) {
List<B> b = map.get(key);
- if (b != null)
+ if (b != null) {
return b;
+ }
map.put(key, new ArrayList<>());
return map.get(key);
}
public static <T> T findFirstOrNullEquals(Iterable<T> list, T obj) {
for (T t : list) {
- if (t.equals(obj))
+ if (t.equals(obj)) {
return t;
+ }
}
return null;
}
@@ -64,26 +66,24 @@ public class CollectionUtils {
public static <T, R> List<R> castAndMap(Iterable<T> list, Class<R> castClass) {
List<R> l = new ArrayList<>();
for (T t : list) {
- if (castClass.isAssignableFrom(t.getClass()))
+ if (castClass.isAssignableFrom(t.getClass())) {
l.add((R) t);
+ }
}
return l;
}
public static <T> T findFirstOrNull(Iterable<T> list, Predicate<T> predicate) {
for (T t : list) {
- if (predicate.test(t))
+ if (predicate.test(t)) {
return t;
+ }
}
return null;
}
public static <T> boolean anyMatch(Iterable<T> list, Predicate<T> predicate) {
- for (T t : list) {
- if (predicate.test(t))
- return true;
- }
- return false;
+ return findFirstOrNull(list, predicate) != null;
}
public static EntryStack<?> findFirstOrNullEqualsExact(Iterable<? extends EntryStack<?>> list, EntryStack<?> stack) {
@@ -155,8 +155,9 @@ public class CollectionUtils {
}
public static <T, R> Optional<R> mapAndMax(Collection<T> list, Function<T, R> function, Comparator<R> comparator) {
- if (list.isEmpty())
+ if (list.isEmpty()) {
return Optional.empty();
+ }
return list.stream().max(Comparator.comparing(function, comparator)).map(function);
}
@@ -167,34 +168,28 @@ public class CollectionUtils {
}
public static <T> Optional<T> max(Collection<T> list, Comparator<T> comparator) {
- if (list.isEmpty())
+ if (list.isEmpty()) {
return Optional.empty();
+ }
return list.stream().max(comparator);
}
public static <T> Optional<T> max(T[] list, Comparator<T> comparator) {
- if (list.length <= 0)
+ if (list.length <= 0) {
return Optional.empty();
+ }
return Stream.of(list).max(comparator);
}
- public static String joinToString(Iterable<String> list, String separator) {
- StringJoiner joiner = new StringJoiner(separator);
- for (String t : list) {
- joiner.add(t);
- }
- return joiner.toString();
+ public static String joinToString(Iterable<CharSequence> list, CharSequence separator) {
+ return String.join(separator, list);
}
- public static String joinToString(String[] list, String separator) {
- StringJoiner joiner = new StringJoiner(separator);
- for (String t : list) {
- joiner.add(t);
- }
- return joiner.toString();
+ public static String joinToString(CharSequence[] list, CharSequence separator) {
+ return String.join(separator, list);
}
- public static <T> String mapAndJoinToString(Iterable<T> list, Function<T, String> function, String separator) {
+ public static <T> String mapAndJoinToString(Iterable<T> list, Function<T, CharSequence> function, CharSequence separator) {
StringJoiner joiner = new StringJoiner(separator);
for (T t : list) {
joiner.add(function.apply(t));
@@ -202,7 +197,7 @@ public class CollectionUtils {
return joiner.toString();
}
- public static <T> String mapAndJoinToString(T[] list, Function<T, String> function, String separator) {
+ public static <T> String mapAndJoinToString(T[] list, Function<T, CharSequence> function, CharSequence separator) {
StringJoiner joiner = new StringJoiner(separator);
for (T t : list) {
joiner.add(function.apply(t));
@@ -282,8 +277,8 @@ public class CollectionUtils {
return sum;
}
- public static <T> Iterable<Iterable<T>> partition(List<T> list, int size) {
- return () -> new UnmodifiableIterator<Iterable<T>>() {
+ public static <T> Iterable<List<T>> partition(List<T> list, int size) {
+ return () -> new UnmodifiableIterator<List<T>>() {
int i = 0;
int partitionSize = Mth.ceil(list.size() / (float) size);
@@ -293,22 +288,9 @@ public class CollectionUtils {
}
@Override
- public Iterable<T> next() {
- UnmodifiableIterator<T> iterator = new UnmodifiableIterator<T>() {
- int cursor = i++ * size;
- int curSize = cursor + Math.min(list.size() - cursor, size);
-
- @Override
- public boolean hasNext() {
- return cursor < curSize;
- }
-
- @Override
- public T next() {
- return list.get(cursor++);
- }
- };
- return () -> iterator;
+ public List<T> next() {
+ int cursor = i++ * size;
+ return list.subList(cursor, cursor + Math.min(list.size() - cursor, size));
}
};
}
diff --git a/build.gradle b/build.gradle
index 1aff1a6b3..3e18d4b57 100755
--- a/build.gradle
+++ b/build.gradle
@@ -11,8 +11,8 @@ import java.text.SimpleDateFormat
archivesBaseName = "RoughlyEnoughItems"
-def runNumber = (System.getenv("GITHUB_RUN_NUMBER") == null ? "9999" : System.getenv("GITHUB_RUN_NUMBER"))
-version = rootProject.base_version + "." + runNumber
+def runNumber = System.getenv("GITHUB_RUN_NUMBER") ?: "9999"
+version = rootProject.base_version + "." + runNumber + "-alpha"
group = "me.shedaniel"
@@ -66,6 +66,7 @@ subprojects {
group = rootProject.group
version = rootProject.version
+ archivesBaseName = rootProject.name
// loom {
// silentMojangMappingsLicense()
@@ -147,10 +148,10 @@ task releaseOnCf {
dependsOn tasks.getByName("curseforge")
}
-/*curseforge {
+curseforge {
if (project.hasProperty('danielshe_curse_api_key') || System.getenv('danielshe_curse_api_key') != null) {
apiKey = project.hasProperty('danielshe_curse_api_key') ? project.property('danielshe_curse_api_key') : System.getenv('danielshe_curse_api_key')
- project {
+ /*project {
id = "310111"
releaseType = "release"
changelogType = "html"
@@ -175,6 +176,26 @@ task releaseOnCf {
afterEvaluate {
uploadTask.dependsOn("build")
}
+ }*/
+ project {
+ id = "392060"
+ releaseType = "beta"
+ changelogType = "html"
+ changelog = releaseChangelog
+ addGameVersion "1.16.4"
+ addGameVersion "1.16.5"
+ addGameVersion "Java 8"
+ addGameVersion "Forge"
+ relations {
+ requiredDependency "architectury-forge"
+ requiredDependency "cloth-config-forge"
+ }
+ addArtifact(project("forge").tasks.getByName("remapJar")) {
+ displayName = "[Forge $project.supported_version] v$project.version"
+ }
+ afterEvaluate {
+ uploadTask.dependsOn("forge:build")
+ }
}
}
options {
@@ -183,7 +204,7 @@ task releaseOnCf {
}
}
-publishing {
+/*publishing {
publications {
mavenJava(MavenPublication) {
artifact(jar) {
diff --git a/default-plugin/build.gradle b/default-plugin/build.gradle
index 4f7fbee58..88bf7f1f4 100644
--- a/default-plugin/build.gradle
+++ b/default-plugin/build.gradle
@@ -1,5 +1,3 @@
-archivesBaseName = "default-plugin"
-
loom {
accessWidener = gradle.rootProject.project("fabric").file("src/main/resources/roughlyenoughitems.accessWidener")
}
diff --git a/fabric/build.gradle b/fabric/build.gradle
index be813394e..a96854333 100644
--- a/fabric/build.gradle
+++ b/fabric/build.gradle
@@ -1,4 +1,10 @@
-archivesBaseName = "fabric"
+plugins {
+ id "com.github.johnrengelman.shadow" version "5.0.0"
+}
+
+configurations {
+ shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
+}
architectury {
platformSetupLoomIde()
@@ -36,4 +42,23 @@ dependencies {
developmentFabric(project(path: ":api")) { transitive = false }
developmentFabric(project(path: ":default-plugin")) { transitive = false }
developmentFabric(project(path: ":runtime")) { transitive = false }
+
+ shadowCommon(project(path: ":api", configuration: "transformProductionFabric")) { transitive = false }
+ shadowCommon(project(path: ":default-plugin", configuration: "transformProductionFabric")) { transitive = false }
+ shadowCommon(project(path: ":runtime", configuration: "transformProductionFabric")) { transitive = false }
+}
+
+shadowJar {
+ configurations = [project.configurations.shadowCommon]
+ classifier "dev-shadow"
+}
+
+remapJar {
+ input.set shadowJar.archiveFile
+ dependsOn shadowJar
+ classifier "fabric"
+}
+
+jar {
+ classifier "dev"
}
diff --git a/forge/build.gradle b/forge/build.gradle
index 338ecaa99..2674432f9 100644
--- a/forge/build.gradle
+++ b/forge/build.gradle
@@ -1,4 +1,10 @@
-archivesBaseName = "forge"
+plugins {
+ id "com.github.johnrengelman.shadow" version "5.0.0"
+}
+
+configurations {
+ shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
+}
architectury {
platformSetupLoomIde()
@@ -38,9 +44,29 @@ dependencies {
developmentForge(project(path: ":runtime")) { transitive = false }
developmentForge(project(path: ":jei-compatibility-layer")) { transitive = false }
+ shadowCommon(project(path: ":api", configuration: "transformProductionForge")) { transitive = false }
+ shadowCommon(project(path: ":default-plugin", configuration: "transformProductionForge")) { transitive = false }
+ shadowCommon(project(path: ":runtime", configuration: "transformProductionForge")) { transitive = false }
+ shadowCommon(project(path: ":jei-compatibility-layer")) { transitive = false }
+
modRuntime("curse.maven:chiselsbits-231095:3176033")
modRuntime("curse.maven:jumbofurnace-390880:3120970")
modRuntime("curse.maven:cyclic-239286:3221427")
modRuntime("curse.maven:mekanism-268560:3206392")
modRuntime("appeng:appliedenergistics2:8.2.0")
}
+
+shadowJar {
+ configurations = [project.configurations.shadowCommon]
+ classifier "dev-shadow"
+}
+
+remapJar {
+ input.set shadowJar.archiveFile
+ dependsOn shadowJar
+ classifier "forge"
+}
+
+jar {
+ classifier "dev"
+}
diff --git a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java
index b6ce353b2..a433c87a5 100644
--- a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java
+++ b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java
@@ -34,6 +34,9 @@ public class RoughlyEnoughItemsInitializerImpl {
}
public static void checkMods() {
+ if (ModList.get().isLoaded("jei")) {
+ RoughlyEnoughItemsState.error("JEI is installed! REI is an replacement of JEI, we can't co-exist!");
+ }
if (isClient()) {
if (!ModList.get().isLoaded("cloth-config")) {
RoughlyEnoughItemsState.error("Cloth Config is not installed!", "https://www.curseforge.com/minecraft/mc-mods/cloth-config/files/all");
diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml
index aa62f0797..02685e595 100644
--- a/forge/src/main/resources/META-INF/mods.toml
+++ b/forge/src/main/resources/META-INF/mods.toml
@@ -13,8 +13,8 @@ To allow players to view items and recipes.
'''
[[dependencies.roughlyenoughitems]]
-modId = "cloth-config"
+modId = "architectury"
mandatory = true
-versionRange = "[4.0.1,)"
+versionRange = "[1.9.136,)"
ordering = "NONE"
-side = "CLIENT" \ No newline at end of file
+side = "BOTH"
diff --git a/runtime/build.gradle b/runtime/build.gradle
index 5d6c24c49..53c1100d7 100644
--- a/runtime/build.gradle
+++ b/runtime/build.gradle
@@ -1,5 +1,3 @@
-archivesBaseName = "runtime"
-
architectury {
common()
}
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 9590c62a7..abaf8443f 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
@@ -43,7 +43,7 @@ import me.shedaniel.rei.api.common.util.EntryStacks;
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.RecipeScreen;
+import me.shedaniel.rei.api.client.gui.screen.DisplayScreen;
import me.shedaniel.rei.impl.client.gui.screen.UncertainDisplayViewingScreen;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -242,14 +242,17 @@ public class ClientHelperImpl implements ClientHelper {
} else {
screen = new DefaultDisplayViewingScreen(map, builder.getPreferredOpenedCategory());
}
- if (screen instanceof RecipeScreen) {
- if (builder.getInputNotice() != null)
- ((RecipeScreen) screen).addIngredientStackToNotice(builder.getInputNotice());
- if (builder.getOutputNotice() != null)
- ((RecipeScreen) screen).addResultStackToNotice(builder.getOutputNotice());
+ if (screen instanceof DisplayScreen) {
+ if (builder.getInputNotice() != null) {
+ ((DisplayScreen) screen).setIngredientStackToNotice(builder.getInputNotice());
+ }
+ if (builder.getOutputNotice() != null) {
+ ((DisplayScreen) screen).setResultStackToNotice(builder.getOutputNotice());
+ }
+ }
+ if (Minecraft.getInstance().screen instanceof DisplayScreen) {
+ REIHelperImpl.getInstance().storeDisplayScreen((DisplayScreen) Minecraft.getInstance().screen);
}
- if (Minecraft.getInstance().screen instanceof RecipeScreen)
- REIHelperImpl.getInstance().storeRecipeScreen((RecipeScreen) Minecraft.getInstance().screen);
Minecraft.getInstance().setScreen(screen);
return true;
}
@@ -269,8 +272,8 @@ public class ClientHelperImpl implements ClientHelper {
public ViewSearchBuilder fillPreferredOpenedCategory() {
if (getPreferredOpenedCategory() == null) {
Screen currentScreen = Minecraft.getInstance().screen;
- if (currentScreen instanceof RecipeScreen) {
- setPreferredOpenedCategory(((RecipeScreen) currentScreen).getCurrentCategory());
+ if (currentScreen instanceof DisplayScreen) {
+ setPreferredOpenedCategory(((DisplayScreen) currentScreen).getCurrentCategoryId());
}
}
return this;
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 82c3eb983..568149a11 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
@@ -38,7 +38,7 @@ import me.shedaniel.rei.api.client.gui.widgets.TextField;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry;
import me.shedaniel.rei.impl.client.gui.ContainerScreenOverlay;
-import me.shedaniel.rei.impl.client.gui.screen.RecipeScreen;
+import me.shedaniel.rei.api.client.gui.screen.DisplayScreen;
import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -64,7 +64,7 @@ public class REIHelperImpl implements REIHelper {
private OverlaySearchField searchField;
private AbstractContainerScreen<?> previousContainerScreen = null;
private Screen previousScreen = null;
- private LinkedHashSet<RecipeScreen> lastRecipeScreen = Sets.newLinkedHashSetWithExpectedSize(10);
+ private LinkedHashSet<DisplayScreen> lastDisplayScreen = Sets.newLinkedHashSetWithExpectedSize(10);
/**
* @return the instance of screen helper
@@ -97,19 +97,19 @@ public class REIHelperImpl implements REIHelper {
return (OverlaySearchField) getInstance().getSearchTextField();
}
- public void storeRecipeScreen(RecipeScreen screen) {
- while (lastRecipeScreen.size() >= 10)
- lastRecipeScreen.remove(Iterables.get(lastRecipeScreen, 0));
- lastRecipeScreen.add(screen);
+ public void storeDisplayScreen(DisplayScreen screen) {
+ while (lastDisplayScreen.size() >= 10)
+ lastDisplayScreen.remove(Iterables.get(lastDisplayScreen, 0));
+ lastDisplayScreen.add(screen);
}
- public boolean hasLastRecipeScreen() {
- return !lastRecipeScreen.isEmpty();
+ public boolean hasLastDisplayScreen() {
+ return !lastDisplayScreen.isEmpty();
}
- public Screen getLastRecipeScreen() {
- RecipeScreen screen = Iterables.getLast(lastRecipeScreen);
- lastRecipeScreen.remove(screen);
+ public Screen getLastDisplayScreen() {
+ DisplayScreen screen = Iterables.getLast(lastDisplayScreen);
+ lastDisplayScreen.remove(screen);
screen.recalculateCategoryPage();
return (Screen) screen;
}
@@ -208,7 +208,7 @@ public class REIHelperImpl implements REIHelper {
@Override
public void startReload() {
getOverlay().ifPresent(REIOverlay::queueReloadOverlay);
- lastRecipeScreen.clear();
+ lastDisplayScreen.clear();
}
@Override
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java
index 05230cbe5..833f4fa01 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/AbstractDisplayViewingScreen.java
@@ -25,6 +25,7 @@ package me.shedaniel.rei.impl.client.gui.screen;
import com.google.common.collect.Lists;
import me.shedaniel.math.Rectangle;
+import me.shedaniel.rei.api.client.gui.screen.DisplayScreen;
import me.shedaniel.rei.api.client.gui.widgets.Slot;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.api.client.gui.widgets.Widgets;
@@ -43,7 +44,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
-public abstract class AbstractDisplayViewingScreen extends Screen implements RecipeScreen {
+public abstract class AbstractDisplayViewingScreen extends Screen implements DisplayScreen {
protected final Map<DisplayCategory<?>, List<Display>> categoryMap;
protected final List<DisplayCategory<?>> categories;
protected EntryStack<?> ingredientStackToNotice = EntryStack.empty();
@@ -68,35 +69,42 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Rec
}
@Override
+ public boolean isPauseScreen() {
+ return false;
+ }
+
+ @Override
public Rectangle getBounds() {
return bounds;
}
@Override
- public void addIngredientStackToNotice(EntryStack<?> stack) {
+ public void setIngredientStackToNotice(EntryStack<?> stack) {
this.ingredientStackToNotice = stack;
}
@Override
- public void addResultStackToNotice(EntryStack<?> stack) {
+ public void setResultStackToNotice(EntryStack<?> stack) {
this.resultStackToNotice = stack;
}
@Override
- public boolean isPauseScreen() {
- return false;
+ public EntryStack<?> getIngredientStackToNotice() {
+ return ingredientStackToNotice;
}
@Override
- public CategoryIdentifier<?> getCurrentCategory() {
- return getSelectedCategory().getCategoryIdentifier();
+ public EntryStack<?> getResultStackToNotice() {
+ return resultStackToNotice;
}
- public DisplayCategory<Display> getSelectedCategory() {
+ @Override
+ public DisplayCategory<Display> getCurrentCategory() {
return (DisplayCategory<Display>) categories.get(selectedCategoryIndex);
}
- protected void previousCategory() {
+ @Override
+ public void previousCategory() {
int currentCategoryIndex = selectedCategoryIndex;
currentCategoryIndex--;
if (currentCategoryIndex < 0)
@@ -104,7 +112,8 @@ public abstract class AbstractDisplayViewingScreen extends Screen implements Rec
ClientHelperImpl.getInstance().openRecipeViewingScreen(categoryMap, categories.get(currentCategoryIndex).getCategoryIdentifier(), ingredientStackToNotice, resultStackToNotice);
}
- protected void nextCategory() {
+ @Override
+ public void nextCategory() {
int currentCategoryIndex = selectedCategoryIndex;
currentCategoryIndex++;
if (currentCategoryIndex >= categories.size())
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java
index 619b9ab7a..6214c0254 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/CompositeDisplayViewingScreen.java
@@ -411,10 +411,11 @@ public class CompositeDisplayViewingScreen extends AbstractDisplayViewingScreen
return true;
}
if (keyCode == 259) {
- if (REIHelperImpl.getInstance().hasLastRecipeScreen())
- minecraft.setScreen(REIHelperImpl.getInstance().getLastRecipeScreen());
- else
+ if (REIHelperImpl.getInstance().hasLastDisplayScreen()) {
+ minecraft.setScreen(REIHelperImpl.getInstance().getLastDisplayScreen());
+ } else {
minecraft.setScreen(REIHelper.getInstance().getPreviousScreen());
+ }
return true;
}
return super.keyPressed(keyCode, scanCode, modifiers);
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
index 915e85be6..85cb85994 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/DefaultDisplayViewingScreen.java
@@ -143,10 +143,11 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
return true;
}
if (keyCode == 259) {
- if (REIHelperImpl.getInstance().hasLastRecipeScreen())
- minecraft.setScreen(REIHelperImpl.getInstance().getLastRecipeScreen());
- else
+ if (REIHelperImpl.getInstance().hasLastDisplayScreen()) {
+ minecraft.setScreen(REIHelperImpl.getInstance().getLastDisplayScreen());
+ } else {
minecraft.setScreen(REIHelper.getInstance().getPreviousScreen());
+ }
return true;
}
return super.keyPressed(keyCode, scanCode, modifiers);
@@ -164,7 +165,7 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
this.widgets.clear();
int largestWidth = width - 100;
int largestHeight = Math.max(height - 34 - 30, 100);
- int maxWidthDisplay = CollectionUtils.mapAndMax(getCurrentDisplayed(), getSelectedCategory()::getDisplayWidth, Comparator.naturalOrder()).orElse(150);
+ int maxWidthDisplay = CollectionUtils.mapAndMax(getCurrentDisplayed(), getCurrentCategory()::getDisplayWidth, Comparator.naturalOrder()).orElse(150);
int guiWidth = Math.max(maxWidthDisplay + 40, 190);
this.tabsPerPage = Math.max(5, Mth.floor((guiWidth - 20d) / tabSize));
if (this.categoryPages == -1) {
@@ -194,7 +195,7 @@ public class DefaultDisplayViewingScreen extends AbstractDisplayViewingScreen {
.enabled(categories.size() > tabsPerPage));
widgets.add(categoryBack = Widgets.createButton(new Rectangle(bounds.getX() + 5, bounds.getY() + 5, 12, 12), new TranslatableComponent("text.rei.left_arrow"))
.onClick(button -> previousCategory()).tooltipLine(new TranslatableComponent("text.rei.previous_category")));
- widgets.add(Widgets.createClickableLabel(new Point(bounds.getCenterX(), bounds.getY() + 7), getSelectedCategory().getTitle(), clickableLabelWidget -> {
+ widgets.add(Widgets.createClickableLabel(new Point(bounds.getCenterX(), bounds.getY() + 7), getCurrentCategory().getTitle(),