-2

Can someone please explain the /setblock command?

I want a command block to set a block if there is clay but not set a block if there is black wool. How do I do this?

1 Answer 1

2

The syntax for setblock is as follows:

/setblock <x> <y> <z> <blockName>

The setblock command can only be used for one block at a time. It cannot replace that block based on what it previously was.

Since your situation requires you to (presumably) fill more than one block, the /fill command would be more appropriate.

The syntax for filling only blocks of a certain type is as follows:

/fill [x1] [y1] [z1] [x2] [y2] [z2] [BlockToFill] 0 replace [BlockToBeReplaced]

So to replace all clay in the world, you would use this command:

/fill [x1] [y1] [z1] [x2] [y2] [z2] [BlockToFill] 0 replace minecraft:clay

Simply replace the x y z x2 y2 z2 values with the co-ordinates to fill, and [BlockToFill] with the ID of the block you wish to replace the clay with.

2
  • 1
    Might be worth noting that the 0 in your fill commands is the dataValue (damage value) of the block you set, which is important for filling with logs or wool.
    – MrLemon
    Commented Jul 1, 2015 at 11:02
  • ... until Minecraft 1.13, where that data value is removed, and logs and wool are entirely separate blocks.
    – pppery
    Commented Jul 12, 2019 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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