當前位置: 首頁>>代碼示例>>Java>>正文


Java Item.isRepairable方法代碼示例

本文整理匯總了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());
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:36,代碼來源:JEI.java


注:本文中的net.minecraft.item.Item.isRepairable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。