use of org.spongepowered.api.item.enchantment.Enchantment in project modules-extra by CubeEngine.
the class RepairBlock method getEnchantmentMultiplier.
/*
* Utilities
*/
public static double getEnchantmentMultiplier(ItemStack item, double factor, double base) {
double enchantmentLevel = 0;
Optional<List<Enchantment>> enchs = item.get(Keys.ITEM_ENCHANTMENTS);
if (enchs.isPresent() && !enchs.get().isEmpty()) {
for (Enchantment enchantment : enchs.get()) {
enchantmentLevel += enchantment.getLevel();
}
}
if (enchantmentLevel > 0) {
double enchantmentMultiplier = factor * Math.pow(base, enchantmentLevel);
enchantmentMultiplier = enchantmentMultiplier / 100.0 + 1.0;
return enchantmentMultiplier;
} else {
return 1.0;
}
}
Aggregations