aboutsummaryrefslogtreecommitdiff
path: root/api/src/main/java/me
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/main/java/me')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java2
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/EntryIngredient.java23
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java5
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/util/EntryIngredients.java2
4 files changed, 28 insertions, 4 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java b/api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java
index 663eb6ce7..1a72ee953 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java
@@ -95,7 +95,7 @@ public interface EntryStackProvider<T> {
@Override
public CompoundTag save() {
- return finalStack.save();
+ return finalStack.saveStack();
}
@Override
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 6e7862a55..cb3e68f44 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,7 @@ import org.jetbrains.annotations.ApiStatus;
import java.util.List;
import java.util.function.Predicate;
+import java.util.function.Supplier;
import java.util.function.UnaryOperator;
import java.util.stream.Collector;
import java.util.stream.Collectors;
@@ -38,6 +39,7 @@ import java.util.stream.Collectors;
/**
* An immutable representation of a list of {@link EntryStack}.
*/
+@ApiStatus.NonExtendable
public interface EntryIngredient extends List<EntryStack<?>> {
/**
* Returns an empty entry ingredient. This is the singleton instance of {@link EntryIngredient} that is
@@ -121,6 +123,12 @@ public interface EntryIngredient extends List<EntryStack<?>> {
return Internals.getEntryIngredientProvider().of(stacks);
}
+ /**
+ * Returns a {@link Collector} that accumulates the stacks into a
+ * new {@link EntryIngredient}.
+ *
+ * @return the collector
+ */
static Collector<EntryStack<?>, ?, EntryIngredient> collector() {
return Collectors.collectingAndThen(Collectors.toList(), EntryIngredient::of);
}
@@ -132,7 +140,22 @@ public interface EntryIngredient extends List<EntryStack<?>> {
* @throws UnsupportedOperationException if an {@link EntryDefinition} does not support saving to a tag
* @see EntrySerializer#supportSaving()
* @see EntryStack#saveStack()
+ * @since 8.3
+ */
+ default ListTag saveIngredient() {
+ return save();
+ }
+
+ /**
+ * Saves the entry ingredient to a {@link ListTag}. This is only supported if every entry stack has a serializer.
+ *
+ * @return the saved tag
+ * @throws UnsupportedOperationException if an {@link EntryDefinition} does not support saving to a tag
+ * @see EntrySerializer#supportSaving()
+ * @see EntryStack#saveStack()
+ * @deprecated use {@link #saveIngredient()} instead
*/
+ @Deprecated(forRemoval = true)
ListTag save();
/**
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java
index 7626611a2..6e3dbb673 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/EntryStack.java
@@ -144,7 +144,8 @@ public interface EntryStack<T> extends TextRepresentable, Renderer {
* @return the saved tag
* @throws UnsupportedOperationException if the {@link EntryDefinition} does not support saving to a tag
* @see EntrySerializer#supportSaving()
- * @see EntryIngredient#save()
+ * @see EntryIngredient#saveIngredient()
+ * @since 8.3
*/
@Nullable
default CompoundTag saveStack() {
@@ -157,7 +158,7 @@ public interface EntryStack<T> extends TextRepresentable, Renderer {
* @return the saved tag
* @throws UnsupportedOperationException if the {@link EntryDefinition} does not support saving to a tag
* @see EntrySerializer#supportSaving()
- * @see EntryIngredient#save()
+ * @see EntryIngredient#saveIngredient()
* @deprecated use {@link #saveStack()} instead
*/
@Nullable
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/util/EntryIngredients.java b/api/src/main/java/me/shedaniel/rei/api/common/util/EntryIngredients.java
index b33a3c231..a0231a40c 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/util/EntryIngredients.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/util/EntryIngredients.java
@@ -146,7 +146,7 @@ public final class EntryIngredients {
public static ListTag save(List<EntryIngredient> ingredients) {
ListTag listTag = new ListTag();
for (EntryIngredient ingredient : ingredients) {
- listTag.add(ingredient.save());
+ listTag.add(ingredient.saveIngredient());
}
return listTag;
}