本文整理匯總了Java中net.minecraft.item.Item.isRepairable方法的典型用法代碼示例。如果您正苦於以下問題:Java Item.isRepairable方法的具體用法?Java Item.isRepairable怎麽用?Java Item.isRepairable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.item.Item
的用法示例。
在下文中一共展示了Item.isRepairable方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generateDawnstoneAnvilRecipes
import net.minecraft.item.Item; //導入方法依賴的package包/類
private List<RecipeDawnstoneAnvil> generateDawnstoneAnvilRecipes()
{
//I'm basicly sorry for all of this. Please forgive me.
ArrayList<RecipeDawnstoneAnvil> repairRecipes = new ArrayList<>();
ArrayList<RecipeDawnstoneAnvil> destroyRecipes = new ArrayList<>();
for (Item item : Item.REGISTRY) {
ItemStack stack = item.getDefaultInstance();
ItemStack repairItem = ItemStack.EMPTY;
try {
repairItem = Misc.getRepairItem(stack);
}
catch (Exception e) { //Gotta catch em all
e.printStackTrace();
}
boolean isRepairable = item.getIsRepairable(stack, repairItem);
boolean materiaAllowed = item.isRepairable();
if(isRepairable || materiaAllowed)
{
ArrayList<ItemStack> repairMaterials = new ArrayList<>();
repairMaterials.add(repairItem.copy());
if(materiaAllowed)
repairMaterials.add(new ItemStack(RegistryManager.isolated_materia));
ItemStack[] repairMaterialsArray = repairMaterials.toArray(new ItemStack[repairMaterials.size()]);
repairRecipes.add(new RecipeDawnstoneAnvil(new ItemStack[]{stack.copy()}, Ingredient.fromStacks(makeDamaged(stack)),Ingredient.fromStacks(repairMaterialsArray)));
if(Misc.getResourceCount(stack) != -1) {
ItemStack material = repairItem.copy();
material.setCount(Misc.getResourceCount(stack));
destroyRecipes.add(new RecipeDawnstoneAnvil(new ItemStack[]{material}, Ingredient.fromStacks(makeDamaged(stack)), Ingredient.EMPTY));
}
}
}
return Stream.concat(repairRecipes.stream(),destroyRecipes.stream()).collect(Collectors.toList());
}