i have this:
const holdingItem = player.getComponent("minecraft:equippable").getEquipment("Mainhand");
const sneaking = player.isSneaking;
world.sendMessage(" ");
world.sendMessage(`typeof: ${typeof holdingItem}`);
world.sendMessage(`constructor.name: ${holdingItem.constructor?.name}`);
world.sendMessage(`${holdingItem.nameTag}`);
the first sendMessage (after the empty one) returns the type, which (when holding an item) is object
the second one returns the name of the class that its in, in this case its ItemStack, to which i go and see the class:
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/itemstack?view=minecraft-bedrock-stable
and based on the documentation, i should be able to get the name using .nameTag but when i do, it returns undefined even though im holding a grass block. Why?