Minecraft – How to track which blocks players step on the most in Minecraft

minecraft-commandsminecraft-java-edition

Is it possible to make a tracker of which blocks players step on the most time? By which blocks I mean the type of block (grass, sand, etc.). I had a nice idea – a survival map where you have to step on some type of block the most to win.

P.S.: I don't want to use mods.

Best Answer

Use pairs of one Repeat and one Chain Command block, one pair for each type of block (or for smaller numbers use good ol' Redstone clocks).

The repeat command block will test if there is a specific block one block under the Player:

/execute @e ~ ~ ~ testforblock ~ ~-1 ~ minecraft:YOUR-BLOCK-ID

And the chain one will add one to your scoreboard:

/scoreboard players add @a YOUR-BLOCK-ID 1

Note:
First you want to create the objective(s) and make them visible:

/scoreboard objectives add YOUR-BLOCK-ID dummy

/scoreboard objectives setdisplay sidebar YOUR-BLOCK-ID

And you want to create one objective for each block you step on frequently: grass, dirt, stone, cobble, wood logs, stairs, slabs and planks, netherrack, farmland, gravel, sand, air, water, …


Example:

First, create the objective:

/scoreboard objectives add dirt dummy

And make it visible:

/scoreboard objectives setdisplay sidebar dirt

Then, in a repeat command block, put this command:

/execute @a ~ ~ ~ testforblock ~ ~-1 ~ minecraft:dirt

And if it returnes true, execute this command:

/scoreboard players add @a dirt 1

Now, for each tick you step ( = are above) on one of the blocks you chose to put into your system, it's score on the left of your screen goes up. The blocks with the highest scores go up in the sidebar list.

You can also use good old comparators and redstone clocks to avoid numbers like Dirt: 8294, Grass: 34890