本文整理汇总了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());
}