Disclaimer
The section symbol is deprecated. You should avoid using it as much as possible and be aware that it will not work in the future. It is being replaced by the JSON text component, which is already supported by chat (accessible with /tellraw
), book pages, sign text, and the /title
command.
In-game with signs
Because sign text supports the text component, it also supports unicode characters (declared as \u####
). The character for the section symbol is \u00A7
.
You would use the sign to run a clickEvent that provides you with a command block that uses the section symbol at the appropriate location in its syntax. You'd then place the command block where needed.
Note that this will only work for signs because it's the sign running the command, rather than the player being forced the run the command in the chat like with /tellraw
or book pages. The player would otherwise be kicked for trying to type the section symbol.
Example command:
/setblock ~ ~1 ~ minecraft:standing_sign 0 replace {Text1:"[\"\"]",Text2:"[\"\"]",Text3:"[\"\"]",Text4:"{\"text\":\"Click\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/give @p minecraft:command_block 1 0 {BlockEntityTag:{Command:/summon Item ~ ~1 ~ {Item:{id:\\\"minecraft:stone\\\",Count:1b,tag:{display:{Name:\\\"\u00A71Custom Name\\\"}}}}}}\"}}"}
Using loot tables
A custom loot table can be created to provide you with a command block containing the section symbol, which can be pasted into the JSON file directly.
For example, the following would provide the necessary command block that you'd place where desired:
{
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "item",
"name": "minecraft:command_block",
"weight": 1,
"functions": [
{
"function": "minecraft:set_nbt",
"tag": "{BlockEntityTag:{Command:/summon Item ~ ~1 ~ {Item:{id:\"minecraft:stone\",Count:1b,tag:{display:{Name:\"ยง1Custom Name\"}}}}}}"
}
]
}
]
}
]
}
The command to place the chest containing the command block (assuming filepath world_name/data/loot_tables/custom/cmd.json
):
/setblock ~ ~1 ~ minecraft:chest 0 replace {LootTable:"custom:cmd"}
You can modify the command block that contains the /summon
command using either of these programs to contain the section symbol at the desired spot in its syntax.
Using MCEdit, you'd locate the command block, double-click it, and paste the section symbol and color code within the command itself.
With NBTExplorer, you would need to locate the command block first by copy/pasting into the program's Search tool. You would then double-click the Command
value and paste the section symbol at the appropriate location.
You need to add more escape characters to deeper-nested quotation marks. You open the Text1
tag with a "
, thus the very next "
character closes it. You open the value
tag for the click event with \"
, meaning the next \"
you use will close it, which occurs in your nested /give
command's NBT data (specifically just after the Name
tag). That it what's causing your issue.
The formula to determine the number of backslashes required is: 2n+1
, where n
is the number of current backslashes. For the nested NBT data, you need 3 backslashes per quotation mark (\\\"
).
Fixed command:
/give @p sign 1 0 {BlockEntityTag:{Text1:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true,\"clickEvent\":{\"action\":\"run_command\",\"value\":\"clear @p[name=rainbowlack,r=3] cactus 0 2304\"}}",Text2:"{\"text\":\"2304 Cacti\",\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"give @p[name=rainbowlack,r=3] minecraft:cookie 18 0 {display:{Name:\\\"$100 Cookie\\\",Lore:[$100]}}\"}}",Text3:"{\"text\":\"iIiIiIi\",\"color\":\"light_purple\",\"strikethrough\":true,\"obfuscated\":true}",Text4:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true}"},display:{Name:"Custom Sign"}}
Best Answer
What to use
It is common to use
/blockdata
for changing placed sign data. So, we will use it for now. The syntax of/blockdata
is/blockdata [x] [y] [z] [dataInJSON]
. Note that we use JSON formatting for text.Basic for sign
To input a text with
/blockdata
, we will useText1
tag. To write "Hello World" into the first line of the sign, simply just do/blockdata [x] [y] [z] {Text1:"{\"text\":\"Hello World\"}"}
. The quotes is there for JSON formatting. If you need multiple line to display, use eitherText2
,Text3
orText4
.Coloring
There is a way to change color of the sign using the
color
sub tag. There is a lot selection of color. Here is all of the available one:For writing "Hello World" in aqua, you write
/blockdata [x] [y] [z] {Text1:"{\"text\":\"Hello World\",\"color\":\"aqua\"}"}
into a command block. It will change the sign with the first line saying "Hello World" on aqua.
Bold
For bold text, you use
bold
sub-tag. This sub-tag is a boolean, meaning the value can be onlytrue
orfalse
for example:/blockdata [x] [y] [z] {Text1:"{\"text\":\"Hello World\",\"bold\":true}"}
will give you a sign with text "Hello World" with bold.
The real answer
Type this into a command block changing [x], [y], and [z] into the coords of the sign:
/blockdata [x] [y] [z] {Text1:"{\"text\":\"Place Block\",\"color\":\"dark_blue\",\"bold\":true}"}
Full list for Raw JSON tags