Steps to Reproduce:
create addon featuring GameTest code
Retrieve a tool (e.g. pickaxe) with enchantments on it
Run the code below to retrieve an enchantment
Observed Results:
The code doesn't work
Expected Results:
The code does work and it is possible to retrieve an enchantment (or all enchantments).
let inventory = player.getComponent("minecraft:inventory")
if (inventory && inventory.container) {
let item = inventory.container.getItem(player.selectedSlot)
let enchantmentsComponent = item.getComponent("minecraft:enchantments")
if (enchantmentsComponent != null) {
let enchantments = enchantmentsComponent.enchantments
if (enchantments != null) {
let enchantment = enchantments.getEnchantment(EnchantmentType.mending) // ?
}
}
}
EnchantmentType.mending does not exist, and EnchantmentType does not have a constructor. I've tried with "mending" or "minecraft:mending" but that gives the same result.
None of this is properly documented it appears.
The releasenotes also mention allEnchantments but that does not exist either.
Is this still an issue in the latest version?