expose more enchantment function to API & use them
Some checks are pending
Java CI with Gradle / build (push) Waiting to run

This commit is contained in:
alexcrea 2026-06-30 07:47:41 +02:00
parent 72a7860d93
commit 1e2acb6f48
Signed by: alexcrea
GPG key ID: E346CD16413450E3
6 changed files with 107 additions and 72 deletions

View file

@ -21,23 +21,6 @@ object ItemUtil {
*/
fun ItemStack.isEnchantedBook() = type == ENCHANTED_BOOK
/**
* Find the enchantment map for this [ItemStack] and return it as a [MutableMap]
*/
fun ItemStack.findEnchantments(): MutableMap<CAEnchantment, Int> = CAEnchantment.getEnchants(this)
/**
* Apply an [enchantments] map to this [ItemStack]
*/
fun ItemStack.setEnchantmentsUnsafe(enchantments: Map<CAEnchantment, Int>) {
CAEnchantment.clearEnchants(this)
enchantments.forEach { (enchantment, level) ->
enchantment.addEnchantmentUnsafe(this, level)
}
}
private fun maxDamage(damageable: Damageable): Int {
val ver = UpdateUtils.currentMinecraftVersion()
if(ver.major <= 1 && ver.minor <= 20 && ver.patch < 5) return Integer.MAX_VALUE