mojira.dev
MCPE-176457

When using the itemUse event of the script api and trying to cancel the equipping of a custom item, the item is stuck in the slot where the item was to be equipped.

I'm trying to use the world.beforeEvents.itemUse to cancel the setting of a custom item, but when I try to do it the item is blocked in the slot where it should be equipped, this only happens if the player is in creative and with custom items apparently 

 

code:
world.beforeEvents.itemUse.subscribe((eventData) => {
    let player = eventData.source
    system.run(() => {
        let chestplate = player.getComponent('equippable').getEquipmentSlot('Chest')
        player.runCommand('say hi-' + chestplate.typeId)
        if (chestplate.typeId == 'backpack:backpack_c') {
            player.runCommand('/replaceitem entity @s slot.armor.chest 0 air')
            player.runCommand('say place')
        }

    })
    eventData.cancel = true;
})
 
Evidence:
https://drive.google.com/file/d/1fiprPu54LJJ4h9OzXqvYtHwo1KvcnY4w/view?usp=sharing
 

Comments 3

I forgot to post the video in public, I've done it.

If this is still an issue in the latest release, could you please provide a sample behavior pack for testing purposes?

This issue is being temporarily resolved as Awaiting Response. Once the requested information has been delivered, the report will be reopened automatically.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

SnowBerry

(Unassigned)

Unconfirmed

Windows

Windows 10

1.20.40

Retrieved