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

ItemDurabilityComponent#maxDurability failed to get property

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.20.73 Hotfix
    • None
    • Unconfirmed
    • Multiple

      When creating an 'ItemStack' and getting 'maxDurability' in the same expression, it throws an error. But when assigning the 'ItemStack' to a variable then accessing 'maxDurability' in a different expression, it works.

      const item = new ItemStack("diamond_sword");
      const maxDurability = item.getComponent("durability")?.maxDurability ?? 0;
      // works fine

       
       

      const maxDurability = new ItemStack("diamond_sword").getComponent("durability")?.maxDurability ?? 0;
      // Error: failed to get property 'maxDurability'

            Fluffyalien Fluffyalien
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: