How to setblock a command block with a /summon command? [duplicate]

How to setblock a command block with a /summon command? [duplicate] - Unrecognizable woman holding paw of dog

I'm trying to make a one command creation, so I need a /setblock command to set a command block with a /summon command. This is the command I'm using:

/setblock ~ ~1 ~ minecraft:command_block 4 replace {auto:0b,powered:0b,conditionMet:0b,Command:"/execute @e[type=Wolf,name=MiniMe] ~ ~ ~ /summon Wolf ~ ~ ~ {Owner:PLAYER_NAME,CustomName:"Mini"}",TrackOutput:0}

It keeps saying:

"Data tag parsing failed: Unexpected token 'M' at: Mini"}",TrackOutput:0"

When I use the /summon command normally it works fine! Please help.



Best Answer

The first quotation mark you use opens the string, and thus the very next un-escaped quotation mark will close it, which happens for your CustomName value. In order to avoid using a quotation mark to close the string, you must escape it by prepending it with a backslash (\").

If you need to use more quotation marks as part of the value at a deeper nesting within quotation marks, you'd need to apply more backslashes. The equation for the number of backslashes is 2n+1 where n is the current number of backslashes. For example, if you need quotation marks within an already-escaped set of quotation marks that have 1 backslash, you would need 2*1+1 backslashes (3).

Fixed command applying the backslash:

/setblock ~ ~1 ~ minecraft:command_block 4 replace {auto:0b,powered:0b,conditionMet:0b,Command:"/execute @e[type=Wolf,name=MiniMe] ~ ~ ~ /summon Wolf ~ ~ ~ {Owner:PLAYER_NAME,CustomName:\"Mini\"}",TrackOutput:0}



Pictures about "How to setblock a command block with a /summon command? [duplicate]"

How to setblock a command block with a /summon command? [duplicate] - Crop hacker silhouette typing on computer keyboard while hacking system
How to setblock a command block with a /summon command? [duplicate] - Side view of young woman in hoodie sitting on floor near sofa and playing with obedient brown Labrador while resting during free time
How to setblock a command block with a /summon command? [duplicate] - Full body optimistic young female with curly hair smiling and teaching Beagle dog beg command on sunny summer day in countryside



How do you summon a repeated command block?

To get a repeating command block, players must use the /give command like so: /give @p minecraft:repeating_command_block <amount> . Players can also change a normal command block into a repeating command block by selecting the option in the command block GUI.

How do you get a command block to repeat mobs to spawn?

To copy the entirety of a certain Command block or Text press Ctrl+A to select it all then Ctrl+C to copy it. Might be quicker than pressing shift and going over 280 characters. Oh and after you hit Ctrl+A you can use shift+Left or Right Arrow Key to adjust what is selected.



Using Commands in Minecraft: How to Use /setblock \u0026 /fill to Alter Terrain! | 1.11.2




More answers regarding how to setblock a command block with a /summon command? [duplicate]

Answer 2

The problem is, that you are basically closing the command that would go into the command block with the " preceding Mini. Since you don't have any spaces in the custom name you can do this:

/setblock ~ ~1 ~ minecraft:command_block 4 replace {auto:0b,powered:0b,conditionMet:0b,Command:"/execute @e[type=Wolf,name=MiniMe] ~ ~ ~ /summon Wolf ~ ~ ~ {Owner:PLAYER_NAME,CustomName:Mini}",TrackOutput:0}

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Ivan Babydov, Anete Lusina, Ivan Babydov, Blue Bird