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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
/*
* Roughly Enough Items by Danielshe.
* Licensed under the MIT License.
*/
package me.shedaniel.rei.api;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeManager;
import net.minecraft.util.Identifier;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
public interface RecipeHelper {
/**
* @return the api instance of {@link me.shedaniel.rei.client.RecipeHelperImpl}
*/
static RecipeHelper getInstance() {
return RoughlyEnoughItemsCore.getRecipeHelper();
}
AutoCraftingHandler registerAutoCraftingHandler(AutoCraftingHandler handler);
List<AutoCraftingHandler> getSortedAutoCraftingHandler();
/**
* Gets the total recipe count registered
*
* @return the recipe count
*/
int getRecipeCount();
/**
* @return a list of sorted recipes
*/
List<Recipe> getAllSortedRecipes();
/**
* Gets all craftable items from materials.
*
* @param inventoryItems the materials
* @return the list of craftable items
*/
List<ItemStack> findCraftableByItems(List<ItemStack> inventoryItems);
/**
* Registers a category
*
* @param category the category to register
*/
void registerCategory(RecipeCategory category);
/**
* Registers the working stations of a category
*
* @param category the category
* @param workingStations the working stations
*/
void registerWorkingStations(Identifier category, List<ItemStack>... workingStations);
/**
* Registers the working stations of a category
*
* @param category the category
* @param workingStations the working stations
*/
void registerWorkingStations(Identifier category, ItemStack... workingStations);
List<List<ItemStack>> getWorkingStations(Identifier category);
/**
* Registers a recipe display
*
* @param categoryIdentifier the category to display in
* @param display the recipe display
*/
void registerDisplay(Identifier categoryIdentifier, RecipeDisplay display);
/**
* Gets a map of recipes for an itemstack
*
* @param stack the stack to be crafted
* @return the map of recipes
*/
Map<RecipeCategory, List<RecipeDisplay>> getRecipesFor(ItemStack stack);
/**
* Gets the vanilla recipe manager
*
* @return the recipe manager
*/
RecipeManager getRecipeManager();
/**
* Gets all registered categories
*
* @return the list of categories
*/
List<RecipeCategory> getAllCategories();
/**
* Gets a map of usages for an itemstack
*
* @param stack the stack to be used
* @return the map of recipes
*/
Map<RecipeCategory, List<RecipeDisplay>> getUsagesFor(ItemStack stack);
/**
* Gets the optional of the speed crafting button area from a category
*
* @param category the category of the display
* @return the optional of speed crafting button area
*/
Optional<ButtonAreaSupplier> getSpeedCraftButtonArea(RecipeCategory category);
/**
* Registers a speed crafting button area
*
* @param category the category of the button area
* @param rectangle the button area
*/
void registerSpeedCraftButtonArea(Identifier category, ButtonAreaSupplier rectangle);
/**
* Removes the speed crafting button
*
* @param category the category of the button
*/
default void removeSpeedCraftButton(Identifier category) {
registerSpeedCraftButtonArea(category, bounds -> null);
}
/**
* @param category the category of the button area
* @deprecated Not required anymore
*/
@Deprecated
void registerDefaultSpeedCraftButtonArea(Identifier category);
/**
* Gets the map of all recipes visible to the player
*
* @return the map of recipes
*/
Map<RecipeCategory, List<RecipeDisplay>> getAllRecipes();
List<RecipeDisplay> getAllRecipesFromCategory(RecipeCategory category);
/**
* Registers a recipe visibility handler
*
* @param visibilityHandler the handler to be registered
*/
void registerRecipeVisibilityHandler(DisplayVisibilityHandler visibilityHandler);
/**
* Unregisters a recipe visibility handler
*
* @param visibilityHandler the handler to be unregistered
*/
void unregisterRecipeVisibilityHandler(DisplayVisibilityHandler visibilityHandler);
/**
* Gets an unmodifiable list of recipe visibility handlers
*
* @return the unmodifiable list of handlers
*/
List<DisplayVisibilityHandler> getDisplayVisibilityHandlers();
/**
* Checks if the display is visible by asking recipe visibility handlers
*
* @param display the display to be checked
* @param respectConfig whether it should respect the user's config
* @return whether the display should be visible
* @deprecated {@link RecipeHelper#isDisplayVisible(RecipeDisplay)} )}
*/
@Deprecated
boolean isDisplayVisible(RecipeDisplay display, boolean respectConfig);
/**
* Checks if the display is visible by asking recipe visibility handlers
*
* @param display the display to be checked
* @return whether the display should be visible
*/
boolean isDisplayVisible(RecipeDisplay display);
<T extends Recipe<?>> void registerRecipes(Identifier category, Predicate<Recipe> recipeFilter, Function<T, RecipeDisplay> mappingFunction);
/**
* Gets the cached category setting by the category identifier
*
* @param category the identifier of the category
* @return the optional of the category settings
*/
Optional<DisplaySettings> getCachedCategorySettings(Identifier category);
/**
* Registers a live recipe generator.
*
* @param liveRecipeGenerator the generator to register
* @apiNote Still work in progress
*/
void registerLiveRecipeGenerator(LiveRecipeGenerator<?> liveRecipeGenerator);
<T extends Recipe<?>> void registerRecipes(Identifier category, Class<T> recipeClass, Function<T, RecipeDisplay> mappingFunction);
<T extends Recipe<?>> void registerRecipes(Identifier category, Function<Recipe, Boolean> recipeFilter, Function<T, RecipeDisplay> mappingFunction);
}
|