Minecraft – ny way to make scoreboard objectives Universal

minecraft-commandsminecraft-java-edition

[1.10.2]

So I am making an adventure map and I made a money system that is a little bit glitchy. Basically, it works like this:

So first I would like to point out my scoreboard objectives:

  • money > Dummy

  • killedBasic > stat.killEntity.Zombie

And I have one repeating command block (Always Active) with the following command:

/testfor @a[score_killedBasic_min=1]

And I have two comparators wired out of the repeating command block as so:

Full command block setup

The "Resets killedBasic" command block has this command:

/scoreboard players set @a killedBasic 0 

And the "Adds 10 to money" command block has the following command:

/scoreboard players add @a money 10

The system itself works fine but I noticed that if say there were two players on the adventure map then if one killed a Zombie they would both get 10 "money" which looked messy.

So my question is (yeah tl;dr I know) is it possible to maybe a scoreboard operate on its own without a player name beside the score? And also is it possible to use renamed entity's such as rabbits to add the score (money) to the scoreboard?

Best Answer

You don't have to use a selector for a playerscore. You can use any name you want, even if it's not a valid player's name. For instance, the following sets the score of a fake player named "pool":

/scoreboard players add pool money 10

Do keep in mind that if a player named "pool" joins, they will essentially "own" that score. You'd want to be careful when manipulating the scores in case their existence causes a conflict (such as running /scoreboard players add @a money 10). If you prepend the name with "#" (such as "#pool"), the name will not appear on the sidebar and also prevents naming conflicts because real players cannot have the "#" character in their name.


As for your mechanism, you'll want to use Chain command blocks, which directly specifies activation order, instead of comparators, which does not have a guaranteed activation order and causes delay. The delay can cause the mechanism to lock up if a player kills a zombie before the comparator turns off.

/testfor is not particularly useful, especially in multiplayer situations. You can replace it with a scoreboard operation that would account for multiple kills in the same tick, rather than assuming there is only 1 kill amongst all players.

Image example of the mechanism:

Repeating Block (1) > Chain Block (2)

Commands:

  1. Increment the fake "#pool" player's score equal to all playerscores for the "killedBasic" objective (or change "#pool" to a name you would prefer, removing "#" so that it appears on the sidebar).

    /scoreboard players operation #pool money += @a[score_killedBasic_min=1] killedBasic
    
  2. Set playerscores for "killedBasic" to 0 like usual.

    /scoreboard players set @a[score_killedBasic_min=1] killedBasic 0
    

This is a multiplayer-friendly and multi-kill friendly solution that will not lock up if multiple kills are made in subsequent ticks.