Can someone please help me fix this command?

/setblock -10 15 -42 command_block 0 replace {Command:"/testfor @p[r=7] {Inventory:[{id:"minecraft:magma_cream"}]}"}

  • 1
    What's wrong with it? Which error are you getting while running it? Jan 21 '17 at 16:52

The problem here is that Minecraft will read the Command string as:

Command:"/testfor @p[r=7] {Inventory:[{id:"

The first " starts the string where you want to start it, but then the next " ends it early.

To stop quotation marks from ending a string, you can escape them by putting a \ in front, like this:

{Command:"/testfor @p[r=7] {Inventory:[{id:\"minecraft:magma_cream\"}]}"}

Alternatively, in this situation but not always, you could leave out one or both pairs of quotation marks:

{Command:"/testfor @p[r=7] {Inventory:[{id:minecraft:magma_cream}]}"}
{Command:/testfor @p[r=7] {Inventory:[{id:"minecraft:magma_cream"}]}}
{Command:/testfor @p[r=7] {Inventory:[{id:minecraft:magma_cream}]}}

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