Minecraft – How to make a clickable signs set a block

minecraft-commandsminecraft-java-edition

I made a command where there is a clickable sign that teleports a player to spawn. Here is the command:

/setblock ~ ~1 ~ minecraft:wall_sign 2 replace {Text1:"{text:\"Start\",clickEvent:{action:run_command,value:\"/tp @p[c=1] -658 104 -690\"}}"} 

How do I alter the command to setblock a redstone block?

I tried this:

/setblock ~ ~1 ~ minecraft:wall_sign 2 replace {Text1:"{\"text\":\"Set Gamemodes\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/setblock -44 110 248 152 delete\"}}"} 

but it didn't work. What am I doing wrong?

Best Answer

After 1.7, you can no longer refer to a block by its numeric Block ID; instead you must use its full name. Thus, you should replace 152 with redstone_block.

Also, with /setblock, you need to specify the [dataValue] before you can specify the [oldBlockHandling] mode, so you should add a 0 before delete.

Fixed command should look like:

/setblock ~ ~1 ~ minecraft:wall_sign 2 replace {Text1:"{\"text\":\"Set Gamemodes\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/setblock -44 110 248 redstone_block 0 delete\"}}"}

In situations like this where you're setting signs that execute commands or have nested execute commands, I often find it useful to "unwrap" it and try each layer of command separately.

For example, you can try the innermost command (/setblock -44 110 248 152 delete) in chat or a command block to get a somewhat useful message that can help you with fixing the first error:

There is no such block with name minecraft:152