117: Allowing players to change the Sidebar statistic. [Minecraft Map Making]

Subscribers:
3,920
Published on ● Video Link: https://www.youtube.com/watch?v=2DrjummhfVg



Minecraft
Game:
Minecraft (2011)
Duration: 21:10
138 views
18


Ep117: A few ways to allow players to change which statistic is displayed on the sidebar, some which we charge them a diamond for, and one using a trigger.

Java Version: 1.19

Commands, builds and ideas for people making their own Minecraft maps.

Check out my collabs on Coppit's channel: https://www.youtube.com/c/CoppitJ

Join the server I play on and the Discord where I hang out.
Server IP: 51.81.246.145:25588
Discord: https://discord.gg/KNSmPWdnfG

The following commands are prefixed with three letters which represent the settings of the command block. E.g IUN: = Impulse Unconditional Needs_Redstone. These prefixes need to be removed if copying the commands.

Commands used: YouTube formatting may make some of these wrong. :)

Create the objectives:
IUN: scoreboard objectives add distanceWalked minecraft.custom:minecraft.walk_one_cm "Distance Walked"
CUA: scoreboard objectives add distanceRan minecraft.custom:minecraft.sprint_one_cm "Distance Ran"
CUA: scoreboard objectives add showWalk trigger
CUA: scoreboard players enable @a showWalk

Reset the Sidebar@
scoreboard objectives setdisplay sidebar



Check a chest for one diamond and remove one if there: [Stacks of more than one won't be detected.]
IUN: execute if data block ~-2 ~-1 ~ Items[{id:"minecraft:diamond",Count:1b}] run data remove block ~-2 ~-1 ~ Items[{id:"minecraft:diamond",Count:1b}]
Display the objective if a diamond is found.
CCA: scoreboard objectives setdisplay sidebar distanceWalked



Display message to the player:
IUN: tellraw @p [{"text":"[","color":"dark_gray"},{"text":"Server","color":"gray"},{"text":"] ","color":"dark_gray"},{"text":"Switch to viewing Distance Walked statistic?", "color":"gray"}]
Display clickable text to the player:
CUA: tellraw @p [{"text":"Yes. ","color":"green","clickEvent":{"action":"run_command","value":"/setblock 62 56 -25 redstone_block replace"}},{"text":"This will take 1 diamond from your inventory!","color":"gray"}]

Clear a diamond from the player:
IUN: clear @p diamond 1
Display the objective:
CCA: scoreboard objectives setdisplay sidebar distanceWalked
Display message if player has no diamonds:
CUA: execute if block ~-2 ~ ~ command_block{SuccessCount:0} run tellraw @p
[{"text":"[","color":"dark_gray"},{"text":"Server","color":"gray"},{"text":"] ","color":"dark_gray"},{"text":"You need a diamond in your inventory to do this!", "color":"gray"}]



Set players showWalk trigger:
IUN: scoreboard players set @p showWalk 1

Detect trigger:
RUA: execute as @p[scores={showWalk=1..}] run setblock ~2 ~ ~ redstone_block replace

Reset the Redstone_Block:
IUN: setblock ~ ~1 ~ white_wool
Reset the players showWalk score:
IUN: execute as @a[scores={showWalk=1..}] run scoreboard players set @s showWalk 0
Enable the trigger:
CAU: scoreboard players enable @a showWalk
Display the objective:
CAU: scoreboard objectives setdisplay sidebar distanceWalked







Tags:
minecraft
adventure map
map making
commands
command blocks
1.18
custom commands
redstone
map ideas
map suggesstions
custom maps
1.19



Other Statistics

Minecraft Statistics For Infernal Device

At present, Infernal Device has 182,939 views spread across 869 videos for Minecraft, accounting for over 10 days of watchable video on his channel. This is 94.82% of the total watchable video for Minecraft on Infernal Device's YouTube channel.