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'
Comments 2
Cleaning up old tickets: This ticket had been set to 'Awaiting Response', but has not received a response from the reporter (~3 months+) so is being closed as Incomplete. If you feel this is still a valid issue then please comment, or create a new ticket following the Issue Guidelines which includes steps to reproduce the problem.
Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki
Please attach a sample behavior pack/add-on that can be used to reproduce this.