So basically I am trying to make a one-command-creation, which is where you have an entire project inside one long command.

I already asked a question on here which explains how the one command works, so you can have a look at my previous question to see that.

My long command makes a box, in which tons of command blocks go, which in turn makes everything work. One of my command blocks in there has a specific bit that needs either single quotes ('example') or double quotes with escape codes ("example").

The problem is, the long command needs it to be double quotes, nothing else. If I use double quotes, the long command works but the command block in the box doesn't, and vice versa.

The last thing I have tried to do is put the escape codes (the backslashes), which, in theory, would make it work, but, in practice, the long command treats it as escape code for itself rather than for the command block.

So I'd appreciate if someone could tell me how I can use escape codes and make it use them in the command block (hopefully you know what I mean), or come up with a solution to the original problem, or just give me an entirelly different way to get around it.

Here's the entire command:

summon falling_block ~ ~1 ~ {Time:1,BlockState:{Name:redstone_block},Passengers:[{id:armor_stand,Health:0,Passengers:[{id:falling_block,Time:1,BlockState:{Name:activator_rail},Passengers:[{id:command_block_minecart,Command:'gamerule commandBlockOutput false'},{id:command_block_minecart,Command:'data merge block ~ ~-2 ~ {auto:0}'},{id:command_block_minecart,Command:'fill ~3 ~-1 ~2 ~8 ~6 ~-2 gray_stained_glass hollow'},{id:command_block_minecart,Command:'fill ~3 ~-1 ~2 ~8 ~-1 ~-2 smooth_stone_slab[type=top]'},{id:command_block_minecart,Command:'playsound block.piston.extend ambient @a'},{id:command_block_minecart,Command:'fill ~3 ~6 ~2 ~8 ~6 ~-2 smooth_stone_slab[type=bottom]'},{id:command_block_minecart,Command:'setblock ~4 ~ ~-1 repeating_command_block[facing=east]{Command:"tag @e[nbt={OnGround:1b,Item:{id:\\"iron_block\\",Count:4b}}] add irondoor1"}'},{id:command_block_minecart,Command:'data merge block ~4 ~ ~-1 {auto:1b}'},{id:command_block_minecart,Command:'setblock ~5 ~ ~-1 chain_command_block[facing=east]{Command:"tag @e[nbt={OnGround:1b,Item:{id:\\"sticky_piston\\",Count:2b}}] add irondoor2"}'},{id:command_block_minecart,Command:'data merge block ~5 ~ ~-1 {auto:1b}'},{id:command_block_minecart,Command:'setblock ~6 ~ ~-1 chain_command_block[facing=east]{Command:"execute at @e[tag=irondoor1] as @e[tag=irondoor2,distance=..1] run summon item ~ ~ ~ {Tags:[\\"itemkill1\\",\\"IronDoorSpawn\\"],PickupDelay:20,Item:{id:\\"minecraft:stray_spawn_egg\\",Count:1b,tag:{display:{Name:\\"{\\"text\\":\\"2 x 2 Iron Door\\"}\\"},HideFlags:1,EntityTag:{id:\\"minecraft:silverfish\\",NoAI:1b,NoGravity:1b,PersistenceRequired:1b,Silent:1b,Health:0}}}}"}'},{id:command_block_minecart,Command:'data merge block ~6 ~ ~-1 {auto:1b}'},{id:command_block_minecart,Command:'setblock ~ ~1 ~ command_block{auto:1,Command:"fill ~ ~ ~ ~ ~-2 ~ air"}'},{id:command_block_minecart,Command:'kill @e[type=command_block_minecart,distance=..1]'}]}]}]}

but this part is all you need to work it out:

{id:command_block_minecart,Command:'setblock ~6 ~ ~-1 chain_command_block[facing=east]{Command:"execute at @e[tag=irondoor1] as @e[tag=irondoor2,distance=..1] run summon item ~ ~ ~ {Tags:[\\"itemkill1\\",\\"IronDoorSpawn\\"],PickupDelay:20,Item:{id:\\"minecraft:stray_spawn_egg\\",Count:1b,tag:{display:{Name:\\"{\\"text\\":\\"2 x 2 Iron Door\\"}\\"},HideFlags:1,EntityTag:{id:\\"minecraft:silverfish\\",NoAI:1b,NoGravity:1b,PersistenceRequired:1b,Silent:1b,Health:0}}}}"}'}

