mojira.dev
MCPE-166705

No way to differentiate between data items [GameTest]

`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.

 

 

Attachments

Comments 5

This affects a lot of items, such as logs. 
For example, defining:

const value = MinecraftItemTypes.acaciaLog;  
const value2 = MinecraftItemTypes.acaciaBoat; // Or most other items

Results in 'value' being undefined, but 'value2' being a populated ItemType.

Thank you for your report!

However, this issue has been temporarily closed as Awaiting Response.

Could you please attach an example addon that showcases the issue?

This ticket will automatically reopen when you reply.

Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📓 Project Summary – 📧 Suggestions – 📖 Minecraft Wiki

I found a workaround, it's pretty nasty, but it works:

Give and clear command still use data.

You can use these commands with the typeId of the item and various data values (0-15) to detect if the amount of the item changes.

Thank you for your report!

However, this issue has been temporarily closed as Awaiting Response.

Is this still an issue in the latest version? If yes, could you please add it to the affected versions (or mention it if you are not the reporter)?

This ticket will automatically reopen when you reply.

Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📓 Project Summary – 📧 Suggestions – 📖 Minecraft Wiki

[[MCQA] Bartłomiej Słodkowski|https://bugs.mojang.com/secure/ViewProfile.jspa?name=baslod]

Yes, this is still an issue.
Some blocks that still have not been separated:

  • slabs (eg. brick slabs are still `minecraft:stone_block_slab`)

  • flowers - many flowers are still under `minecraft:red_flower` and `minecraft:yellow_flower` (eg. oxeye daisy is `minecraft:red_flower`)

  • walls (eg. brick walls are still `minecraft:cobblestone_wall`)

Fluffyalien

(Unassigned)

1202892

Confirmed

Multiple

Addon, GameTest, Items, itemstack

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

Retrieved