Uploaded image for project: 'Minecraft (Bedrock codebase)'
  1. Minecraft (Bedrock codebase)
  2. 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.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Awaiting Response
    • None
    • 1.20.40
    • None
    • Unconfirmed
    • Windows

      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
       

            SnowBerry SnowBerry
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: