protected int calculateRepairAmount(List<Material> materials, NonNullList<ItemStack> repairItems) { Set<Material> materialsMatched = Sets.newHashSet(); float durability = 0f; // try to match each material once for(int index : getRepairParts()) { Material material = materials.get(index); if(materialsMatched.contains(material)) { continue; } // custom repairing durability += repairCustom(material, repairItems) * getRepairModifierForPart(index); Optional<RecipeMatch.Match> matchOptional = material.matches(repairItems); if(matchOptional.isPresent()) { RecipeMatch.Match match = matchOptional.get(); HeadMaterialStats stats = material.getStats(MaterialTypes.HEAD); if(stats != null) { materialsMatched.add(material); durability += ((float) stats.durability * (float) match.amount * getRepairModifierForPart(index)) / 144f; RecipeMatch.removeMatch(repairItems, match); } } } durability *= 1f + ((float) materialsMatched.size() - 1) / 9f; return (int) durability; }
Material material = materials.get(index); if(repairCustom(material, items) > 0) { foundMatch = true;