Mojira Archive
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
 

Awaiting Response

SnowBerry

2023-10-28, 08:52 AM

2024-02-01, 06:09 PM

2024-02-01, 06:09 PM

0

2

Unconfirmed

1.20.40

-