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

No way to differentiate between data items [GameTest]

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.19.80.24 Preview, 1.19.80.23 Preview, 1.19.80.22 Preview, 1.19.80.21 Preview, 1.19.70.22 Preview, 1.19.70.21 Preview, 1.19.73, 1.20.80.21 Preview
    • Confirmed
    • Multiple
    • 1202892

      `ItemStack.data` was removed in this preview and now there is no way to differentiate between stacked by data items. For example, there is no way to differentiate between Stone and Granite since they are both `minecraft:stone` and the `data` property has now been removed.

       

      Example Script:

       

      import * as s from '@minecraft/server';
      
      const player = s.world.getAllPlayers()[0];
      
      // Assume the player is holding granite.
      const selectedItem = player.getComponent('inventory').container.getItem(player.selectedSlot); // This would return an ItemStack of granite.
      if (!selectedItem) throw "Not holding an item, please hold granite and run '/reload'.";
      
      // However, there is no way to know if it is granite because there is no data property on the item.
      
      console.warn('selectedItem.typeId:', selectedItem.typeId /* returns 'minecraft:stone'. */);
      
      for (const property in selectedItem.type /* returns ItemType with only one property, 'id', which equals 'minecraft:stone'. */) console.warn('Property in selectedItem.type:', property, 'Property value:', selectedItem.type[property]);
      
      console.warn('selectedItem.data:', selectedItem.data /* returns undefined. */);
      
      // So, there's no way to know if the item recieved is stone or another stone variant. This also applies to many other blocks and items.

       

       

            Fluffyalien Fluffyalien
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              CHK: