Can't replace block with a Command Block [duplicate]

Can't replace block with a Command Block [duplicate] - Blonde Girl in White T-shirt Leaning on White Block

I am making a Sell Shop, but I need to replace some things using /setblock.

For one of the replacements, I am using the command:

/setblock 579 62 1053 minecraft:command_block 0 replace {Command:"testfor @p {Inventory:[{id:"minecraft:log",Count:32b}]}",TrackOutput:0}

But it won't work! When I try it using a Command Block, I get this message:

[19:14:38]
Data tag parsing failed: Unexpected token 'm' at: minecraft:log",Count:32b}]}",TrackOutput:0

Is there any way I can fix this?



Best Answer

The first quotation mark for the Command string that you wrote will open the string. The very next un-escaped quotation mark will then close that string, which happens after the id tag.

To prevent a quotation mark from closing the string early, you must escape the character by applying a backslash before it.

/setblock 579 62 1053 minecraft:command_block 0 replace {Command:"testfor @p {Inventory:[{id:\"minecraft:log\",Count:32b}]}",TrackOutput:0}



Pictures about "Can't replace block with a Command Block [duplicate]"

Can't replace block with a Command Block [duplicate] - White shabby concrete wall with cracked stucco
Can't replace block with a Command Block [duplicate] - Assorted-color House Facade in Park
Can't replace block with a Command Block [duplicate] - Man in Black Jacket Sitting on Block



How do you replace a block with another block in Minecraft with commands?

In Minecraft, you can use the /fill command to replace a specific type of block with another.

Can you duplicate command blocks?

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.

How do you use command blocks to clone blocks?

Open the Chat menu and type clone [first coordinates] [second coordinates] [destination coordinates]. For example, you might type clone 302 3 2 300 1 0 ~ ~2 ~. Make sure your character is at least somewhat close to both the target that you're cloning and the destination where you're cloning it to.



CanBroke | WIR FAHREN IN DIE TÜRKEI




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

Images: Ruslan Alekso, Tatiana Syrikova, Pixabay, Lisa