I am building a map in Minecraft (Java Edition). How do we make it so that if a player touches or lands on a specific block a title will appear on the screen? For example /title @p title {"text":"Level 2","color":"red"}
. I want this to happen upon touching a block. But I want it to run once and never again, unless the player touches a red carpet or quarts. This is what I want: a repeating system, basically a touching block system on touching a block, a title will appear and never again, but on touching another block the system will reset and we can touch that same block again. Please tell me how to make this possible.
Make a title appear on a player screen on touching a block
minecraft-commandsminecraft-java-edition
Best Answer
Since it wasn't clear what "Touching" a block means, I choose "Land on" as the solution
First, let us create a scoreboard to track which was the last stepped on block
Here is the first command, let us call it [If statement], just to reference it later in this answer.
Where [@a] is the players you want to target (You can learn more about target selector here), [last_stepped] is the name of the scoreboard we created before, [N] is the ID we gave the block (We will choose an ID for each block later, this isn't any ingame actual ID), [YourBlock] is the block he has to stepon, and [Result] is our [/title] command or our [/scoreboard set] (Shown later).
This translates to "Execute as every player, if the block right bellow each player (Here, @s refers to self, or each player previously targeted, in this case, by the [as @a]) is [YourBlock], unless the last stepped block is the one we are looking for now, if so, run [Result] for each player"
(In case you are not familiar with command blocks) Set each command block as the following:
For each block you want to track, we will need two [Results]:
Let me leave two examples here:
For the use of the OP: