Fluffyalien
- Fluffyalien
- JIRAUSER745371
- America/Los_Angeles
- Yes
- No
`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 has granite at slot 0. 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('Item at slot 0 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.
`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 has granite at slot 0. 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('Item at slot 0typeId:', 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.
`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 has granite at slot 0. 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.
`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 playerhas granite at slot 0. 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.
`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.
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'
The `onPlace` method on block custom components is triggered when the block is updated (eg. state change) not only when the block is placed.
How to reproduce with test pack:
- Place the `testpack:test_block` block
- The block's `testpack:test_state` will be reversed every 10 ticks
- `onPlace` will warn "onPlace triggered" when it is called
- Observe
The `onPlace` method on block custom components is triggered when the block is updated (eg. state change) not only when the block is placed.
How to reproduce with test pack:
- Place the `testpack:test_block` block
- The block's `testpack:test_state` will be reversed every 10 ticks
- `onPlace` will warn "onPlace triggered" to the content log when it is called
- Observe
[MCQA] Bartłomiej Słodkowski
Yes, this is still an issue.
Some blocks that still have not been separated:
KR_,
I've attached a test pack and added instructions to reproduce the bug in the issue description