3

I would like to accomplish this using a single command in a command block that is set to repeat, and I'd like to avoid using the scoreboard. I'm looking to check whether or not the player's level is above Lv.15, and if so, give them a tripwire hook named "15EXP Key". I'd also like to make sure they only have one of these keys at a time, so as to encourage using them before acquiring any more experience. I had tried this, but it didn't work how I had expected it to:

/execute unless entity @a[nbt={Inventory:[{id:"minecraft:tripwire_hook"}]}] run give @a[level=15..] minecraft:tripwire_hook{Name:"15EXP Key"} 1

Moreover, this command will be used in an area with multiple nearby players, and I'd like it to only apply to players in a certain specified area, but I have no idea how to do that. Also, it should apply to those players individually so that if one player has the required levels and the other does not, the player with the right level should receive the item but the other should not.

1
  • I'm pretty sure you have to change the order of checks, first @a[level=15..], then unless @s[nbt={…}]. Also, you said that it doesn't work like expected, how does it behave instead? Does the check for tripwire in the inventory work? I think it should, but I'm not 100% sure. Sep 4, 2018 at 20:45

1 Answer 1

2

Check out this command:

/execute as @a[scores={level=15..},nbt=!{Inventory:[{id:"minecraft:tripwire_hook"}]}] run give @s tripwire_hook{display:{Name:"\"15EXP Key\""}}

Notice I've added a Count in the nbt, moved the score condition to the execute command and did some tweaking to your code to code I know would work. However, I have not tested this, but by the looks of it it should definitely work.

You must log in to answer this question.

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