So, I need o give players one arrow every two seconds, but with a maximum of two arrows in the inventory. To do this, I tried adding a scoreboard objective called ArrowN and setting the score to 1 if the player has one arrow and to 2 if the player has two arrow. Then every two seconds replacing with two arrows if the player has an ArrowN score of 1 and not replacing if he has a score of 2. Now, I couldn't get how to set a score of 0 for a player that has no arrows, to replace him one arrow. Something like this just works for a half:

scoreboard objectives set @a[score_ArrowN=!1,score_ArrowN=!2] ArrowN 0

I think operation could be useful, but i can't use that command.

Note: it must be multiplayer friendly

Edit:probably using /give is a lot easier but I don't like having arrows popping on your face every two seconds

  • 1
    Have you tried giving everybody a score of 0, test for the number of arrows (give everybody who has arrows to 1 or 2) then apply the giving of the arrows?
    – aytimothy
    Sep 8, 2015 at 10:13
  • It is what i was trying to do with the scoreboard objectives set @a[score_ArrowN=!1,score_ArrowN=!2] ArrowN 0, but it won't work
    – Lionitow
    Sep 8, 2015 at 11:27
  • I don't think you got my concept. I'll post an answer when I can write one up.
    – aytimothy
    Sep 8, 2015 at 12:11
  • The scoreboard command you wrote does not do what you think it does. The target selector argument score_name checks for the maximum, not an exact value. Also, the first check is overwritten by the second, meaning that you select players who don't have 2 our less arrows.
    – MrLemon
    Sep 8, 2015 at 12:52
  • 1
    You can simply set everyone's score to 0 before counting the arrows and setting It to 1 or 2 (using inventory, I assume). You can do all of this in the same tick, so the score effectively doesn't change at all (unless it should, of course)
    – MrLemon
    Sep 8, 2015 at 12:57

2 Answers 2


Part of the solution is to use the /stats command to count the number of arrows in a players inventory using the /clear command, and set that result to a scoreboard objective for the player. Then it's pretty straight forward command-block-fu to give arrows when needed, as well as take them away. Let's see how I did it.

First things first, though, I'm doing this in 1.9, but the commands will work fine in 1.8, with a little adjustment and a 20Hz fill clock.

We need 2 scoreboard objectives: the arrow count (which you've named ArrowN, so I'll keep that in my example), and a timer variable.

/scoreboard objectives add ArrowN dummy
/scoreboard objectives add Timer dummy

Next, we need a chain of command blocks, starting with a repeating command block, and followed by several chain command blocks. Set the repeating command block to "Needs Redstone", at least for now, and the rest to "Always Activate". The first two commands, in order, are:

/scoreboard players remove #Timer Timer 1
/clear @a minecraft:arrow -1 0

#Timer is a dummy player that will never show up in scoreboard displays, and he will keep track of when to hand out arrows. It might be a good idea to initially set his Timer score to 40, but that's not strictly necessary. The second command will count all the arrows someone has in their inventory, independent of the number of stacks. Unfortunately, this doesn't do much for us until we get that count into the scoreboard. To do this, stand on the command block and enter the following command (through chat):

/stats block ~ ~-1 ~ set QueryResult @a ArrowN

So, whenever the clear command gets run, the count that it finds will be placed in that players ArrowN score.

The next three commands manage the 2 second timer and dole out the arrows. In 1.9, the first is unconditional, while the other 2 are conditional. For 1.8, you can use comparators off each side of the first command block, but this is a little inelegant.

/scoreboard players test #Timer Timer * 0
/scoreboard players set #Timer Timer 40
/give @a[score_ArrowN=1] minecraft:arrow

The first command tests to see if the timer has reached 0, and if so, resets it (the second command) and gives all players an arrow if they have at most 1 arrow already (the third command).

Now, we just need to remove arrows from people who have too many. These commands are all unconditional so that they run every game tick:

/clear @a[score_ArrowN_min=3] minecraft:arrow -1 1
/clear @a[score_ArrowN_min=12] minecraft:arrow -1 9
/clear @a[score_ArrowN_min=66] minecraft:arrow -1 54

These three commands will remove a total of 1 arrow if the player has between 3 and 10, 10 arrows if they have between 12 and 66, and a whole stack if they have 66 or more. You can expand on this (and add finer intervals) if you find arrows aren't being removed fast enough, but it should take less than a second in most cases.


One way to do this would be to set up a command block to give everyone an arrow every 2 seconds, then in a repeating command block put:
/scoreboard players set @a Arrows 1 {Inventory:[{id:minecraft:arrow,Count:3b}]}
and then:
clear @a[score_Arrows_min=1] minecraft:arrow
give @a[score_Arrows_min=1] minecraft:arrow 2
/scoreboard players set @a[score_Arrows_min=1] Arrows 0
in command blocks in a fill clock so that they all trigger on the same tick, in this order. (if you are on the 1.9 snapshots, you can replace a fill clock with a command chain and the Arrows score with a tag)
This is not ideal, and if a player gets more than 3 arrows somehow, they will keep getting arrows forever, but without the ability to check negated NBT, such as {Inventory:[{Count:!2b}]}, I think this is your best bet.

  • You can check for negated NBT, you just need to test for not the score. For example testing for players with out 2 arrows in their inventory, first mark all players with 2 arrows and do @a[score_Arrow_min=!1]
    – Moddl
    Sep 8, 2015 at 21:36
  • @ModDL I know you can test negated selector arguments, but that isn't NBT. Sep 8, 2015 at 23:57
  • If you have a score of the NBT and you test for the negate of the score, whats the difference between testing negated NBT?
    – Moddl
    Sep 9, 2015 at 0:07
  • I've discovered something while testing my own solution: having more than one stack of arrows can allow someone to easily hold 3 or more arrows, because the data tag is only tested against a single inventory slot, not the entirety of the inventory.
    – MBraedley
    Sep 9, 2015 at 0:10
  • @ModDL I may be missing something, is there a way to set a scoreboard objective to an NBT value? I was not aware of a way to do this. Sep 9, 2015 at 3:30

You must log in to answer this question.

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