Updated:
1. Lock the map
/gamemode adventure @a
/gamerule mob_griefing false
Adventure mode stops players breaking out. Use mobGriefing on 1.21.10 and earlier.
2. Key doors
/give @p minecraft:tripwire_hook[custom_name="Room Key",custom_data={key:1b}]
Hide the key in a chest. The door logic is in the key door commands.
3. Block puzzles
/give @p minecraft:redstone_block[can_place_on={blocks:"minecraft:gold_block"}]
It can only be placed on gold blocks, even in adventure mode, so the right spot powers a door.
4. Clickable hints
/tellraw @a {"text":"[Show hint]","color":"aqua","click_event":{"action":"run_command","command":"/trigger hint"}}
Uses the trigger command. On 1.21.4 and earlier write clickEvent with value.
5. Timer
/bossbar add escape "Time left"
/bossbar set escape max 6000
/bossbar set escape value 6000
/bossbar set escape players @a
A five-minute bar; count it down as in the bossbar command.
6. Exit check
execute as @a[x=20,y=64,z=0,dx=2,dy=3,dz=2,tag=!escaped] run tellraw @a [{"selector":"@s"},{"text":" escaped!","color":"gold"}]
tag @a[x=20,y=64,z=0,dx=2,dy=3,dz=2] add escaped
7. Show the hint text
/scoreboard objectives add hint trigger
/scoreboard players enable @a hint
# Repeating command block
execute as @a[scores={hint=1..}] run tellraw @s {"text":"Hint: look under the red carpet","color":"yellow"}
# Chain 1
scoreboard players set @a[scores={hint=1..}] hint 0
# Chain 2
scoreboard players enable @a hint
Clicking the hint in step 4 sets hint to 1 and only that player sees the text. The score goes back to 0 and is enabled again so the hint can be used once more. Add an area to the selector for a different hint per room. See the trigger command.
8. Time the escape (Java 1.21.11+)
/stopwatch create minecraft:escape
execute store result score @s escape_time run stopwatch query minecraft:escape 1
Create the stopwatch at the start and store the seconds when a player reaches the exit in step 6. Run /scoreboard objectives add escape_time dummy first. See the stopwatch command.
9. Reset for the next team
/tag @a remove escaped
/clear @a minecraft:tripwire_hook
/bossbar set escape value 6000
/tp @a 0 64 0
Clear the exit tag and keys, refill the timer and gather players at the start. To restore opened doors and placed blocks, save a copy of the room and paste it back with /clone.
Troubleshooting
- Blocks break: players must be in adventure mode.
- Puzzle block will not place: check the can_place_on block name.
- Hint click does nothing: run
/scoreboard players enable @a hint.
Check your command
The Command Error Doctor checks common syntax mistakes in your browser.