-1

I have a command block with a command similar to this below, and it works fine.

/testfor @p[r=10] {Inventory:[{id:"minecraft:emerald",Count:1b}]}

When trying to use a command block to replace it with another one, I get syntax errors about uneven quotations.

The goal here is to trigger a comparator, and then reset it.

Any help is appreciated. Thanks!

  • 1
    Could you paste the command that you're getting the error on? – SirBenet Dec 16 '16 at 0:51
0

Try this command, assuming you're standing one block above the command block you want to replace:

/setblock ~ ~-1 ~ minecraft:command_block 0 {Command:""}

You probably want to make the old command block come back, and this is the command to do it.

/setblock ~ ~-1 ~ minecraft:command_block 0 {Command:"/setblock ~ ~ ~ minecraft:command_block 0 {Command:\"/testfor @p[r=10] {Inventory:[{id:"minecraft:emerald",Count:1b}]}\"}"}
  • I do want to make the old one come back. The second command doesn't work though. I get the error: "Data tag parsing failed: Invalid tag encountered, expected '{' as first char. – Brolovis Dec 16 '16 at 3:51
  • @Brolovis Can you share the command you were using before to reset the command block? – haykam Dec 16 '16 at 11:32
  • I'm new to command blocks, so it's just an edited version of a command I found off a youtube video, meant to spawn in a command block with a command. – Brolovis Dec 16 '16 at 15:53
  • /setblock ~ ~ ~-4 command_block 1 3 {Command:"/testfor @p[r=10] {Inventory:[{id:minecraft:emerald,Count:1b}"]} Original command from the video was /setblock ~ ~ ~ command_block 1 3 {Command:"/testfor @p[r=3]"} which works on its own. – Brolovis Dec 16 '16 at 15:54
  • 1
    After more searching and testing I found the command "/blockdata ~ ~ ~-4 {SuccessCount:0}" which serves my purpose in resetting a comparator, so I no longer need to replace the entire command block. Thanks for the help. – Brolovis Dec 16 '16 at 16:19

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.