Skip to content

Commit

Permalink
Fix #263 Show recipes that use a crafting category item first
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed May 1, 2016
1 parent 7996861 commit 713d9c5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
8 changes: 8 additions & 0 deletions changelog.html
@@ -1,3 +1,11 @@
<h2>3.3.2</h2>
<h4>Fixes:</h4>
<ul>
<li>Show recipes that use a crafting category item first. (for example: show recipes that use a crafting table first when looking up uses for crafting table, since it now shows every crafting recipe).</li>
</ul>
<br/>
<hr/>

<h2>3.3.1</h2>
<h4>Fixes:</h4>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -5,4 +5,4 @@ curse_project_id=238222

version_major=3
version_minor=3
version_patch=1
version_patch=2
18 changes: 16 additions & 2 deletions src/main/java/mezz/jei/RecipeRegistry.java
Expand Up @@ -5,6 +5,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableTable;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimap;
Expand All @@ -28,6 +29,7 @@

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -308,13 +310,25 @@ public List<Object> getRecipesWithInput(@Nullable IRecipeCategory recipeCategory
Log.error("Null ItemStack input", new NullPointerException());
return ImmutableList.of();
}

ImmutableList<Object> recipes = recipeInputMap.getRecipes(recipeCategory, input);

String recipeCategoryUid = recipeCategory.getUid();
for (String inputKey : Internal.getStackHelper().getUniqueIdentifiersWithWildcard(input)) {
if (categoriesForCraftItemKeys.get(inputKey).contains(recipeCategoryUid)) {
return recipesForCategories.get(recipeCategory);
ImmutableSet<Object> specificRecipes = ImmutableSet.copyOf(recipes);
List<Object> recipesForCategory = recipesForCategories.get(recipeCategory);
List<Object> allRecipes = new ArrayList<>(recipes);
for (Object recipe : recipesForCategory) {
if (!specificRecipes.contains(recipe)) {
allRecipes.add(recipe);
}
}
return allRecipes;
}
}
return recipeInputMap.getRecipes(recipeCategory, input);

return recipes;
}

@Nonnull
Expand Down

0 comments on commit 713d9c5

Please sign in to comment.