3

I'm trying to set up a series of working commands that test when the player breaks the wool block (i.e. the flag), they get tagged as the FlagCarrier. They will also have other effects applied, specifically the glowing effect and a banner placed on their head. I know how to do the glowing and banner, but for some reason I can't seem to get the 'FlagCarrier' commands to work.

I was originally trying to testfor when a player breaks a certain block (at exact coordinates) I tried testing for air (which worked) - but how does the command know who broke it? So now instead I'm trying to tag whoever picks it up and has the wool block in their inventory. But I can't seem to:

/execute @a {Inventory:[{id:"minecraft:wool",Damage:11s}]} /scoreboard players set @a FlagCarrier 1.

For some reason execute doesn't work with scoreboard?

My original set-up commands are:

/execute @a[r=100] ~ ~ ~ /scoreboard objectives add FlagCarrier dummy

This has a comparator leading into a block with a redstone torch, so it activates when the player is NOT within 100 blocks: /execute @a ~ ~ ~ /scoreboard objectives remove FlagCarrier

/execute @a[r=100] ~ ~ ~ /scoreboard objectives setdisplay sidebar FlagCarrier (also, this isn't showing unless I manually set it to either 1 or 0)

Also, how can I replace the block if there is no player tagged FlagCarrier, and no flag item on the ground? I would like to have it so a player on the blue team cannot pick up the blue flag, and it is instead returned to their base. whereas a red player could pick up the dropped flag and gain the tags.

I'm playing version 1.12, so any of the new or changed commands from 1.13+ won't help.

3
  • Your first command, /execute @a {Inventory:[{id:"minecraft:wool",Damage:11s}]} /scoreboard players set @a FlagCarrier 1 doesn't have tildes? Shouldn't it be /execute @a {Inventory:[{id:"minecraft:wool",Damage:11s}]} ~ ~ ~ scoreboard players set @a FlagCarrier 1?
    – AMJ
    Commented May 12, 2020 at 0:19
  • Your commands seem to be a mix of 1.12 commands and 1.13 command, I recommend reading or watching a commands tutorial that came out after 1.13 or an update video that summarises the changes, for example this one: youtube.com/watch?v=uO41sptfGt8 But the existing answer is already good, checking the pickup and drop directly is better. Commented May 12, 2020 at 7:45
  • 1

2 Answers 2

4

What you have is close, the main problem is in your execute:

/execute @a {Inventory:[{id:"minecraft:wool",Damage:11s}]} /scoreboard players set @a FlagCarrier 1

What this execute is doing is running scoreboard players set @a FlagCarrier 1 at the position of all players for which {Inventory:[{id:"minecraft:wool",Damage:11s}]} matches. In other words, if one or more players have wool with damage value 11, the command block sets the FlagCarrier score for @a (every player in the server) to 1.

This can be simplified using just a /scoreboard command that utilizes the appropriate NBT data:

/scoreboard players set @a FlagCarrier 1 {Inventory:[{id:"minecraft:wool",Damage:11s}]}

This sets the FlagCarrier score to 1 for all players that match that NBT (aka, all players that have that particular color of wool in their inventory).

2

Depends what version you're using but if you're using 1.13 or over, do this:

First make a new objective where the objective is to pick up wool

/scoreboard objectives add (Name) minecraft.picked_up:minecraft.(color)_wool

Next set up a repeat command block that is always on that will detect who has the wool and give them glowing

/execute as @a[scores={(Name)=1}] run effect give @s minecraft:glowing 1 10 true

Next, make another objective that will see when a player drops the wool

/scoreboard objectives add (Name2) minecraft.dropped:minecraft.(same color as last time)_wool

Then make two other repeat command blocks that are always on and put this in the first

/execute as @a[scores={(Name2)=1}] run scoreboard players remove @s (Name) 1

and this in the second

/execute as @a[scores={Name1=1}] run scoreboard players remove @s (Name2) 1

Lastly, add the players to both of the scoreboards and you should be good. Hope this helps!

2
  • 2
    As of 1.13 they completely changed commands, so I still use 1.12. Any chance you know how to do it in 1.12? I'll see if these work in 1.12, I think the only difference is Execute format. Anyways thanks, I didn't know picked_up was an objective.
    – Aceplante
    Commented May 12, 2020 at 13:01
  • @Aceplante commands have become so much easier and more powerful in 1.13 and above. This problem actually becomes almost trivial in 1.13 as described in this answer.
    – MBraedley
    Commented May 20, 2020 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.