mojira.dev
MCPE-229145

scripting api inventory methods contains and find affected by item name changes even though item typeId is provide in itemStack parameter

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

  1. Write a script that returns the value of the contains and find methods

  2. Go into the game and change the name of the item you specified in the itemStack parameter of the methods

  3. 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)
        
    }
})

Video of the bug

Comments 0

No comments.

Gamer99

(Unassigned)

Unconfirmed

Multiple

1.21.111

Retrieved