Thanks in advance.

  • You are getting into a big mess of escaping. The further in you go, the more backslashes you require. Finding the correct number of backslashes is a tedious process. – ExpertCoder14 Apr 19 at 19:07

Again, let's work backwards from the innermost later:


You then want to put it inside a double-quoted string, so I've placed a \ in front of each " in the bold area:

execute at @e[tag=irondoor1] as @e[tag=irondoor2,distance=..1] run summon item ~ ~ ~ {Tags:["itemkill1","IronDoorSpawn"],PickupDelay:20,Item:{id:"minecraft:stray_spawn_egg",Count:1b,tag:{display:{Name:"{\"text\":\"2 x 2 Iron Door\"}"},HideFlags:1,EntityTag:{id:"minecraft:silverfish",NoAI:1b,NoGravity:1b,PersistenceRequired:1b,Silent:1b,Health:0}}}}

You then want to put all of that inside another double-quoted string. The bold section below is the entire above command. To insert it into this, you replace all \ with \\ and all " with \":

setblock ~6 ~ ~-1 chain_command_block[facing=east]{Command:"execute at @e[tag=irondoor1] as @e[tag=irondoor2,distance=..1] run summon item ~ ~ ~ {Tags:[\"itemkill1\",\"IronDoorSpawn\"],PickupDelay:20,Item:{id:\"minecraft:stray_spawn_egg\",Count:1b,tag:{display:{Name:\"{\\\"text\\\":\\\"2 x 2 Iron Door\\\"}\"},HideFlags:1,EntityTag:{id:\"minecraft:silverfish\",NoAI:1b,NoGravity:1b,PersistenceRequired:1b,Silent:1b,Health:0}}}}"}

Finally, you want to place all of that inside a single-quoted string. This means you still need to replace all \ with \\ and all ' with \', but luckily you don't have any single quotes so far. The bold section below is your entire code, with the above part inserted in bold:

{id:command_block_minecart,Command:'setblock ~6 ~ ~-1 chain_command_block[facing=east]{Command:"execute at @e[tag=irondoor1] as @e[tag=irondoor2,distance=..1] run summon item ~ ~ ~ {Tags:[\\"itemkill1\\",\\"IronDoorSpawn\\"],PickupDelay:20,Item:{id:\\"minecraft:stray_spawn_egg\\",Count:1b,tag:{display:{Name:\\"{\\\\\\"text\\\\\\":\\\\\\"2 x 2 Iron Door\\\\\\"}\\"},HideFlags:1,EntityTag:{id:\\"minecraft:silverfish\\",NoAI:1b,NoGravity:1b,PersistenceRequired:1b,Silent:1b,Health:0}}}}"}'}

If my calculations are correct, you need six backslashes on your JSON text indeed.

(By the way, if you want that 2x2 thing to have the actual multiplication sign(2×2), you can replace it with \\\\\\\\\\\\u00d7. But that's another story.

If something is wrong, you can look through my workings above to find errors if needed

  • Lol, it's you again! You really are an expert coder. And an expert editor. I did have a lot of doubts about whether people would understand what I was trying to say since I'm not great at explaining. I'm not a beginner at commands but also not an expert, so thanks a lot. So, WOW that's confusing to me, but I understand it. I think what got me is that you have jumped from 1 backslash to 2 of them to 6 of them. I was going in an orderly fashion doing 3 of them, could you explain why you've done this? Either way, thanks so much. Again. – TotallyNotTeo Apr 20 at 19:33
  • @TotallyNotTeo Thanks for that. Every time you move up a layer, you have to double the current number of backslashes in each location. It's confusing, I know. – ExpertCoder14 Apr 20 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.