Minecraft – How to set the players “tame” score to 1 if they tame a wolf

minecraft-commandsminecraft-java-edition

I'm making a map and I need to give the player +1 for taming a wolf but I don't know the command. All I know is /scoreboard objectives add tame {part I don't know}. Then some command block that gives them the point. Then maybe testfor @p[score=tame=1].

All the commands I tried are:

  • testfor @p[team=start]
  • scoreboard objectives add tame{I don't know}
  • scoreboard players set @p{I don't know}

Best Answer

This solution is based on defining the person closest to a wolf when it first sits down as it's tamer.

The reason for this workaround is twofold:

  • Players don't have a "wolves tamed" statistic
  • Wolves don't have a "tamed" entry in their NBT, and it's not possible to look for an empty "ownerUUID"

Start with the following commands.

/scoreboard objective add isTamed dummy
/scoreboard objective add wolvesTamed dummy Wolves Tamed

This will add an objective that is used to check for tamed wolves, and another for the players.

Now run the following commands on a clock

/scoreboard players add @e[type=Wolf] isTamed 1 {Sitting:1}
/scoreboard players add @e[type=Wolf,score_isTamed_min=3] isTamed -1
/execute @e[type=Wolf,score_isTamed=1,score_isTamed_min=1] scoreboard players add @p[r=3] wolvesTamed 1 

This will continuously increase the isTamed objective by 1 as long as the wolf sits. This is followed by decreasing it by one if it is greater than 2 (this is not technically necessary, but keeps the scores low)

In addition, the player closest to a wolf (and within 3m) with an isTamed score of exactly 1 (which can only happen when it first sits down) will have their wolvesTamed score increased by 1.

There might be an issue with the last command, because wolves might not be able to use "cheats". In this case, you would need to find a way to use the /trigger command instead.