fixed unknown recipe types. Fixes #1068

This commit is contained in:
gnembon committed 2021-08-19 09:43:00 -03:00
1 parent 03353a7675
commit 6222c97375
3 files changed
+5 -3

No files matched your search

@@ -13,5 +13,5 @@ public interface RecipeManagerInterface
* Gets all the recipes for a given item. Also used for {@link carpet.helpers.HopperCounter#guessColor} to guess the
* colour of an item to display it prettily
*/
List<Recipe<?>> getAllMatching(RecipeType type, Identifier output);
List<Recipe<?>> getAllMatching(RecipeType<?> type, Identifier output);
}
@@ -22,9 +22,11 @@ public class RecipeManager_scarpetMixin implements RecipeManagerInterface
@Shadow private Map<RecipeType<?>, Map<Identifier, Recipe<?>>> recipes;
@Override
public List<Recipe<?>> getAllMatching(RecipeType type, Identifier output)
public List<Recipe<?>> getAllMatching(RecipeType<?> type, Identifier output)
{
Map<Identifier, Recipe<?>> typeRecipes = recipes.get(type);
// happens when mods add recipe to the registry without updating recipe manager
if (typeRecipes == null) return Collections.emptyList();
if (typeRecipes.containsKey(output)) return Collections.singletonList(typeRecipes.get(output));
return Lists.newArrayList(typeRecipes.values().stream().filter(
r -> Registry.ITEM.getId(r.getOutput().getItem()).equals(output)).collect(Collectors.toList()));
@@ -93,7 +93,7 @@ public class Inventories {
CarpetContext cc = (CarpetContext)c;
if (lv.size() < 1) throw new InternalExpressionException("'recipe_data' requires at least one argument");
String recipeName = lv.get(0).getString();
RecipeType type = RecipeType.CRAFTING;
RecipeType<?> type = RecipeType.CRAFTING;
if (lv.size() > 1)
{
String recipeType = lv.get(1).getString();