From a47ece6c10ca844fc197eeb7f1d2f39dacbabc2c Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+blay09@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:22:46 +0100 Subject: [PATCH] docs: new api --- .../api/IngredientToken.java | 18 ++++++++++++++++++ .../api/KitchenItemProcessor.java | 5 +++++ .../api/KitchenItemProvider.java | 19 +++++++++++++++++++ .../api/KitchenOperation.java | 3 +++ 4 files changed, 45 insertions(+) diff --git a/shared/src/main/java/net/blay09/mods/cookingforblockheads/api/IngredientToken.java b/shared/src/main/java/net/blay09/mods/cookingforblockheads/api/IngredientToken.java index 9c8d2822..1dd40836 100644 --- a/shared/src/main/java/net/blay09/mods/cookingforblockheads/api/IngredientToken.java +++ b/shared/src/main/java/net/blay09/mods/cookingforblockheads/api/IngredientToken.java @@ -2,9 +2,27 @@ import net.minecraft.world.item.ItemStack; +/** + * Ingredient tokens are references towards ingredients to be used in a crafting operation. + *
+ * You should return a custom implementation of this interface with properties specific to your context, i.e. a slot index or similar. + */ public interface IngredientToken { + /** + * @return the item stack referenced by this token, but without removing it from its source + */ ItemStack peek(); + + /** + * @return the item stack referenced by this token, consuming it from its source. Remember to use a substack or return copy if you're going to shrink() the source. + */ ItemStack consume(); + + /** + * This is both used for failed operations (e.g. oven already full), as well as returning remaining items of operations. + * @param itemStack the item to be returned to the source inventory + * @return the rest that could not be returned to the source inventory, or ItemStack.EMPTY if all was returned + */ ItemStack restore(ItemStack itemStack); IngredientToken EMPTY = new IngredientToken() { diff --git a/shared/src/main/java/net/blay09/mods/cookingforblockheads/api/KitchenItemProcessor.java b/shared/src/main/java/net/blay09/mods/cookingforblockheads/api/KitchenItemProcessor.java index b7e975e2..fa92d8b1 100644 --- a/shared/src/main/java/net/blay09/mods/cookingforblockheads/api/KitchenItemProcessor.java +++ b/shared/src/main/java/net/blay09/mods/cookingforblockheads/api/KitchenItemProcessor.java @@ -5,6 +5,11 @@ import java.util.List; +/** + * Item processors are able to define custom logic for processing recipes. + *
+ * This is used by the oven for example, in order to allow smelting recipes to be moved to the oven when crafted. + */ public interface KitchenItemProcessor { boolean canProcess(RecipeType> recipeType); diff --git a/shared/src/main/java/net/blay09/mods/cookingforblockheads/api/KitchenItemProvider.java b/shared/src/main/java/net/blay09/mods/cookingforblockheads/api/KitchenItemProvider.java index f61639f7..02f395e6 100644 --- a/shared/src/main/java/net/blay09/mods/cookingforblockheads/api/KitchenItemProvider.java +++ b/shared/src/main/java/net/blay09/mods/cookingforblockheads/api/KitchenItemProvider.java @@ -5,8 +5,27 @@ import java.util.Collection; +/** + * Item Providers are responsible for locating and supplying ingredients to recipes. + *
+ * If your block is a simple storage container providing either a Container or ItemHandler,
+ * you can tag it cookingforblockheads:kitchen_item_providers
to have it automatically
+ * use the default implementation.
+ *
+ * This interface is specifically for cases where you want to provide custom logic for locating ingredients.
+ */
public interface KitchenItemProvider {
+ /**
+ * @param ingredient the ingredient to find
+ * @param ingredientTokens the ingredient tokens that have already been provided by this provider
+ * @return an ingredient token that matches the given ingredient, or null if none was found
+ */
IngredientToken findIngredient(Ingredient ingredient, Collection