These functions take the itemStack as a parameter; however, based on testing, the function only returns correctly when the item typeId specified in the itemStack matches the item's name in-game, which should not matter as the typeId is provided in the ItemStack parameter and has not changed
And even after changing the name back to the original, the methods still don't detect the item
The expected result is that the methods find the itemstack regardless of name change through the use of the typeId provided in the itemStack parameter
steps to recreate
Write a script that returns the value of the contains and find methods
Go into the game and change the name of the item you specified in the itemStack parameter of the methods
observe results
Here is the code and a video of the bug in-game(had to attach video as a YouTube link as the file failed to upload 😞)
world.afterEvents.itemUse.subscribe((data) => {
const Player = data.source
const Item = data.itemStack
const inv = Player.getComponent("inventory").container
if (Item.typeId === "minecraft:stick") {
console.warn(inv.contains(new ItemStack("minecraft:diamond", 1)))
}
if (Item.typeId === "minecraft:diamond" && Player.isSneaking) {
console.warn(Item.typeId)
}
})Comments 0
No comments.