aboutsummaryrefslogtreecommitdiff
path: root/api/src/main/java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-06-20 17:23:47 +0800
committershedaniel <daniel@shedaniel.me>2023-05-29 21:01:44 +0800
commit0d3acf2cae1bb9ec625b4d9e80daa529334e7974 (patch)
tree82f5e2fef51b8ab0d2c5c8b4280985b64c574961 /api/src/main/java
parent404506009fc4de8606c13e90b3bf0cfab19f08b8 (diff)
downloadRoughlyEnoughItems-0d3acf2cae1bb9ec625b4d9e80daa529334e7974.tar.gz
RoughlyEnoughItems-0d3acf2cae1bb9ec625b4d9e80daa529334e7974.tar.bz2
RoughlyEnoughItems-0d3acf2cae1bb9ec625b4d9e80daa529334e7974.zip
Migrate EntryIngredient and EntryStack save() to saveIngredient() and saveStack()
Diffstat (limited to 'api/src/main/java')
-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 82c804577..b3c5616c9 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,11 +31,13 @@ import org.jetbrains.annotations.ApiStatus;
import java.util.List;
import java.util.function.Predicate;
+import java.util.function.Supplier;
import java.util.function.UnaryOperator;
/**
* 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
@@ -119,6 +121,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);
}
@@ -130,7 +138,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 61256b6d2..bacf2781e 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
@@ -142,7 +142,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() {
@@ -155,7 +156,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 718dfae82..41c103a03 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
@@ -147,7 +147,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;
}