/**
* Removes an enchant from an ItemStack
* @param item
* @param enchantId
* @returns the ItemStack if the enchant was successfully removed
*/
export function removeEnchant(item: ItemStack, enchantId: string): ItemStack|null{
const enchantable = item.getComponent('enchantable')
if (!enchantable) return null;
const enchants = enchantable.getEnchantments()
const enchant = enchants.find(ench => ench.type.id === enchantId)
if (!enchant) return null;
enchantable.removeEnchantment(enchant.type)
return item
}
#Enchant Remover
1 messages · Page 1 of 1 (latest)