diff --git a/src/main/java/org/spongepowered/api/item/recipe/RecipeManager.java b/src/main/java/org/spongepowered/api/item/recipe/RecipeManager.java index bb1e05ca83..5ddae2894c 100644 --- a/src/main/java/org/spongepowered/api/item/recipe/RecipeManager.java +++ b/src/main/java/org/spongepowered/api/item/recipe/RecipeManager.java @@ -25,6 +25,7 @@ package org.spongepowered.api.item.recipe; import org.spongepowered.api.ResourceKey; +import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.item.inventory.ItemStackSnapshot; import org.spongepowered.api.item.recipe.cooking.CookingRecipe; import org.spongepowered.api.item.recipe.crafting.RecipeInput; @@ -76,6 +77,14 @@ default > Collection allOfType(Supplier> Collection findByResult(RecipeType type, ItemStackSnapshot result) { + return this.findByResult(type, (ItemStackLike) result); + } + /** * Returns all registered recipes of given type and with given item as a result. * @@ -84,7 +93,15 @@ default > Collection allOfType(Supplier> Collection findByResult(RecipeType type, ItemStackSnapshot result); + > Collection findByResult(RecipeType type, ItemStackLike result); + + /** + * @deprecated Use {@link #findByResult(Supplier, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default > Collection findByResult(Supplier> supplier, ItemStackSnapshot result) { + return this.findByResult(supplier, (ItemStackLike) result); + } /** * Gets all recipes with given item as a result. @@ -93,7 +110,7 @@ default > Collection allOfType(Supplier> Collection findByResult(Supplier> supplier, ItemStackSnapshot result) { + default > Collection findByResult(Supplier> supplier, ItemStackLike result) { return this.findByResult(supplier.get(), result); } @@ -121,6 +138,14 @@ default > Optional findMatchingRec return this.findMatchingRecipe(supplier.get(), input, world); } + /** + * @deprecated Use {@link #findCookingRecipe(RecipeType, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default Optional findCookingRecipe(RecipeType type, ItemStackSnapshot ingredient) { + return this.findCookingRecipe(type, (ItemStackLike) ingredient); + } + /** * Finds a matching cooking recipe for given type and ingredient * @@ -129,7 +154,15 @@ default > Optional findMatchingRec * * @return The matching recipe. */ - Optional findCookingRecipe(RecipeType type, ItemStackSnapshot ingredient); + Optional findCookingRecipe(RecipeType type, ItemStackLike ingredient); + + /** + * @deprecated Use {@link #findCookingRecipe(Supplier, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default Optional findCookingRecipe(Supplier> supplier, ItemStackSnapshot ingredient) { + return this.findCookingRecipe(supplier, (ItemStackLike) ingredient); + } /** * Finds a matching cooking recipe for given type and ingredient @@ -139,7 +172,7 @@ default > Optional findMatchingRec * * @return The matching recipe. */ - default Optional findCookingRecipe(Supplier> supplier, ItemStackSnapshot ingredient) { + default Optional findCookingRecipe(Supplier> supplier, ItemStackLike ingredient) { return this.findCookingRecipe(supplier.get(), ingredient); } diff --git a/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingRecipe.java b/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingRecipe.java index 6038676b55..776725f7e0 100644 --- a/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingRecipe.java +++ b/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingRecipe.java @@ -29,6 +29,7 @@ import org.spongepowered.api.datapack.DataPack; import org.spongepowered.api.item.ItemType; import org.spongepowered.api.item.inventory.ItemStack; +import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.item.inventory.ItemStackSnapshot; import org.spongepowered.api.item.recipe.Recipe; import org.spongepowered.api.item.recipe.RecipeRegistration; @@ -64,25 +65,41 @@ static Builder builder() { Ingredient ingredient(); /** - * Checks if the given {@link ItemStackSnapshot} fits the required + * @deprecated Use {@link #isValid(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default boolean isValid(ItemStackSnapshot ingredient) { + return this.isValid((ItemStackLike) ingredient); + } + + /** + * Checks if the given {@link ItemStackLike} fits the required * constraints to craft this {@link CookingRecipe}. * * @param ingredient The ingredient to check against * * @return Whether this ingredient can be used to craft the result */ - boolean isValid(ItemStackSnapshot ingredient); + boolean isValid(ItemStackLike ingredient); + + /** + * @deprecated Use {@link #result(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default Optional result(ItemStackSnapshot ingredient) { + return this.result((ItemStackLike) ingredient); + } /** *

Returns the {@link CookingResult} containing the resulting - * {@link ItemStackSnapshot} and the amount of experience released.

+ * {@link ItemStackLike} and the amount of experience released.

* - * @param ingredient The {@link ItemStackSnapshot} currently being cooked + * @param ingredient The {@link ItemStackLike} currently being cooked * @return The {@link CookingResult}, or {@link Optional#empty()} * if the recipe is not valid according to - * {@link #isValid(ItemStackSnapshot)}. + * {@link #isValid(ItemStackLike)}. */ - Optional result(ItemStackSnapshot ingredient); + Optional result(ItemStackLike ingredient); /** * Returns the cooking time in ticks. @@ -183,24 +200,38 @@ default EndStep result(Supplier result) { } /** - * Changes the result and returns this builder. The result is the - * {@link ItemStack} created when the recipe is fulfilled. - * - * @param result The output of this recipe - * - * @return This builder, for chaining + * @deprecated Use {@link #result(ItemStackLike)} instead. */ - EndStep result(ItemStack result); + @Deprecated(forRemoval = true) + default EndStep result(ItemStack result) { + return this.result((ItemStackLike) result); + } + + /** + * @deprecated Use {@link #result(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default EndStep result(ItemStackSnapshot result) { + return this.result((ItemStackLike) result); + } /** * Changes the result and returns this builder. The result is the - * {@link ItemStack} created when the recipe is fulfilled. + * {@link ItemStackLike} created when the recipe is fulfilled. * * @param result The output of this recipe * * @return This builder, for chaining */ - EndStep result(ItemStackSnapshot result); + EndStep result(ItemStackLike result); + + /** + * @deprecated Use {@link #result(Function, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default EndStep result(final Function resultFunction, final ItemStack exemplaryResult) { + return this.result(resultFunction, (ItemStackLike) exemplaryResult); + } /** * Sets the result function and an exemplary result. @@ -210,7 +241,7 @@ default EndStep result(Supplier result) { * * @return The builder */ - EndStep result(final Function resultFunction, final ItemStack exemplaryResult); + EndStep result(final Function resultFunction, final ItemStackLike exemplaryResult); } interface EndStep extends Builder, diff --git a/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingResult.java b/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingResult.java index c978d3951c..8cb100ba48 100644 --- a/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingResult.java +++ b/src/main/java/org/spongepowered/api/item/recipe/cooking/CookingResult.java @@ -24,6 +24,7 @@ */ package org.spongepowered.api.item.recipe.cooking; +import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.item.inventory.ItemStackSnapshot; import java.util.Objects; @@ -37,6 +38,14 @@ public final class CookingResult { private final ItemStackSnapshot result; private final double experience; + /** + * @deprecated Use {@link #CookingResult(ItemStackLike, double)} instead. + */ + @Deprecated(forRemoval = true) + public CookingResult(final ItemStackSnapshot result, final double experience) { + this((ItemStackLike) result, experience); + } + /** * Creates a new {@link CookingResult}. * @@ -45,16 +54,16 @@ public final class CookingResult { * @param result The result of the cooking recipe * @param experience The experience that should be created from this result */ - public CookingResult(final ItemStackSnapshot result, final double experience) { + public CookingResult(final ItemStackLike result, final double experience) { Objects.requireNonNull(result, "result"); if (result.isEmpty()) { - throw new IllegalArgumentException("The resulting snapshot must not be empty"); + throw new IllegalArgumentException("The result must not be empty"); } if (experience < 0) { throw new IllegalArgumentException("The experience must be non-negative."); } - this.result = result; + this.result = result.asImmutable(); this.experience = experience; } diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/Ingredient.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/Ingredient.java index c2e6062d19..abefa1b908 100644 --- a/src/main/java/org/spongepowered/api/item/recipe/crafting/Ingredient.java +++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/Ingredient.java @@ -29,6 +29,7 @@ import org.spongepowered.api.Sponge; import org.spongepowered.api.item.ItemType; import org.spongepowered.api.item.inventory.ItemStack; +import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.item.inventory.ItemStackSnapshot; import org.spongepowered.api.registry.DefaultedRegistryReference; @@ -53,11 +54,19 @@ static Ingredient empty() { return Sponge.game().factoryProvider().provide(Factory.class).empty(); } + /** + * @deprecated Use {@link #test(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) @Override - boolean test(ItemStack itemStack); + default boolean test(ItemStack itemStack) { + return this.test((ItemStackLike) itemStack); + } + + boolean test(ItemStackLike item); /** - * Returns the list of {@link ItemStack}s used to display the ingredient in a recipe. + * Returns the list of {@link ItemStackSnapshot}s used to display the ingredient in a recipe. * These are not necessarily all the items that this Ingredient can match. * * @return The list of items to display the Ingredient in a recipe. @@ -87,25 +96,28 @@ static Ingredient of(ItemType @Nullable ... itemTypes) { } /** - * Creates a new {@link Ingredient} for the provided {@link ItemStack}s. - * - * @param items The items - * @return The new ingredient + * @deprecated Use {@link #of(ItemStackLike...)} instead. */ + @Deprecated(forRemoval = true) static Ingredient of(ItemStack @Nullable ... items) { - if (items == null || items.length == 0) { - return Ingredient.empty(); - } - return Ingredient.builder().with(items).build(); + return Ingredient.of((ItemStackLike[]) items); } /** - * Creates a new {@link Ingredient} for the provided {@link ItemStackSnapshot}s. + * @deprecated Use {@link #of(ItemStackLike...)} instead. + */ + @Deprecated(forRemoval = true) + static Ingredient of(ItemStackSnapshot @Nullable ... items) { + return Ingredient.of((ItemStackLike[]) items); + } + + /** + * Creates a new {@link Ingredient} for the provided {@link ItemStackLike}s. * * @param items The item * @return The new ingredient */ - static Ingredient of(ItemStackSnapshot @Nullable ... items) { + static Ingredient of(ItemStackLike @Nullable ... items) { if (items == null) { return Ingredient.empty(); } @@ -127,7 +139,15 @@ static Ingredient of(DefaultedRegistryReference @Nullable .. } /** - * Creates a new {@link Ingredient} for the provided {@link Predicate} and exemplary {@link ItemStack}s. + * @deprecated Use {@link #of(ResourceKey, Predicate, ItemStackLike...)} instead. + */ + @Deprecated(forRemoval = true) + static Ingredient of(ResourceKey key, Predicate predicate, ItemStack... exemplaryStacks) { + return Ingredient.of(key, itemStack -> predicate.test(itemStack.asMutable()), (ItemStackLike[]) exemplaryStacks); + } + + /** + * Creates a new {@link Ingredient} for the provided {@link Predicate} and exemplary {@link ItemStackLike}s. *

Note: Predicate ingredients may not be fully supported for all recipe types

* * @param key A unique resource key @@ -136,7 +156,7 @@ static Ingredient of(DefaultedRegistryReference @Nullable .. * * @return The new ingredient */ - static Ingredient of(ResourceKey key, Predicate predicate, ItemStack... exemplaryStacks) { + static Ingredient of(ResourceKey key, Predicate predicate, ItemStackLike... exemplaryStacks) { if (exemplaryStacks.length == 0) { throw new IllegalArgumentException("At least exemplary stack is required"); } @@ -178,12 +198,28 @@ interface Builder extends org.spongepowered.api.util.Builder... types); /** - * Sets one ore more ItemStack for matching the ingredient. + * @deprecated Use {@link #with(ItemStackLike...)} instead + */ + @Deprecated(forRemoval = true) + default Builder with(ItemStack... types) { + return this.with((ItemStackLike[]) types); + } + + /** + * Sets one or more ItemStackLike for matching the ingredient. * * @param types The items * @return This Builder, for chaining */ - Builder with(ItemStack... types); + Builder with(ItemStackLike... types); + + /** + * @deprecated Use {@link #with(ResourceKey, Predicate, ItemStackLike...)} instead. + */ + @Deprecated(forRemoval = true) + default Builder with(ResourceKey resourceKey, Predicate predicate, ItemStack... exemplaryTypes) { + return this.with(resourceKey, itemStack -> predicate.test(itemStack.asMutable()), (ItemStackLike[]) exemplaryTypes); + } /** * Sets a Predicate for matching the ingredient. @@ -194,15 +230,15 @@ interface Builder extends org.spongepowered.api.util.Builder predicate, ItemStack... exemplaryTypes); + Builder with(ResourceKey resourceKey, Predicate predicate, ItemStackLike... exemplaryTypes); /** - * Sets one ItemStack for matching the ingredient. - * - * @param types The items - * @return This Builder, for chaining + * @deprecated Use {@link #with(ItemStackLike...)} instead */ - Builder with(ItemStackSnapshot... types); + @Deprecated(forRemoval = true) + default Builder with(ItemStackSnapshot... types) { + return this.with((ItemStackLike[]) types); + } /** * Sets the item tag for matching the ingredient. diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeInput.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeInput.java index 11981dd274..d31e8dcd1b 100644 --- a/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeInput.java +++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeInput.java @@ -26,6 +26,7 @@ import org.spongepowered.api.item.inventory.Inventory; import org.spongepowered.api.item.inventory.ItemStack; +import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.item.inventory.type.GridInventory; import org.spongepowered.api.item.recipe.cooking.CookingRecipe; import org.spongepowered.api.item.recipe.single.StoneCutterRecipe; @@ -65,6 +66,14 @@ interface Crafting extends RecipeInput { interface Factory { + /** + * @deprecated Use {@link #single(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default RecipeInput.Single single(ItemStack stack) { + return this.single((ItemStackLike) stack); + } + /** * Creates a recipe input for * {@link CookingRecipe} and @@ -74,7 +83,15 @@ interface Factory { * * @return the recipe input */ - RecipeInput.Single single(ItemStack stack); + RecipeInput.Single single(ItemStackLike stack); + + /** + * @deprecated Use {@link #smithing(ItemStackLike, ItemStackLike, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default RecipeInput.Smithing smithing(ItemStack templateStack, ItemStack baseStack, ItemStack additionStack) { + return this.smithing((ItemStackLike) templateStack, (ItemStackLike) baseStack, (ItemStackLike) additionStack); + } /** * Creates a recipe input for {@link SmithingRecipe} @@ -85,7 +102,7 @@ interface Factory { * * @return the recipe input */ - RecipeInput.Smithing smithing(ItemStack templateStack, ItemStack baseStack, ItemStack additionStack); + RecipeInput.Smithing smithing(ItemStackLike templateStack, ItemStackLike baseStack, ItemStackLike additionStack); /** * Creates a recipe input for {@link CraftingRecipe} diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeResult.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeResult.java index 3fff2cec29..d8128aa8db 100644 --- a/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeResult.java +++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/RecipeResult.java @@ -24,12 +24,14 @@ */ package org.spongepowered.api.item.recipe.crafting; +import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.item.inventory.ItemStackSnapshot; import org.spongepowered.api.item.inventory.crafting.CraftingGridInventory; import java.util.List; import java.util.Objects; import java.util.StringJoiner; +import java.util.stream.Collectors; /** * The result of fulfilling a {@link CraftingRecipe}. @@ -39,6 +41,14 @@ public final class RecipeResult { private final ItemStackSnapshot result; private final List remainingItems; + /** + * @deprecated Use {@link #RecipeResult(ItemStackLike, List)} instead. + */ + @Deprecated(forRemoval = true) + public RecipeResult(ItemStackSnapshot result, List remainingItems) { + this((ItemStackLike) result, (List) remainingItems); + } + /** * Creates a new {@link RecipeResult}. * @@ -49,7 +59,7 @@ public final class RecipeResult { * @param remainingItems The remaining items to leave in the * crafting window */ - public RecipeResult(ItemStackSnapshot result, List remainingItems) { + public RecipeResult(ItemStackLike result, List remainingItems) { Objects.requireNonNull(result, "result"); if (result.isEmpty()) { throw new IllegalArgumentException("The result must not be empty!"); @@ -60,8 +70,8 @@ public RecipeResult(ItemStackSnapshot result, List remainingI + " It should contain empty ItemStackSnapshot values for slots which should be cleared."); } - this.result = result; - this.remainingItems = List.copyOf(remainingItems); + this.result = result.asImmutable(); + this.remainingItems = remainingItems.stream().map(ItemStackLike::asImmutable).toList(); } /** diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapedCraftingRecipe.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapedCraftingRecipe.java index 570df7e2a8..388f2dbd46 100644 --- a/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapedCraftingRecipe.java +++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapedCraftingRecipe.java @@ -29,6 +29,7 @@ import org.spongepowered.api.Sponge; import org.spongepowered.api.datapack.DataPack; import org.spongepowered.api.item.inventory.ItemStack; +import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.item.inventory.ItemStackSnapshot; import org.spongepowered.api.item.recipe.RecipeRegistration; import org.spongepowered.api.util.ResourceKeyedBuilder; @@ -214,28 +215,44 @@ interface ResultStep extends Builder { * @param remainingItemsFunction the remaining items function * * @return This builder, for chaining + * @deprecated Will be replaced with ItemStackLike variant */ - ResultStep remainingItems(Function> remainingItemsFunction); + @Deprecated + ResultStep remainingItems(Function> remainingItemsFunction); /** - * Sets the resultant {@link ItemStackSnapshot} for when this shaped + * @deprecated Use {@link #result(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default EndStep result(ItemStackSnapshot result) { + return this.result((ItemStackLike) result); + } + + /** + * @deprecated Use {@link #result(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default EndStep result(ItemStack result) { + return this.result((ItemStackLike) result); + } + + /** + * Sets the resultant {@link ItemStackLike} for when this shaped * recipe is correctly crafted. * * @param result The resultant snapshot * * @return The builder */ - EndStep result(ItemStackSnapshot result); + EndStep result(ItemStackLike result); /** - * Sets the resultant {@link ItemStack} for when this shaped recipe - * is correctly crafted. - * - * @param result The resultant stack - * - * @return The builder + * @deprecated Use {@link #result(Function, ItemStackLike)} instead. */ - EndStep result(ItemStack result); + @Deprecated(forRemoval = true) + default EndStep result(Function resultFunction, ItemStack exemplaryResult) { + return this.result(resultFunction, (ItemStackLike) exemplaryResult); + } /** * Sets the result function and an exemplary result. @@ -246,7 +263,7 @@ interface ResultStep extends Builder { * * @return The builder */ - EndStep result(Function resultFunction, ItemStack exemplaryResult); + EndStep result(Function resultFunction, ItemStackLike exemplaryResult); } /** diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapelessCraftingRecipe.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapelessCraftingRecipe.java index b8c9dbe5a2..f32e54eab2 100644 --- a/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapelessCraftingRecipe.java +++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/ShapelessCraftingRecipe.java @@ -30,6 +30,7 @@ import org.spongepowered.api.datapack.DataPack; import org.spongepowered.api.item.ItemType; import org.spongepowered.api.item.inventory.ItemStack; +import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.item.inventory.ItemStackSnapshot; import org.spongepowered.api.item.recipe.RecipeRegistration; import org.spongepowered.api.util.ResourceKeyedBuilder; @@ -98,27 +99,41 @@ interface ResultStep extends Builder { * * @return This builder, for chaining */ - ResultStep remainingItems(Function> remainingItemsFunction); + ResultStep remainingItems(Function> remainingItemsFunction); /** - * Sets the result and returns this builder. The result is the - * {@link ItemStack} created when the recipe is fulfilled. - * - * @param result The result - * - * @return This builder, for chaining + * @deprecated Use {@link #result(ItemStackLike)} instead. */ - EndStep result(ItemStackSnapshot result); + @Deprecated(forRemoval = true) + default EndStep result(ItemStackSnapshot result) { + return this.result((ItemStackLike) result); + } + + /** + * @deprecated Use {@link #result(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default EndStep result(ItemStack result) { + return this.result((ItemStackLike) result); + } /** * Sets the result and returns this builder. The result is the - * {@link ItemStack} created when the recipe is fulfilled. + * {@link ItemStackLike} created when the recipe is fulfilled. * * @param result The result * * @return This builder, for chaining */ - EndStep result(ItemStack result); + EndStep result(ItemStackLike result); + + /** + * @deprecated Use {@link #result(Function, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default EndStep result(Function resultFunction, ItemStack exemplaryResult) { + return this.result(resultFunction, (ItemStackLike) exemplaryResult); + } /** * Sets the result function and an exemplary result. @@ -129,7 +144,7 @@ interface ResultStep extends Builder { * * @return This builder, for chaining */ - EndStep result(Function resultFunction, ItemStack exemplaryResult); + EndStep result(Function resultFunction, ItemStackLike exemplaryResult); } diff --git a/src/main/java/org/spongepowered/api/item/recipe/crafting/SpecialCraftingRecipe.java b/src/main/java/org/spongepowered/api/item/recipe/crafting/SpecialCraftingRecipe.java index b46e9ecc0d..8f5e35d5bc 100644 --- a/src/main/java/org/spongepowered/api/item/recipe/crafting/SpecialCraftingRecipe.java +++ b/src/main/java/org/spongepowered/api/item/recipe/crafting/SpecialCraftingRecipe.java @@ -27,6 +27,7 @@ import org.spongepowered.api.Sponge; import org.spongepowered.api.datapack.DataPack; import org.spongepowered.api.item.inventory.ItemStack; +import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.item.recipe.RecipeRegistration; import org.spongepowered.api.util.ResourceKeyedBuilder; import org.spongepowered.api.world.server.ServerWorld; @@ -74,7 +75,7 @@ interface ResultStep extends Builder { * * @return This builder, for chaining */ - ResultStep remainingItems(Function> remainingItemsFunction); + ResultStep remainingItems(Function> remainingItemsFunction); /** * Sets the result function. @@ -83,7 +84,15 @@ interface ResultStep extends Builder { * * @return This builder, for chaining */ - EndStep result(Function resultFunction); + EndStep result(Function resultFunction); + + /** + * @deprecated Use {@link #result(ItemStackLike)} instead; + */ + @Deprecated(forRemoval = true) + default EndStep result(ItemStack result) { + return this.result((ItemStackLike) result); + } /** * Sets the result @@ -92,7 +101,7 @@ interface ResultStep extends Builder { * * @return This builder, for chaining */ - EndStep result(ItemStack result); + EndStep result(ItemStackLike result); } interface EndStep extends Builder, org.spongepowered.api.util.Builder { diff --git a/src/main/java/org/spongepowered/api/item/recipe/single/StoneCutterRecipe.java b/src/main/java/org/spongepowered/api/item/recipe/single/StoneCutterRecipe.java index 407e74c2f3..4f4ec3fce7 100644 --- a/src/main/java/org/spongepowered/api/item/recipe/single/StoneCutterRecipe.java +++ b/src/main/java/org/spongepowered/api/item/recipe/single/StoneCutterRecipe.java @@ -30,6 +30,7 @@ import org.spongepowered.api.datapack.DataPack; import org.spongepowered.api.item.ItemType; import org.spongepowered.api.item.inventory.ItemStack; +import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.item.inventory.ItemStackSnapshot; import org.spongepowered.api.item.recipe.Recipe; import org.spongepowered.api.item.recipe.RecipeRegistration; @@ -90,35 +91,49 @@ default ResultStep ingredient(Supplier ingredient) { interface ResultStep extends StoneCutterRecipe.Builder { /** - * Changes the result and returns this builder. The result is the - * {@link ItemStack} created when the recipe is fulfilled. - * - * @param result The output of this recipe - * - * @return This builder, for chaining + * @deprecated Use {@link #result(ItemStackLike)} instead. */ - EndStep result(ItemStackSnapshot result); + @Deprecated(forRemoval = true) + default EndStep result(ItemStackSnapshot result) { + return this.result((ItemStackLike) result); + } + + /** + * @deprecated Use {@link #result(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default EndStep result(ItemStack result) { + return this.result((ItemStackLike) result); + } /** * Changes the result and returns this builder. The result is the - * {@link ItemStack} created when the recipe is fulfilled. + * {@link ItemStackLike} created when the recipe is fulfilled. * * @param result The output of this recipe * * @return This builder, for chaining */ - EndStep result(ItemStack result); + EndStep result(ItemStackLike result); + + /** + * @deprecated Use {@link #result(Function, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default EndStep result(Function resultFunction, ItemStack exemplaryResult) { + return this.result(resultFunction, (ItemStackLike) exemplaryResult); + } /** * Changes the result and returns this builder. The result is the - * {@link ItemStack} created when the recipe is fulfilled. + * {@link ItemStackLike} created when the recipe is fulfilled. * * @param resultFunction The result function * @param exemplaryResult The exemplary output of this recipe * * @return This builder, for chaining */ - EndStep result(Function resultFunction, ItemStack exemplaryResult); + EndStep result(Function resultFunction, ItemStackLike exemplaryResult); } diff --git a/src/main/java/org/spongepowered/api/item/recipe/smithing/SmithingRecipe.java b/src/main/java/org/spongepowered/api/item/recipe/smithing/SmithingRecipe.java index 9c57d1c057..9520273623 100644 --- a/src/main/java/org/spongepowered/api/item/recipe/smithing/SmithingRecipe.java +++ b/src/main/java/org/spongepowered/api/item/recipe/smithing/SmithingRecipe.java @@ -30,6 +30,7 @@ import org.spongepowered.api.datapack.DataPack; import org.spongepowered.api.item.ItemType; import org.spongepowered.api.item.inventory.ItemStack; +import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.item.inventory.ItemStackSnapshot; import org.spongepowered.api.item.recipe.Recipe; import org.spongepowered.api.item.recipe.RecipeRegistration; @@ -155,35 +156,49 @@ default ResultStep addition(Supplier ingredient) { interface ResultStep extends SmithingRecipe.Builder { /** - * Changes the result and returns this builder. The result is the - * {@link ItemStack} created when the recipe is fulfilled. - * - * @param result The output of this recipe - * - * @return This builder, for chaining + * @deprecated Use {@link #result(ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default EndStep result(ItemStackSnapshot result) { + return this.result((ItemStackLike) result); + } + + /** + * @deprecated Use {@link #result(ItemStackLike)} instead. */ - EndStep result(ItemStackSnapshot result); + @Deprecated(forRemoval = true) + default EndStep result(ItemStack result) { + return this.result((ItemStackLike) result); + } /** * Changes the result and returns this builder. The result is the - * {@link ItemStack} created when the recipe is fulfilled. + * {@link ItemStackLike} created when the recipe is fulfilled. * * @param result The output of this recipe * * @return This builder, for chaining */ - EndStep result(ItemStack result); + EndStep result(ItemStackLike result); + + /** + * @deprecated Use {@link #result(Function, ItemStackLike)} instead. + */ + @Deprecated(forRemoval = true) + default EndStep result(Function resultFunction, ItemStack exemplaryResult) { + return this.result(resultFunction, (ItemStackLike) exemplaryResult); + } /** * Changes the result and returns this builder. The result is the - * {@link ItemStack} created when the recipe is fulfilled. + * {@link ItemStackLike} created when the recipe is fulfilled. * * @param resultFunction The result function * @param exemplaryResult The exemplary output of this recipe * * @return This builder, for chaining */ - EndStep result(Function resultFunction, ItemStack exemplaryResult); + EndStep result(Function resultFunction, ItemStackLike exemplaryResult); }