I heard of two methods of using fake players and objectives

  1. Small amount of fake player and lots of objectives for example:
    #fakeplayer obj1, #fakeplayer obj2, #fakeplayer obj3, #fakeplayer obj4 etc
  1. Lots of fake players and a very small amount of objectives for example:
    #Variable1 temp, #Variable2 temp, #Variable3 temp, #Variable4 temp etc

Are either of these two methods more effective than the other, in terms of performance or other factors?

  • 4
    Which edition of Minecraft are you playing? – pppery Jun 12 at 14:10
  • If you just want to score constant numbers, the standard seems to be to name the scoreboard "const" and the fake players simply by their numbers, so for example: /scoreboard players set 42 const 42 Other than that, I would be interested to hear why you need so many fixed values that the performance matters. – Fabian Röling Sep 2 at 21:20

If I'm answering solely based on the examples you gave in your question, it doesn't really matter. Go with what is more readable to you.

However, for large projects, the second option with fake players is more programmatic and scalable. The way the game lays out player scores and objectives is more naturally inclined to have few objectives, but many players with various scores. I say this because creating an objective takes one command, and assigning a score to a player takes one command.

If we create variables using objectives and a single fake player, each new variable requires two commands: one to create the objective, one to assign the score. If we create variables using fake players, we need one command to create the objective, but every new variable only needs one command to assign the score. The command count alone is a slight performance benefit, and while I don't know how the code works specifically, the design of the objectives vs players would indicate more players is better than more objectives.

Additionally, you may find yourself wanting to use variables programmatically. It is easier to work with players as variables, because you can programmatically reference entities using tags in selectors. Objective names cannot be used programmatically because an exact string must be used every time. This does not apply to the exact examples in your question, but in most of my work I have to use selectors for programmatic access to variables.

| improve this answer | |
  • Thanks for explaining, I just ran into the limit of using just objectives on 1 fake player as soon as you answered, It should have been using more fake players from the start – Joe Jun 12 at 10:09

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