本文整理匯總了Java中org.bukkit.inventory.ShapelessRecipe.getIngredientList方法的典型用法代碼示例。如果您正苦於以下問題:Java ShapelessRecipe.getIngredientList方法的具體用法?Java ShapelessRecipe.getIngredientList怎麽用?Java ShapelessRecipe.getIngredientList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.inventory.ShapelessRecipe
的用法示例。
在下文中一共展示了ShapelessRecipe.getIngredientList方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fromBukkitRecipe
import org.bukkit.inventory.ShapelessRecipe; //導入方法依賴的package包/類
public static CraftShapelessRecipe fromBukkitRecipe(ShapelessRecipe recipe) {
if (recipe instanceof CraftShapelessRecipe) {
return (CraftShapelessRecipe) recipe;
}
CraftShapelessRecipe ret = new CraftShapelessRecipe(recipe.getResult());
for (ItemStack ingred : recipe.getIngredientList()) {
ret.addIngredient(ingred.getType(), ingred.getDurability());
}
return ret;
}
示例2: fromBukkitRecipe
import org.bukkit.inventory.ShapelessRecipe; //導入方法依賴的package包/類
public static CraftShapelessRecipe fromBukkitRecipe(ShapelessRecipe recipe) {
if (recipe instanceof CraftShapelessRecipe) {
return (CraftShapelessRecipe) recipe;
}
CraftShapelessRecipe ret = new CraftShapelessRecipe(recipe.getKey(), recipe.getResult());
for (ItemStack ingred : recipe.getIngredientList()) {
ret.addIngredient(ingred.getType(), ingred.getDurability());
}
return ret;
}
示例3: collect
import org.bukkit.inventory.ShapelessRecipe; //導入方法依賴的package包/類
Transaction collect(ShapelessRecipe recipe) {
List<ItemStack> ingredients = recipe.getIngredientList();
List<ItemStack> collected = new ArrayList<ItemStack>(ingredients.size());
INGREDIENTS: for (ItemStack ingredient : ingredients) {
for (ItemStack item : collected) {
if (ItemUtils.itemEqualsTypeAndData(item, ingredient)) {
item.setAmount(item.getAmount() + ingredient.getAmount());
continue INGREDIENTS;
}
}
collected.add(ingredient);
}
return new Transaction(collected, recipe.getResult());
}
示例4: verify
import org.bukkit.inventory.ShapelessRecipe; //導入方法依賴的package包/類
/**
* 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;
}
示例5: SerialisableShapelessRecipe
import org.bukkit.inventory.ShapelessRecipe; //導入方法依賴的package包/類
public SerialisableShapelessRecipe(ShapelessRecipe recipe) {
this.ingredients = recipe.getIngredientList();
this.result = recipe.getResult();
}
示例6: shapelessRecipesMatch
import org.bukkit.inventory.ShapelessRecipe; //導入方法依賴的package包/類
/**
* Checks to see if the ingredients of the recipes are the same.
*
* @param a Recipe A
* @param b Recipe B
* @return If A & B have the same ingredients
*/
private boolean shapelessRecipesMatch(ShapelessRecipe a, ShapelessRecipe b) {
final List<ItemStack> aL = a.getIngredientList();
final List<ItemStack> bL = b.getIngredientList();
return aL.size() == bL.size() && aL.containsAll(bL);
}