/**
* Returns true if the recipe contained in this verifier matches the given
* {@link ShapelessRecipe}.
*
* @param recipe
* @return True if the recipe was verified.
*/
boolean verify(ShapelessRecipe recipe) {
List<ItemStack> ingredients = recipe.getIngredientList();
for (int i = 0; i < rows; i++) {
RECIPEITEM: for (int j = 0; j < columns; j++) {
ItemStack recipeItem = matrix[i][j];
if (recipeItem == null)
continue;
for (Iterator<ItemStack> it = ingredients.iterator(); it.hasNext();) {
ItemStack ingredient = it.next();
if (ItemUtils.recipeIngredientEqualsTypeAndData(ingredient, recipeItem)) {
int amount = ingredient.getAmount();
if (amount == 1)
it.remove();
else
ingredient.setAmount(amount - 1);
continue RECIPEITEM;
}
}
// An item in the matrix is not on the ingredient list.
return false;
}
}
// If the list of ingredients was exhausted, recipe verified.
if (ingredients.size() == 0)
return true;
// Unsatisfied ingredients remain.
return false;
}
RecipeVerifier.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:StarQuestCode
作者:
评论列表
文章目录