PT-BR EN ES
Channel Icon

Crazy Ozz

Official Channel Website

Command Block

How to Create a Clickable Magic Book That Runs Commands in Minecraft

Minecraft Java 1.21+ and 26+ – Written Book Click Event (run_command)

Want to create a clickable command book in Minecraft that runs commands instantly? In this tutorial, you’ll learn how to make a written_book with a click_event using run_command, allowing you to build teleport menus, gamemode selectors, RPG systems, and interactive GUIs. Works in Minecraft Java Edition 1.21+ and newer versions like 26+.

Let's start with a simple magic book that runs only 1 command, see below

Command for version 1.21.5+ and 26+

give @p written_book[written_book_content={pages:[{text:"Test",color:"dark_blue",click_event:{action:"run_command",command:"tellraw @s Test"}}],title:"Magic Book",author:Anonymous}]

Now, let's use a more complex command, with 3 embedded commands for teleporting and changing gamemode

Command for version 1.21.5+ and 26+

give @p written_book[written_book_content={pages:[["",{text:"Gamemodes:",color:"black"},{text:"\n"},{text:"Survival",bold:true,color:"red",click_event:{action:"run_command",command:"gamemode survival @s"}},{text:"\n"},{text:"Creative",bold:true,color:"dark_green",click_event:{action:"run_command",command:"gamemode creative @s"}},{text:"\n"},{text:"Others:",color:"black"},{text:"\n"},{text:"Teleport",bold:true,color:"dark_blue",click_event:{action:"run_command",command:"teleport @s 64 22 -890 90 0"}}]],title:"Magic Book",author:Anonymous}]

Notice that we always have a custom {text} with some parameters like text color, bold, and command execution

Following this logic, you can add more text and commands just by adding a comma after a {text}, and each page is represented by [ ]

NOTE: {text:"\n"} is used to move to the next line

Now here is the command for versions older than 1.21.5, and it can even work for 1.20.4

Book with 1 command

give @p written_book[written_book_content={pages:["{\"text\":\"Test\",\"color\":\"dark_blue\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"tellraw @s Test\"}}"],title:"Magic Book",author:Anonymous}]

Book with 3 commands

give @p written_book[written_book_content={pages:["[\"\",{\"text\":\"Gamemodes:\",\"color\":\"black\"},{\"text\":\"\\n\"},{\"text\":\"Survival\",\"bold\":true,\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"gamemode survival @s\"}},{\"text\":\"\\n\"},{\"text\":\"Creative\",\"bold\":true,\"color\":\"dark_green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"gamemode creative @s\"}},{\"text\":\"\\n\"},{\"text\":\"Others:\",\"color\":\"black\"},{\"text\":\"\\n\"},{\"text\":\"Teleport\",\"bold\":true,\"color\":\"dark_blue\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"teleport @s 62 21 -885 90\"}}]"],title:"Magic Book",author:Anonymous}]

Want cheap and lag-free Minecraft hosting?

I recommend Sparked Host: affordable plans, great performance, easy panel and fast support.

🚀 Start your Minecraft Server

Still have questions? Watch the video below