Minecraft – Scoreboard system for an invisible maze in Minecraft

minecraft-commandsminecraft-java-edition

So this might be confusing, but I'll try to explain the best I can.

I made an invisible maze (using barrier blocks) in Minecraft. I want to set up a score system that tracks the number of steps (using the "walkOneCm" stat) it takes a player to get to the end. I can set up the objective to track the steps and display them in the sidebar.

The only problem is it tracks all of the steps any player takes and I only want it to track people in the maze (it's circular with a radius of 16). I'm relatively sure this is doable, I just don't know how to target those players inside that circle.

Am I SOL or is this possible?

Best Answer

You could reset that stat objective for anyone not within that radius. You would use a target selector with the radius minimum argument. I recommend putting the command block in the spawn chunk as it will never unload.

Command block is Repeat Unconditional Always Active with command:

scoreboard players reset @a[x=X,y=Y,z=Z,rm=16] [objective]

Where X, Y, and Z are the center of the maze and [objective] is the name of your stat objective.

The only problem with doing it this way is the sidebar display will blink on and off for the players outside the maze when they walk as the stat will increase and then be reset.

You could also set their score to 0 instead of resetting their score. This would prevent the sidebar display from blinking but players outside the maze would still see the sidebar.