I am using version 1.8.9.

So I used this command:

/setblock ~ ~6 ~ air 0 replace end_portal

And it worked perfectly fine, but when I swapped the two blocks with this command,

/setblock ~ ~6 ~ end_portal 0 replace air

It didn't work, and displayed the error:

Data tag parsing failed invalid tag encountered expected '{' as first char.

Does anyone know what is causing this?


setblock cannot replace specific blocks like that; only fill can. Putting replace in a setblock command just tells the command not to drop any items from the replaced block. Your first command appears to be working, but it's actually ignoring the end_portal bit completely. It'd set any block to air: dirt, stone, anything.

The correct syntax for the setblock command is
/setblock <x> <y> <z> <block> [dataValue|state] [oldBlockHandling] [dataTag]

So your original command,
/setblock ~ ~6 ~ air 0 replace end_portal should reasonably fail for two reasons:

  1. The air block does not support NBT
  2. end_portal not valid NBT data

What actually happens is that Minecraft says, "Well, air doesn't support NBT, so I'll just ignore this bit that should be NBT." Your command, therefore, is equivalent to
/setblock ~ ~6 ~ air 0 replace

But with your second command, Minecraft says "The end_portal block does support NBT, so let's parse this--hey! This isn't valid NBT!" and throws an error.

If you're using command blocks, you can test for the air block explicitly, and then only set the end portal if the test succeeded:

   /testforblock <x> <y> <z> air
C: /setblock <x> <y> <z> end_portal

Where C: indicates a conditional command block.

  • 1
    Alternatively you could just fill one block: /fill ~ ~6 ~ ~ ~6 ~ air 0 replace end_portal Aug 24 '17 at 8:35

Or just use /fill ~ ~-6 ~ ~ ~-6 ~ fill only that one block

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.