Uploaded image for project: 'Minecraft (Bedrock codebase)'
  1. Minecraft (Bedrock codebase)
  2. MCPE-161753

Gametest Enchantment API does not work or is wrongly documented

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Awaiting Response
    • None
    • 1.19.21 Hotfix
    • None
    • Plausible
    • Multiple

      Steps to Reproduce:

      1. create addon featuring GameTest code
      2. Retrieve a tool (e.g. pickaxe) with enchantments on it
      3. 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.

            Inferis Tom Adriaenssen
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: