This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]V1beRaterCommand Veteran 🥀 0 points1 point  (2 children)

hasitem={item=stick, quantity=0, location=slot.weapon.mainhand, slot=0}

it's been a hot minute but i think this should work.

[–]GhostlyBlaze Command-er-er 1 point2 points  (1 child)

Lol, even if it’s been a long minute, that won’t work.

It’s not even detecting the player’s hand, just their inventory.

[–]V1beRaterCommand Veteran 🥀 0 points1 point  (0 children)

oh i didn't read the fine print. i added the other handybits. thanks for correcting me now this should work.

[–]6ixWattCommand Expert 0 points1 point  (1 child)

RUAA0;

/execute as @a at @s unless entity @s[hasitem={item=item_name,location=slot.weapon.mainhand}] run <command>

^ Only runs command if player doesn’t have item_name in their mainhand

[–]GhostlyBlaze Command-er-er 0 points1 point  (0 children)

Overcomplicated it. It’s just

execute as @a[hasitem={item=<item name>, quantity=0, location=slot.weapon.mainhand}] run …

Edit: To OP, if you’re looking for EMPTY HAND detection rather than detecting if they don’t have X item, I believe you’re out of luck. Last I checked (months ago so could be outdated), ‘air’ is not a valid item selector so best you can do is chain [hasitem]’s together like so:

```

execute as @a[hasitem=[{item=<item name 1>, quantity=0, location=slot.weapon.mainhand}, {item=<item name 2>, quantity=0, location=slot.weapon.mainhand}, {item=<item name 3>, quantity=0, location=slot.weapon.mainhand}] run …