/
IIngredientHelper.java
185 lines (162 loc) · 5.59 KB
/
IIngredientHelper.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
package mezz.jei.api.ingredients;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
import mezz.jei.api.ingredients.subtypes.UidContext;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IFocusFactory;
import mezz.jei.api.registration.IModIngredientRegistration;
/**
* An ingredient helper allows JEI to get information about ingredients for searching and other purposes.
* An ingredient is anything used in a recipe, like ItemStacks and FluidStacks.
*
* If you have a new type of ingredient to add to JEI, you will have to implement this in order to use
* {@link IModIngredientRegistration#register(IIngredientType, Collection, IIngredientHelper, IIngredientRenderer)}
*/
public interface IIngredientHelper<V> {
/**
* Change one focus into a different focus.
* This can be used to treat lookups of one focus as if it were something else.
*
* On example is looking up fluid blocks, which get translated here into looking up the fluid itself.
*/
default IFocus<?> translateFocus(IFocus<V> focus, IFocusFactory focusFactory) {
return focus;
}
/**
* Find a matching ingredient from a group of them.
* Used for finding a specific focused ingredient in a recipe.
* Return null if there is no match.
*
* @deprecated since JEI 7.3.0. Use {@link #getMatch(Iterable, Object, UidContext)}
*/
@Deprecated
@Nullable
V getMatch(Iterable<V> ingredients, V ingredientToMatch);
/**
* Find a matching ingredient from a group of them.
* Used for finding a specific focused ingredient in a recipe.
* Return null if there is no match.
* @since JEI 7.3.0
*/
@Nullable
default V getMatch(Iterable<V> ingredients, V ingredientToMatch, UidContext context) {
return getMatch(ingredients, ingredientToMatch);
}
/**
* Display name used for searching. Normally this is the first line of the tooltip.
*/
String getDisplayName(V ingredient);
/**
* Unique ID for use in comparing, blacklisting, and looking up ingredients.
*
* @deprecated since JEI 7.3.0. Use {@link #getUniqueId(Object, UidContext)}
*/
@Deprecated
String getUniqueId(V ingredient);
/**
* Unique ID for use in comparing, blacklisting, and looking up ingredients.
* @since JEI 7.3.0
*/
default String getUniqueId(V ingredient, UidContext context) {
return getUniqueId(ingredient);
}
/**
* Wildcard ID for use in comparing, blacklisting, and looking up ingredients.
* For an example, ItemStack's wildcardId does not include NBT.
* For ingredients like FluidStacks which do not have a wildcardId, just return the uniqueId here.
*/
default String getWildcardId(V ingredient) {
return getUniqueId(ingredient);
}
/**
* Return the modId of the mod that created this ingredient.
*/
String getModId(V ingredient);
/**
* Return the modId of the mod that should be displayed.
*/
default String getDisplayModId(V ingredient) {
return getModId(ingredient);
}
/**
* Get the main colors of this ingredient. Used for the color search.
* If this is too difficult to implement for your ingredient, just return an empty collection.
* @see mezz.jei.api.helpers.IColorHelper
*/
default Iterable<Integer> getColors(V ingredient) {
return Collections.emptyList();
}
/**
* Return the resource id of the given ingredient.
*/
String getResourceId(V ingredient);
/**
* Called when a player is in cheat mode and clicks an ingredient in the list.
*
* @param ingredient The ingredient to cheat in. Do not edit this ingredient.
* @return an ItemStack for JEI to give the player, or an empty stack if there is nothing that can be given.
*/
default ItemStack getCheatItemStack(V ingredient) {
return ItemStack.EMPTY;
}
/**
* Makes a copy of the given ingredient.
* Used by JEI to protect against mutation of ingredients.
*
* @param ingredient the ingredient to copy
* @return a copy of the ingredient
*/
V copyIngredient(V ingredient);
/**
* Makes a normalized copy of the given ingredient.
* Used by JEI for bookmarks.
*
* @param ingredient the ingredient to copy and normalize
* @return a normalized copy of the ingredient
*/
default V normalizeIngredient(V ingredient) {
return copyIngredient(ingredient);
}
/**
* Checks if the given ingredient is valid for lookups and recipes.
*
* @param ingredient the ingredient to check
* @return whether the ingredient is valid for lookups and recipes.
*/
default boolean isValidIngredient(V ingredient) {
return true;
}
/**
* This is called when connecting to a server, to hide ingredients that are missing on the server.
* This call must be fast, the client should already know the answer without making any network calls.
* If in doubt, just leave this with the default implementation and return true.
*
* @param ingredient the ingredient to check
* @return true if the ingredient is on the server as well as the client
*/
default boolean isIngredientOnServer(V ingredient) {
return true;
}
/**
* Get a list of tags that include this ingredient.
* Used for searching by tags.
*/
default Collection<ResourceLocation> getTags(V ingredient) {
return Collections.emptyList();
}
/**
* Get a list of creative tab names that include this ingredient.
* Used for searching by creative tab name.
*/
default Collection<String> getCreativeTabNames(V ingredient) {
return Collections.emptyList();
}
/**
* Get information for error messages involving this ingredient.
* Be extremely careful not to crash here, get as much useful info as possible.
*/
String getErrorInfo(@Nullable V ingredient);
}