/**
* {@inheritDoc}
*/
@Override
public boolean matches(CraftingInventory craftingInventory, World world) {
final List<ChoiceIngredient> ingredients = new ArrayList<>(this.ingredients);
final List<ItemStack> contents = Arrays.asList(craftingInventory.getMatrix())
.stream().filter(i -> !InventoryUtils.isEmptyStack(i))
.collect(Collectors.toList());
for (ItemStack stack : contents) {
boolean match = false;
for (int ingredientIndex = 0; ingredientIndex < ingredients.size(); ingredientIndex++) {
ChoiceIngredient ingredient = ingredients.get(ingredientIndex);
if (ingredient.isIngredient(stack)) {
ingredients.remove(ingredientIndex);
match = true;
break;
}
}
//there was no matching ingredient for the current ItemStack
if (!match) return false;
}
//return true if there are no unused ingredients left over
return ingredients.isEmpty();
}
SimpleShapelessRecipe.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:CustomRecipes
作者:
评论列表
文章目录