@@ -129,7 +129,7 @@ public boolean matches(final CraftingInput $$0, final Level $$1) {
129129 if (this .onlyVanillaIngredients ) {
130130 return super .matches ($$0 , $$1 );
131131 }
132- return SpongeShapelessRecipe .matches ($$0 . items () , this .getIngredients ());
132+ return SpongeShapelessRecipe .matches ($$0 , this .getIngredients ());
133133 }
134134
135135 @ Override
@@ -158,19 +158,22 @@ public ItemStack getResultItem(final HolderLookup.Provider $$1) {
158158 }
159159
160160 private static boolean
161- matches (List < ItemStack > stacks , List <Ingredient > ingredients ) {
161+ matches (CraftingInput input , List <Ingredient > ingredients ) {
162162 final int elements = ingredients .size ();
163- if (stacks .size () < elements ) {
163+ if (input .ingredientCount () != elements ) {
164+ // The amount of non-empty stacks doesn't match the amount of ingredients
164165 return false ;
165166 }
166167
168+ final List <ItemStack > stacks = input .items ();
167169 // find matched stack -> ingredient list
168170 final Map <Integer , List <Integer >> matchesMap = new HashMap <>();
169171 for (int i = 0 ; i < ingredients .size (); i ++) {
170172 Ingredient ingredient = ingredients .get (i );
171173 boolean noMatch = true ;
172174 for (int j = 0 ; j < stacks .size (); j ++) {
173- if (ingredient .test (stacks .get (j ))) {
175+ final ItemStack stack = stacks .get (j );
176+ if (!stack .isEmpty () && ingredient .test (stack )) {
174177 matchesMap .computeIfAbsent (j , k -> new ArrayList <>()).add (i );;
175178 noMatch = false ;
176179 }
@@ -181,7 +184,8 @@ public ItemStack getResultItem(final HolderLookup.Provider $$1) {
181184 }
182185 }
183186
184- if (matchesMap .isEmpty ()) {
187+ if (matchesMap .size () != elements ) {
188+ // At least one stack had no matching ingredient
185189 return false ;
186190 }
187191
0 commit comments