/
IRecipeSlotView.java
92 lines (82 loc) · 2.75 KB
/
IRecipeSlotView.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package mezz.jei.api.gui.ingredient;
import com.mojang.blaze3d.vertex.PoseStack;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.builder.IRecipeSlotBuilder;
import mezz.jei.api.ingredients.IIngredientType;
import mezz.jei.api.ingredients.ITypedIngredient;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import java.util.Optional;
import java.util.stream.Stream;
/**
* Represents one drawn ingredient that is part of a recipe.
* One recipe slot can contain multiple ingredients, displayed one after the other over time.
*
* These ingredients may be different types, for example {@link VanillaTypes#ITEM_STACK} and {@link mezz.jei.api.forge.ForgeTypes#FLUID_STACK}
* can be displayed in one recipe slot in rotation.
*
* Useful for implementing {@link IRecipeTransferHandler} and some other advanced cases.
*
* @since 9.3.0
*/
public interface IRecipeSlotView {
/**
* All ingredient variations of the given type that can be shown.
*
* @see #getAllIngredients() to get ingredients of every type together.
*
* @since 9.3.0
*/
<T> Stream<T> getIngredients(IIngredientType<T> ingredientType);
/**
* All ingredient variations that can be shown.
*
* @see #getIngredients(IIngredientType) to limit to one type of ingredient.
*
* @since 9.3.0
*/
Stream<ITypedIngredient<?>> getAllIngredients();
/**
* @return true if there are no ingredients in this recipe slot.
*
* @since 9.3.0
*/
boolean isEmpty();
/**
* The ingredient variation that is shown at this moment.
* For ingredients that rotate through several values, this will change over time.
* If nothing of this type is currently shown, this will return {@link Optional#empty()}.
*
* @since 9.3.0
*/
<T> Optional<T> getDisplayedIngredient(IIngredientType<T> ingredientType);
/**
* The ingredient variation that is shown at this moment.
* For ingredients that rotate through several values, this will change over time.
* If nothing is currently shown, this will return {@link Optional#empty()}.
*
* @since 9.3.0
*/
Optional<ITypedIngredient<?>> getDisplayedIngredient();
/**
* The slot's name if one was set by {@link IRecipeSlotBuilder#setSlotName(String)}
*
* @since 9.3.0
*/
Optional<String> getSlotName();
/**
* Returns the type of focus that matches this ingredient.
*
* @since 9.3.0
*/
RecipeIngredientRole getRole();
/**
* Draws a highlight on background of this ingredient.
* This is used by recipe transfer errors to turn missing ingredient backgrounds to red, but can be used for other purposes.
*
* @see IRecipeTransferHandlerHelper#createUserErrorForMissingSlots(Component, Collection).
*
* @since 9.3.0
*/
void drawHighlight(PoseStack stack, int color);
}