mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
expose more enchantment function to API & use them
Some checks are pending
Java CI with Gradle / build (push) Waiting to run
Some checks are pending
Java CI with Gradle / build (push) Waiting to run
This commit is contained in:
parent
72a7860d93
commit
1e2acb6f48
6 changed files with 107 additions and 72 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue