RecipeHelperImpl.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. /*
  2. * Roughly Enough Items by Danielshe.
  3. * Licensed under the MIT License.
  4. */
  5. package me.shedaniel.rei.impl;
  6. import com.google.common.collect.Lists;
  7. import com.google.common.collect.Maps;
  8. import com.google.common.collect.Sets;
  9. import me.shedaniel.math.api.Rectangle;
  10. import me.shedaniel.rei.RoughlyEnoughItemsCore;
  11. import me.shedaniel.rei.api.*;
  12. import me.shedaniel.rei.api.annotations.Internal;
  13. import me.shedaniel.rei.api.plugins.REIPluginV0;
  14. import me.shedaniel.rei.utils.CollectionUtils;
  15. import net.fabricmc.loader.api.FabricLoader;
  16. import net.fabricmc.loader.api.SemanticVersion;
  17. import net.fabricmc.loader.api.Version;
  18. import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen;
  19. import net.minecraft.recipe.Recipe;
  20. import net.minecraft.recipe.RecipeManager;
  21. import net.minecraft.util.ActionResult;
  22. import net.minecraft.util.Identifier;
  23. import java.util.*;
  24. import java.util.concurrent.atomic.AtomicInteger;
  25. import java.util.function.Function;
  26. import java.util.function.Predicate;
  27. import java.util.stream.Collectors;
  28. @Deprecated
  29. @Internal
  30. public class RecipeHelperImpl implements RecipeHelper {
  31. private static final Comparator<DisplayVisibilityHandler> VISIBILITY_HANDLER_COMPARATOR;
  32. @SuppressWarnings("rawtypes")
  33. private static final Comparator<Recipe> RECIPE_COMPARATOR = (o1, o2) -> {
  34. int int_1 = o1.getId().getNamespace().compareTo(o2.getId().getNamespace());
  35. if (int_1 == 0)
  36. int_1 = o1.getId().getPath().compareTo(o2.getId().getPath());
  37. return int_1;
  38. };
  39. static {
  40. Comparator<DisplayVisibilityHandler> comparator = Comparator.comparingDouble(DisplayVisibilityHandler::getPriority);
  41. VISIBILITY_HANDLER_COMPARATOR = comparator.reversed();
  42. }
  43. private final List<AutoTransferHandler> autoTransferHandlers = Lists.newArrayList();
  44. private final List<RecipeFunction> recipeFunctions = Lists.newArrayList();
  45. private final List<ScreenClickArea> screenClickAreas = Lists.newArrayList();
  46. private final AtomicInteger recipeCount = new AtomicInteger();
  47. private final Map<Identifier, List<RecipeDisplay>> recipeCategoryListMap = Maps.newHashMap();
  48. private final List<RecipeCategory<?>> categories = Lists.newArrayList();
  49. private final Map<Identifier, ButtonAreaSupplier> autoCraftAreaSupplierMap = Maps.newHashMap();
  50. private final Map<Identifier, List<List<EntryStack>>> categoryWorkingStations = Maps.newHashMap();
  51. private final List<DisplayVisibilityHandler> displayVisibilityHandlers = Lists.newArrayList();
  52. private final List<LiveRecipeGenerator<RecipeDisplay>> liveRecipeGenerators = Lists.newArrayList();
  53. private RecipeManager recipeManager;
  54. private boolean arePluginsLoading = false;
  55. @Override
  56. public List<EntryStack> findCraftableEntriesByItems(List<EntryStack> inventoryItems) {
  57. List<EntryStack> craftables = new ArrayList<>();
  58. for (List<RecipeDisplay> value : recipeCategoryListMap.values())
  59. for (RecipeDisplay recipeDisplay : value) {
  60. int slotsCraftable = 0;
  61. List<List<EntryStack>> requiredInput = (List<List<EntryStack>>) recipeDisplay.getRequiredEntries();
  62. for (List<EntryStack> slot : requiredInput) {
  63. if (slot.isEmpty()) {
  64. slotsCraftable++;
  65. continue;
  66. }
  67. back:
  68. for (EntryStack possibleType : inventoryItems) {
  69. for (EntryStack slotPossible : slot)
  70. if (possibleType.equals(slotPossible)) {
  71. slotsCraftable++;
  72. break back;
  73. }
  74. }
  75. }
  76. if (slotsCraftable == recipeDisplay.getRequiredEntries().size())
  77. craftables.addAll((List<EntryStack>) recipeDisplay.getOutputEntries());
  78. }
  79. return craftables.stream().distinct().collect(Collectors.toList());
  80. }
  81. @Override
  82. public boolean arePluginsLoading() {
  83. return arePluginsLoading;
  84. }
  85. @Override
  86. public void registerCategory(RecipeCategory<?> category) {
  87. categories.add(category);
  88. recipeCategoryListMap.put(category.getIdentifier(), Lists.newLinkedList());
  89. categoryWorkingStations.put(category.getIdentifier(), Lists.newLinkedList());
  90. }
  91. @Override
  92. public void registerWorkingStations(Identifier category, List<EntryStack>... workingStations) {
  93. categoryWorkingStations.get(category).addAll(Arrays.asList(workingStations));
  94. }
  95. @Override
  96. public void registerWorkingStations(Identifier category, EntryStack... workingStations) {
  97. categoryWorkingStations.get(category).addAll(Arrays.asList(workingStations).stream().map(Collections::singletonList).collect(Collectors.toList()));
  98. }
  99. @Override
  100. public List<List<EntryStack>> getWorkingStations(Identifier category) {
  101. return categoryWorkingStations.get(category);
  102. }
  103. @Override
  104. public void registerDisplay(Identifier categoryIdentifier, RecipeDisplay display) {
  105. if (!recipeCategoryListMap.containsKey(categoryIdentifier))
  106. return;
  107. recipeCount.incrementAndGet();
  108. recipeCategoryListMap.get(categoryIdentifier).add(display);
  109. }
  110. private void registerDisplay(Identifier categoryIdentifier, RecipeDisplay display, int index) {
  111. if (!recipeCategoryListMap.containsKey(categoryIdentifier))
  112. return;
  113. recipeCount.incrementAndGet();
  114. recipeCategoryListMap.get(categoryIdentifier).add(index, display);
  115. }
  116. @Override
  117. public Map<RecipeCategory<?>, List<RecipeDisplay>> getRecipesFor(EntryStack stack) {
  118. Map<Identifier, List<RecipeDisplay>> categoriesMap = new HashMap<>();
  119. categories.forEach(f -> categoriesMap.put(f.getIdentifier(), Lists.newArrayList()));
  120. for (Map.Entry<Identifier, List<RecipeDisplay>> entry : recipeCategoryListMap.entrySet()) {
  121. RecipeCategory<?> category = getCategory(entry.getKey());
  122. for (RecipeDisplay recipeDisplay : entry.getValue())
  123. for (EntryStack outputStack : recipeDisplay.getOutputEntries())
  124. if (stack.equals(outputStack))
  125. categoriesMap.get(recipeDisplay.getRecipeCategory()).add(recipeDisplay);
  126. }
  127. for (LiveRecipeGenerator<RecipeDisplay> liveRecipeGenerator : liveRecipeGenerators) {
  128. liveRecipeGenerator.getRecipeFor(stack).ifPresent(o -> categoriesMap.get(liveRecipeGenerator.getCategoryIdentifier()).addAll(o));
  129. }
  130. Map<RecipeCategory<?>, List<RecipeDisplay>> recipeCategoryListMap = Maps.newLinkedHashMap();
  131. categories.forEach(category -> {
  132. if (categoriesMap.containsKey(category.getIdentifier()) && !categoriesMap.get(category.getIdentifier()).isEmpty())
  133. recipeCategoryListMap.put(category, categoriesMap.get(category.getIdentifier()).stream().filter(display -> isDisplayVisible(display)).collect(Collectors.toList()));
  134. });
  135. for (RecipeCategory<?> category : Lists.newArrayList(recipeCategoryListMap.keySet()))
  136. if (recipeCategoryListMap.get(category).isEmpty())
  137. recipeCategoryListMap.remove(category);
  138. return recipeCategoryListMap;
  139. }
  140. @Override
  141. public RecipeCategory<?> getCategory(Identifier identifier) {
  142. return CollectionUtils.findFirstOrNull(categories, category -> category.getIdentifier().equals(identifier));
  143. }
  144. @Override
  145. public RecipeManager getRecipeManager() {
  146. return recipeManager;
  147. }
  148. private boolean isStackWorkStationOfCategory(Identifier category, EntryStack stack) {
  149. for (List<EntryStack> stacks : getWorkingStations(category)) {
  150. for (EntryStack entryStack : stacks) {
  151. if (entryStack.equalsIgnoreTagsAndAmount(stack))
  152. return true;
  153. }
  154. }
  155. return false;
  156. }
  157. @Override
  158. public Map<RecipeCategory<?>, List<RecipeDisplay>> getUsagesFor(EntryStack stack) {
  159. Map<Identifier, Set<RecipeDisplay>> categoriesMap = new HashMap<>();
  160. categories.forEach(f -> categoriesMap.put(f.getIdentifier(), Sets.newLinkedHashSet()));
  161. for (Map.Entry<Identifier, List<RecipeDisplay>> entry : recipeCategoryListMap.entrySet()) {
  162. boolean isWorkstationCategory = isStackWorkStationOfCategory(entry.getKey(), stack);
  163. if (isWorkstationCategory) {
  164. for (RecipeDisplay recipeDisplay : entry.getValue()) {
  165. back:
  166. for (List<EntryStack> input : recipeDisplay.getInputEntries()) {
  167. for (EntryStack otherEntry : input) {
  168. if (otherEntry.equals(stack)) {
  169. categoriesMap.get(recipeDisplay.getRecipeCategory()).add(recipeDisplay);
  170. break back;
  171. }
  172. }
  173. }
  174. }
  175. for (RecipeDisplay recipeDisplay : entry.getValue()) {
  176. categoriesMap.get(recipeDisplay.getRecipeCategory()).add(recipeDisplay);
  177. }
  178. } else {
  179. for (RecipeDisplay recipeDisplay : entry.getValue()) {
  180. back:
  181. for (List<EntryStack> input : recipeDisplay.getInputEntries()) {
  182. for (EntryStack otherEntry : input) {
  183. if (otherEntry.equals(stack)) {
  184. categoriesMap.get(recipeDisplay.getRecipeCategory()).add(recipeDisplay);
  185. break back;
  186. }
  187. }
  188. }
  189. }
  190. }
  191. }
  192. for (LiveRecipeGenerator<RecipeDisplay> liveRecipeGenerator : liveRecipeGenerators) {
  193. liveRecipeGenerator.getUsageFor(stack).ifPresent(o -> categoriesMap.get(liveRecipeGenerator.getCategoryIdentifier()).addAll(o));
  194. }
  195. Map<RecipeCategory<?>, List<RecipeDisplay>> recipeCategoryListMap = Maps.newLinkedHashMap();
  196. for (RecipeCategory<?> category : categories) {
  197. if (categoriesMap.containsKey(category.getIdentifier()) && !categoriesMap.get(category.getIdentifier()).isEmpty())
  198. recipeCategoryListMap.put(category, categoriesMap.get(category.getIdentifier()).stream().filter(display -> isDisplayVisible(display)).collect(Collectors.toList()));
  199. }
  200. for (RecipeCategory<?> category : Lists.newArrayList(recipeCategoryListMap.keySet()))
  201. if (recipeCategoryListMap.get(category).isEmpty())
  202. recipeCategoryListMap.remove(category);
  203. return recipeCategoryListMap;
  204. }
  205. @Override
  206. public List<RecipeCategory<?>> getAllCategories() {
  207. return Collections.unmodifiableList(categories);
  208. }
  209. @Override
  210. public Optional<ButtonAreaSupplier> getAutoCraftButtonArea(RecipeCategory<?> category) {
  211. if (!autoCraftAreaSupplierMap.containsKey(category.getIdentifier()))
  212. return Optional.ofNullable(bounds -> new Rectangle(bounds.getMaxX() - 16, bounds.getMaxY() - 16, 10, 10));
  213. return Optional.ofNullable(autoCraftAreaSupplierMap.get(category.getIdentifier()));
  214. }
  215. @Override
  216. public void registerAutoCraftButtonArea(Identifier category, ButtonAreaSupplier rectangle) {
  217. if (rectangle == null) {
  218. if (autoCraftAreaSupplierMap.containsKey(category))
  219. autoCraftAreaSupplierMap.remove(category);
  220. } else
  221. autoCraftAreaSupplierMap.put(category, rectangle);
  222. }
  223. @SuppressWarnings("deprecation")
  224. public void recipesLoaded(RecipeManager recipeManager) {
  225. long startTime = System.currentTimeMillis();
  226. arePluginsLoading = true;
  227. ScreenHelper.clearData();
  228. this.recipeCount.set(0);
  229. this.recipeManager = recipeManager;
  230. this.recipeCategoryListMap.clear();
  231. this.categories.clear();
  232. this.autoCraftAreaSupplierMap.clear();
  233. this.screenClickAreas.clear();
  234. this.categoryWorkingStations.clear();
  235. this.recipeFunctions.clear();
  236. this.displayVisibilityHandlers.clear();
  237. this.liveRecipeGenerators.clear();
  238. this.autoTransferHandlers.clear();
  239. ((DisplayHelperImpl) DisplayHelper.getInstance()).resetData();
  240. ((DisplayHelperImpl) DisplayHelper.getInstance()).resetCache();
  241. BaseBoundsHandler baseBoundsHandler = new BaseBoundsHandlerImpl();
  242. DisplayHelper.getInstance().registerBoundsHandler(baseBoundsHandler);
  243. ((DisplayHelperImpl) DisplayHelper.getInstance()).setBaseBoundsHandler(baseBoundsHandler);
  244. List<REIPluginEntry> plugins = Lists.newLinkedList(RoughlyEnoughItemsCore.getPlugins());
  245. plugins.sort(Comparator.comparingInt(REIPluginEntry::getPriority).reversed());
  246. RoughlyEnoughItemsCore.LOGGER.info("[REI] Loading %d plugins: %s", plugins.size(), plugins.stream().map(REIPluginEntry::getPluginIdentifier).map(Identifier::toString).collect(Collectors.joining(", ")));
  247. Collections.reverse(plugins);
  248. EntryRegistry.getInstance().getStacksList().clear();
  249. Version reiVersion = FabricLoader.getInstance().getModContainer("roughlyenoughitems").get().getMetadata().getVersion();
  250. if (!(reiVersion instanceof SemanticVersion))
  251. RoughlyEnoughItemsCore.LOGGER.warn("[REI] Roughly Enough Items is not using semantic versioning, will be ignoring plugins' minimum versions!");
  252. List<REIPluginV0> reiPluginV0s = new ArrayList<>();
  253. for (REIPluginEntry plugin : plugins) {
  254. try {
  255. if (reiVersion instanceof SemanticVersion)
  256. if (plugin.getMinimumVersion().compareTo((SemanticVersion) reiVersion) > 0) {
  257. throw new IllegalStateException("Requires " + plugin.getMinimumVersion().getFriendlyString() + " version of REI!");
  258. }
  259. if (plugin instanceof REIPluginV0) {
  260. ((REIPluginV0) plugin).preRegister();
  261. reiPluginV0s.add((REIPluginV0) plugin);
  262. }
  263. } catch (Throwable e) {
  264. RoughlyEnoughItemsCore.LOGGER.error("[REI] " + plugin.getPluginIdentifier().toString() + " plugin failed to pre register!", e);
  265. }
  266. }
  267. for (REIPluginV0 plugin : reiPluginV0s) {
  268. Identifier identifier = plugin.getPluginIdentifier();
  269. try {
  270. plugin.registerBounds(DisplayHelper.getInstance());
  271. plugin.registerEntries(EntryRegistry.getInstance());
  272. plugin.registerPluginCategories(this);
  273. plugin.registerRecipeDisplays(this);
  274. plugin.registerOthers(this);
  275. } catch (Throwable e) {
  276. RoughlyEnoughItemsCore.LOGGER.error("[REI] " + identifier.toString() + " plugin failed to load!", e);
  277. }
  278. }
  279. for (REIPluginV0 plugin : reiPluginV0s) {
  280. Identifier identifier = plugin.getPluginIdentifier();
  281. try {
  282. plugin.postRegister();
  283. } catch (Throwable e) {
  284. RoughlyEnoughItemsCore.LOGGER.error("[REI] " + identifier.toString() + " plugin failed to post register!", e);
  285. }
  286. }
  287. if (!recipeFunctions.isEmpty()) {
  288. @SuppressWarnings("rawtypes") List<Recipe> allSortedRecipes = getAllSortedRecipes();
  289. Collections.reverse(allSortedRecipes);
  290. for (RecipeFunction recipeFunction : recipeFunctions) {
  291. try {
  292. for (Recipe<?> recipe : CollectionUtils.filter(allSortedRecipes, recipe -> recipeFunction.recipeFilter.test(recipe))) {
  293. registerDisplay(recipeFunction.category, (RecipeDisplay) recipeFunction.mappingFunction.apply(recipe), 0);
  294. }
  295. } catch (Exception e) {
  296. RoughlyEnoughItemsCore.LOGGER.error("[REI] Failed to add recipes!", e);
  297. }
  298. }
  299. }
  300. if (getDisplayVisibilityHandlers().isEmpty())
  301. registerRecipeVisibilityHandler(new DisplayVisibilityHandler() {
  302. @Override
  303. public ActionResult handleDisplay(RecipeCategory<?> category, RecipeDisplay display) {
  304. return ActionResult.SUCCESS;
  305. }
  306. @Override
  307. public float getPriority() {
  308. return -1f;
  309. }
  310. });
  311. // Clear Cache
  312. ((DisplayHelperImpl) DisplayHelper.getInstance()).resetCache();
  313. ScreenHelper.getOptionalOverlay().ifPresent(overlay -> overlay.shouldReInit = true);
  314. long usedTime = System.currentTimeMillis() - startTime;
  315. RoughlyEnoughItemsCore.LOGGER.info("[REI] Registered %d stack entries, %d recipes displays, %d exclusion zones suppliers, %d bounds handler, %d visibility handlers and %d categories (%s) in %d ms.", EntryRegistry.getInstance().getStacksList().size(), recipeCount.get(), DisplayHelper.getInstance().getBaseBoundsHandler().supplierSize(), DisplayHelper.getInstance().getAllBoundsHandlers().size(), getDisplayVisibilityHandlers().size(), categories.size(), String.join(", ", categories.stream().map(RecipeCategory::getCategoryName).collect(Collectors.toList())), usedTime);
  316. arePluginsLoading = false;
  317. }
  318. @Override
  319. public AutoTransferHandler registerAutoCraftingHandler(AutoTransferHandler handler) {
  320. autoTransferHandlers.add(handler);
  321. return handler;
  322. }
  323. @Override
  324. public List<AutoTransferHandler> getSortedAutoCraftingHandler() {
  325. return autoTransferHandlers.stream().sorted(Comparator.comparingDouble(AutoTransferHandler::getPriority).reversed()).collect(Collectors.toList());
  326. }
  327. @Override
  328. public int getRecipeCount() {
  329. return recipeCount.get();
  330. }
  331. @Override
  332. @SuppressWarnings("rawtypes")
  333. public List<Recipe> getAllSortedRecipes() {
  334. return getRecipeManager().values().stream().sorted(RECIPE_COMPARATOR).collect(Collectors.toList());
  335. }
  336. @Override
  337. public Map<RecipeCategory<?>, List<RecipeDisplay>> getAllRecipes() {
  338. Map<RecipeCategory<?>, List<RecipeDisplay>> map = Maps.newLinkedHashMap();
  339. for (RecipeCategory<?> recipeCategory : categories) {
  340. if (recipeCategoryListMap.containsKey(recipeCategory.getIdentifier())) {
  341. List<RecipeDisplay> list = CollectionUtils.filter(recipeCategoryListMap.get(recipeCategory.getIdentifier()), this::isDisplayVisible);
  342. if (!list.isEmpty())
  343. map.put(recipeCategory, list);
  344. }
  345. }
  346. return map;
  347. }
  348. @Override
  349. public List<RecipeDisplay> getAllRecipesFromCategory(RecipeCategory<?> category) {
  350. return recipeCategoryListMap.get(category.getIdentifier());
  351. }
  352. @Override
  353. public void registerRecipeVisibilityHandler(DisplayVisibilityHandler visibilityHandler) {
  354. displayVisibilityHandlers.add(visibilityHandler);
  355. }
  356. @Override
  357. public void unregisterRecipeVisibilityHandler(DisplayVisibilityHandler visibilityHandler) {
  358. displayVisibilityHandlers.remove(visibilityHandler);
  359. }
  360. @Override
  361. public List<DisplayVisibilityHandler> getDisplayVisibilityHandlers() {
  362. return Collections.unmodifiableList(displayVisibilityHandlers);
  363. }
  364. @SuppressWarnings("deprecation")
  365. @Override
  366. public boolean isDisplayVisible(RecipeDisplay display, boolean respectConfig) {
  367. return isDisplayVisible(display);
  368. }
  369. @SuppressWarnings("deprecation")
  370. @Override
  371. public boolean isDisplayVisible(RecipeDisplay display) {
  372. RecipeCategory<?> category = getCategory(display.getRecipeCategory());
  373. List<DisplayVisibilityHandler> list = getDisplayVisibilityHandlers().stream().sorted(VISIBILITY_HANDLER_COMPARATOR).collect(Collectors.toList());
  374. for (DisplayVisibilityHandler displayVisibilityHandler : list) {
  375. try {
  376. ActionResult visibility = displayVisibilityHandler.handleDisplay(category, display);
  377. if (visibility != ActionResult.PASS)
  378. return visibility == ActionResult.SUCCESS;
  379. } catch (Throwable throwable) {
  380. RoughlyEnoughItemsCore.LOGGER.error("[REI] Failed to check if the recipe is visible!", throwable);
  381. }
  382. }
  383. return true;
  384. }
  385. @Override
  386. public void registerScreenClickArea(Rectangle rectangle, Class<? extends AbstractContainerScreen<?>> screenClass, Identifier... categories) {
  387. this.screenClickAreas.add(new ScreenClickAreaImpl(screenClass, rectangle, categories));
  388. }
  389. @Override
  390. public <T extends Recipe<?>> void registerRecipes(Identifier category, Class<T> recipeClass, Function<T, RecipeDisplay> mappingFunction) {
  391. recipeFunctions.add(new RecipeFunction(category, recipe -> recipeClass.isAssignableFrom(recipe.getClass()), mappingFunction));
  392. }
  393. @Override
  394. public <T extends Recipe<?>> void registerRecipes(Identifier category, @SuppressWarnings("rawtypes")
  395. Function<Recipe, Boolean> recipeFilter, Function<T, RecipeDisplay> mappingFunction) {
  396. recipeFunctions.add(new RecipeFunction(category, recipeFilter::apply, mappingFunction));
  397. }
  398. @Override
  399. public <T extends Recipe<?>> void registerRecipes(Identifier category,
  400. @SuppressWarnings("rawtypes") Predicate<Recipe> recipeFilter, Function<T, RecipeDisplay> mappingFunction) {
  401. recipeFunctions.add(new RecipeFunction(category, recipeFilter, mappingFunction));
  402. }
  403. @Override
  404. public void registerLiveRecipeGenerator(LiveRecipeGenerator<?> liveRecipeGenerator) {
  405. liveRecipeGenerators.add((LiveRecipeGenerator<RecipeDisplay>) liveRecipeGenerator);
  406. }
  407. @Override
  408. public List<ScreenClickArea> getScreenClickAreas() {
  409. return screenClickAreas;
  410. }
  411. private class ScreenClickAreaImpl implements ScreenClickArea {
  412. Class<? extends AbstractContainerScreen<?>> screenClass;
  413. Rectangle rectangle;
  414. Identifier[] categories;
  415. private ScreenClickAreaImpl(Class<? extends AbstractContainerScreen<?>> screenClass, Rectangle rectangle, Identifier[] categories) {
  416. this.screenClass = screenClass;
  417. this.rectangle = rectangle;
  418. this.categories = categories;
  419. }
  420. public Class<? extends AbstractContainerScreen<?>> getScreenClass() {
  421. return screenClass;
  422. }
  423. public Rectangle getRectangle() {
  424. return rectangle;
  425. }
  426. public Identifier[] getCategories() {
  427. return categories;
  428. }
  429. }
  430. @SuppressWarnings("rawtypes")
  431. private class RecipeFunction {
  432. Identifier category;
  433. Predicate<Recipe> recipeFilter;
  434. Function mappingFunction;
  435. public RecipeFunction(Identifier category, Predicate<Recipe> recipeFilter, Function<?, RecipeDisplay> mappingFunction) {
  436. this.category = category;
  437. this.recipeFilter = recipeFilter;
  438. this.mappingFunction = mappingFunction;
  439. }
  440. }
  441. }