0

I'm building a city themed parkour map and I'm trying to figure out how to detect if a player is in a certain place and has a certain item in his inventory. I've tried using a combination of these two commands:

/execute if entity @p[x=-628,y=120,z=-157,dx=0,dy=0,dz=3]

and

/execute if entity @a[nbt={Inventory:[{id:"minecraft:rabbit_stew"}]}]

but I just can't figure it out. I'd appreciate your help.

1 Answer 1

1

Try combining those into one command:

execute if entity @a[x=-628,y=120,z=-157,dx=0,dy=0,dz=3,nbt={Inventory:[{id:"minecraft:rabbit_stew"}]}]
3
  • Thank you, I just wanted to ask one more thing when I have my command block on impulse and always active with this command: /execute if entity @a[x=168,y=64,z=-154,dx=0,dy=0,dz=3,nbt={Inventory:[{id:"minecraft:rabbit_stew"}]}] run say Thank you it doesn't work but when I make it on repeat it works, but I just want it to say it one time and also do you know how to take away that rabbit stew from the player
    – Karolis
    Feb 1, 2021 at 16:22
  • @Karolis 1) change the command block to redstone powered and give it a pulse when you want to use it. 2) use the /clear command
    – Penguin
    Feb 1, 2021 at 16:26
  • Thank you so much.
    – Karolis
    Feb 1, 2021 at 16:36

You must log in to answer this question.

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