From 6222c97375e67c01300b1c4600b389b84309ace7 Mon Sep 17 00:00:00 2001 From: gnembon Date: Thu, 19 Aug 2021 09:39:14 -0300 Subject: [PATCH] fixed unknown recipe types. Fixes #1068 --- src/main/java/carpet/fakes/RecipeManagerInterface.java | 2 +- src/main/java/carpet/mixins/RecipeManager_scarpetMixin.java | 4 +++- src/main/java/carpet/script/api/Inventories.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/carpet/fakes/RecipeManagerInterface.java b/src/main/java/carpet/fakes/RecipeManagerInterface.java index d61db8a1..1078b24b 100644 --- a/src/main/java/carpet/fakes/RecipeManagerInterface.java +++ b/src/main/java/carpet/fakes/RecipeManagerInterface.java @@ -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> getAllMatching(RecipeType type, Identifier output); + List> getAllMatching(RecipeType type, Identifier output); } diff --git a/src/main/java/carpet/mixins/RecipeManager_scarpetMixin.java b/src/main/java/carpet/mixins/RecipeManager_scarpetMixin.java index c31d4648..167ca616 100644 --- a/src/main/java/carpet/mixins/RecipeManager_scarpetMixin.java +++ b/src/main/java/carpet/mixins/RecipeManager_scarpetMixin.java @@ -22,9 +22,11 @@ public class RecipeManager_scarpetMixin implements RecipeManagerInterface @Shadow private Map, Map>> recipes; @Override - public List> getAllMatching(RecipeType type, Identifier output) + public List> getAllMatching(RecipeType type, Identifier output) { Map> 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())); diff --git a/src/main/java/carpet/script/api/Inventories.java b/src/main/java/carpet/script/api/Inventories.java index 41a7ed73..e7ccb2a8 100644 --- a/src/main/java/carpet/script/api/Inventories.java +++ b/src/main/java/carpet/script/api/Inventories.java @@ -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();