3

I have a command block, among others, that checks an area and gives all players within that aren't holding a soul lantern in their offhand the Wither effect:

execute as @a[x=1237,y=57,z=-195,distance=..50,nbt=!{Inventory:[{Slot:-106b,Count:1b,id:"minecraft:soul_lantern"}]}] run effect give @s minecraft:wither 3 2 true

This command works on me totally fine, but others that enter the area are still withered despite holding the lantern. I've tried multiple variations of achieving this result, and all worked for me but seemed to fail to check if other players were holding the right item. Is there just a problem with how I'm defining what entities to target?

2
  • I assume this is the latest version right? (I'm just going to try to debug this, so it would be helpful to know)
    – Blue Robin
    Feb 12, 2023 at 3:50
  • 1
    I changed your command just a bit so it does the same but slightly differently: execute as @a[x=1237,y=57,z=-195,distance=..50] unless entity @s[nbt={Inventory:[{Slot:-106b,Count:1b,id:"minecraft:soul_lantern"}]}] run effect give @s minecraft:wither 3 2 true It will execute all players in the area, and if the player holds a soul lantern offhand it will ignore it. Just like the original but I have separated the selectors. it might work better in multiplayer but I haven't tested it myself. That's why I just made a comment. Feb 12, 2023 at 12:43

1 Answer 1

2

For 1.16+ use this command for players

Note: @a is for all players

execute as @a[x=1237,y=57,z=-195, distance=..50,nbt=!{SelectedItem:{id:"minecraft:soul_lantern",Count:1b}}] run effect give @s minecraft:wither 3 2 false

For certain entities, use this command:

Note: @e is for all entities You can see the selectors are different than the player selectors.

execute as @e[x=1237,y=57,z=-195, distance=..50,nbt=!{HandItems:[{id:"minecraft:soul_lantern",Count:1b}]}] run effect give @s minecraft:wither 3 2 false

Note: HandItems is in a list, and that means you can add more items which is cool.

I changed the NBT to SelectedItem which is what the player is holding. Reference to all NBT selectors: https://www.digminecraft.com/data_tags/player.php

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .