aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/client/RecipeHelper.java
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-01-13 22:32:06 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-01-13 22:32:06 +0800
commit55fb26865a7c77a098b2be067afcf29c335df48c (patch)
treee801d272eeea5b5a6eeda1162dbd9b43a67a228b /src/main/java/me/shedaniel/rei/client/RecipeHelper.java
parentf4473fd6c4142e071e498094490f44692dfbbdf3 (diff)
downloadRoughlyEnoughItems-2.0.0.37.tar.gz
RoughlyEnoughItems-2.0.0.37.tar.bz2
RoughlyEnoughItems-2.0.0.37.zip
Guess this worksv2.0.0.37
Diffstat (limited to 'src/main/java/me/shedaniel/rei/client/RecipeHelper.java')
-rw-r--r--src/main/java/me/shedaniel/rei/client/RecipeHelper.java31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/main/java/me/shedaniel/rei/client/RecipeHelper.java b/src/main/java/me/shedaniel/rei/client/RecipeHelper.java
index 70dad4c7c..d23d3d69d 100644
--- a/src/main/java/me/shedaniel/rei/client/RecipeHelper.java
+++ b/src/main/java/me/shedaniel/rei/client/RecipeHelper.java
@@ -4,9 +4,11 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.api.IRecipeCategory;
+import me.shedaniel.rei.api.IRecipeCategoryCraftable;
import me.shedaniel.rei.api.IRecipeDisplay;
import me.shedaniel.rei.api.IRecipePlugin;
import me.shedaniel.rei.listeners.RecipeSync;
+import net.minecraft.client.gui.Gui;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.RecipeManager;
import net.minecraft.util.Identifier;
@@ -19,10 +21,12 @@ public class RecipeHelper implements RecipeSync {
private static Map<Identifier, List<IRecipeDisplay>> recipeCategoryListMap;
private static List<IRecipeCategory> categories;
private static RecipeManager recipeManager;
+ private static Map<Class, IRecipeCategoryCraftable> craftables;
public RecipeHelper() {
this.recipeCategoryListMap = Maps.newHashMap();
this.categories = Lists.newArrayList();
+ this.craftables = Maps.newHashMap();
}
public static List<ItemStack> findCraftableByItems(List<ItemStack> inventoryItems) {
@@ -113,20 +117,39 @@ public class RecipeHelper implements RecipeSync {
return recipeCategoryListMap;
}
+ public static List<IRecipeCategory> getCategories() {
+ return categories;
+ }
+
+ public static void registerCategoryCraftable(Class<? extends IRecipeDisplay> guiClass, IRecipeCategoryCraftable categoryCraftable) {
+ craftables.put(guiClass, categoryCraftable);
+ }
+
+ public static void registerCategoryCraftable(Class<? extends IRecipeDisplay>[] guiClasses, IRecipeCategoryCraftable categoryCraftable) {
+ for(Class<? extends IRecipeDisplay> guiClass : guiClasses) craftables.put(guiClass, categoryCraftable);
+ }
+
+ public static IRecipeCategoryCraftable getCategoryCraftable(IRecipeDisplay gui) {
+ if (!craftables.containsKey(gui.getClass()))
+ return null;
+ return craftables.get(gui.getClass());
+ }
+
@Override
public void recipesLoaded(RecipeManager recipeManager) {
this.recipeManager = recipeManager;
this.recipeCategoryListMap.clear();
this.categories.clear();
+ this.craftables.clear();
RoughlyEnoughItemsCore.getListeners(IRecipePlugin.class).forEach(plugin -> {
plugin.registerPluginCategories();
plugin.registerRecipes();
+ plugin.registerAutoCraftingGui();
});
Collections.reverse(categories);
- RoughlyEnoughItemsCore.LOGGER.info("Registered REI Categories: " + String.join(", ", categories.stream().map(category -> {return category.getCategoryName();}).collect(Collectors.toList())));
+ RoughlyEnoughItemsCore.LOGGER.info("Registered REI Categories: " + String.join(", ", categories.stream().map(category -> {
+ return category.getCategoryName();
+ }).collect(Collectors.toList())));
}
- public static List<IRecipeCategory> getCategories() {
- return categories;
- }
}