33

Block quotes are not the proper formatting tool for Minecraft commands. Instead, for large commands or a group of commands, we should be using code blocks. Why? Because Minecraft commands are code-like and not speech-like, and as such are not covered by the rule against using code formatting.

Instead of seeing this:

/summon ArmorStand ~ ~ ~10 {ShowArms:1,NoBasePlate:1,Pose:{LeftArm:[0f,0f0f],RightArm:[0f,0f,0f],Body:[0f,0f,0f],LeftLeg:[0f,0f,0f],RightLeg:[0f,0f,0f],Head:[0f,0f,0f]},ArmorItems:{id:diamond_boots,ench:[{id:protection,lvl:1000},{id:blast_protection,lvl:1000},{id:thorns,lvl:1000},{id:unbreaking,lvl:1000}]},{id:diamond_leggings,ench:[{id:protection,lvl:1000},{id:blast_protection,lvl:1000}, {id:thorns,lvl:1000},{id:unbreaking,lvl:1000}]}, {id:diamond_chestplate,ench:[{id:protection,lvl:1000},{id:blast_protection,lvl:1000},{id:thorns,lvl:1000},{id:unbreaking,lvl:1000}]},{id:diamond_helmet,ench:[{id:protection,lvl:1000},{id:blast_protection,lvl:1000},{id:thorns,lvl:1000},{id:unbreaking,lvl:1000}]}}

We should instead see this:

/summon ArmorStand ~ ~ ~10 {ShowArms:1,NoBasePlate:1,Pose:{LeftArm:[0f,0f0f],RightArm:[0f,0f,0f],Body:[0f,0f,0f],LeftLeg:[0f,0f,0f],RightLeg:[0f,0f,0f],Head:[0f,0f,0f]},ArmorItems:{id:diamond_boots,ench:[{id:protection,lvl:1000},{id:blast_protection,lvl:1000},{id:thorns,lvl:1000},{id:unbreaking,lvl:1000}]},{id:diamond_leggings,ench:[{id:protection,lvl:1000},{id:blast_protection,lvl:1000}, {id:thorns,lvl:1000},{id:unbreaking,lvl:1000}]}, {id:diamond_chestplate,ench:[{id:protection,lvl:1000},{id:blast_protection,lvl:1000},{id:thorns,lvl:1000},{id:unbreaking,lvl:1000}]},{id:diamond_helmet,ench:[{id:protection,lvl:1000},{id:blast_protection,lvl:1000},{id:thorns,lvl:1000},{id:unbreaking,lvl:1000}]}}

This example was taken from an edit that required approval. Not only was the block quote done incorrectly, but then two other people thought it was the right edit to make to begin with. (I'll note that, in this case at least, the approvers are not experts.) I have been seeing many edits like this over the past few weeks. I've further edited a few, but not all of them.

This, however, is just bastardizing a single long command. What happens when we have multiple commands, and at least one of them is long enough that it would wrap to the next line. This nicely formatted set of commands:

scoreboard players set @e[type=PrimedTnt] TNTGoBoom 1 {Fuse:0b}
execute @e[type=PrimedTnt,score_TNTGoBoom=1] ~ ~ ~ summon Fireball ~ ~ ~ {direction:[0.0,-1.0,0.0],ExplosionPower:4,Fuse:0,Time:-1,TileEntityData:{CustomName:"TNT"},ActiveEffects:[{Id:14,Duration:10,Amplifier:10,Ambient:1}]}
kill @e[type=PrimedTnt,score_TNTGoBoom=1]

becomes this:

scoreboard players set @e[type=PrimedTnt] TNTGoBoom 1 {Fuse:0b}
execute @e[type=PrimedTnt,score_TNTGoBoom=1] ~ ~ ~ summon Fireball ~ ~ ~ {direction:[0.0,-1.0,0.0],ExplosionPower:4,Fuse:0,Time:-1,TileEntityData:{CustomName:"TNT"},ActiveEffects:[{Id:14,Duration:10,Amplifier:10,Ambient:1}]}
kill @e[type=PrimedTnt,score_TNTGoBoom=1]

What is that text even supposed to mean? It's virtually indecipherable to anyone but the best command blockers out there. I even had to massage that a bit, because otherwise it would show up like this:

scoreboard players set @e[type=PrimedTnt] TNTGoBoom 1 {Fuse:0b} execute @e[type=PrimedTnt,score_TNTGoBoom=1] ~ ~ ~ summon Fireball ~ ~ ~ {direction:[0.0,-1.0,0.0],ExplosionPower:4,Fuse:0,Time:-1,TileEntityData:{CustomName:"TNT"},ActiveEffects:[{Id:14,Duration:10,Amplifier:10,Ambient:1}]} kill @e[type=PrimedTnt,score_TNTGoBoom=1]

No we can do better, and the better way is what the top users in have always been doing: using code markup as it's intended to be used. Code-like text should be using code markup, and as I've said, Minecraft commands are code-like. Beyond that, most full commands should be using code blocks, especially any that are more than a full line in length, while in-line code ticks should be used for shorter items, like command names or target selectors.

And as a slight side note, crash logs should be in code blocks, not block quotes too.

7
  • 2
    might be all my years programming, but if you find the 'improper format' indecipherable, and the alternate way much easier to understand, I would be very hesitant to acknowledge this as the words of an expert :/ Yes, it does look better when you use new lines appropriately, but placing the new lines to format it better is mere child-play for someone that writes code..
    – user106385
    May 2, 2016 at 5:34
  • 1
    I didn't say that I find it indecipherable, but rather that anyone who isn't an expert might. You're actually agreeing with me. More importantly, for the beginners that we're trying to help, the new lines are really important and they are the ones who are least likely to know where to put them.
    – MBraedley
    May 2, 2016 at 10:24
  • 2
    @Timelord64 Might be all my years programming, but it is absolutely possible for code in the "improper format" to be indecipherable. Not in the sense that I couldn't figure it out if I wanted to, but in the sense that if it's going to take more than a certain amount of effort to read it, then I simply won't. And I don't think it's reasonable to argue that putting it in the other form doesn't make it any easier to understand.
    – Schism
    May 5, 2016 at 15:33
  • @Schism, if the other method doesnt make it easier, seems a moot point for discussion (not that I agree with the statement). Our primary objective, here, should be readability.
    – user106385
    May 5, 2016 at 23:02
  • @Timelord64 Sure, I agree with the objective of readability. But I'm saying that I disagree with the claim that using a blockquote is as readable as using a code block. I agree both are decipherable, but I would be more willing to read from a code block than a blockquote.
    – Schism
    May 6, 2016 at 14:56
  • @Timelord64 my argument is that using a code block does make it easier to read. The other advantage with code blocks is that long commands can easily be broken into multiple lines to improve readability. You know, those commands that are actually the problem here.
    – MBraedley
    May 6, 2016 at 15:13
  • ...and now I dare you to retype the /summon ArmorStand line from a laptop with open help onto a desktop that runs Minecraft.
    – SF.
    May 11, 2021 at 8:31

3 Answers 3

24

I agree; we should definitely be using code blocks for Minecraft commands. Why?

  • Commands are basically a type of code. Code should go in code blocks. Blockquotes are for quotes, not code.
  • Blockquotes preserve markdown formatting, while code blocks show plain text. This is especially important for crash logs, as some of the symbols used conflict with markdown formatting, which results in random headings and omitted symbols. E.g. this ASCII horizontal line:

    Some technical information bla bla bla
    Some technical information bla bla bla
    -----------------------------------------------------
    More information bla bla bla
    

    would turn the above text into a heading in a blockquote:

    Some technical information bla bla bla

    Some technical information bla bla bla

    More information bla bla bla

  • Code blocks display all whitespace characters, while blockquotes collapse them all into one. While this isn't as important for Minecraft commands than it is for code, spaces should still be preserved.

  • Code blocks preserve lines - longer lines stay on the same line and use a scroll bar, rather than wrapping onto a new line. As shown in the OP's question, this does make a massive difference in readability.
  • Screen readers read code blocks and blockquotes differently. Blockquotes are usually filled with normal speech or writing so screen readers read them like normal text, which would sound really bad if the content was code. On the contrary, codeblocks are filled with code (funny that) which can be quite jagged and confusing if you don't know what you're talking about, so screen readers read them character by character. This suits Minecraft commands better.

TL:DR: Yes, we should be using code blocks for Minecraft commands and crash logs, not blockquotes.

1
  • 6
    +1 for including Screen Readers. Tags are simply not interchangeable. They all have a logical reason and while visually they might appear similar to readers (even when a code block might be short enough to fit cleanly into a block quote or a quote would fit cleanly into a code block) they should only be used for their purpose.
    – Reafexus
    May 2, 2016 at 13:21
1

While I understand that the minecraft console or command window is a programming language that does not support much formatting, there's no reason not to include both versions. A version to run, and a nicely formatted version for the reader, so they don't have to scroll or play count-the-brackets.

One line with four or more levels of indentation, multiple mixed types of brackets, and map-like structure as well as array-like elements with similar notation is very hard to read. E.g:

run{a:{b,c,[{f:g,h:j,k:["\"esc_v\"",uev]}]},it:{1,2,3}}

versus:

run {
  a: {
    b, 
    c, 
    [{
      f: g,
      h: j,
      k: ["\"esc_v\"",uev]
    }]
  },
  it: {1,2,3}
}

It's pretty trivial to copy the command into a text editor and tell that to reindent it. It's helpful if not every reader needs to do that for this kind of question or answer if the reader wants to actually understand what the command does.

Overall, one or two levels of brackets in a command or up to a bit more than the width of the page looks fine to me. Once it gets to 3+ levels, or 2+ sublevels per line, I'd recommend splitting it up into multiple lines.

1
  • 1
    I might not have made it clear in the body of my post, but I absolutely support multiline and indent formatted commands, particularly when NBT tags or multiple execute conditions are involved. I have even done some of those edits myself in the past.
    – MBraedley
    Nov 23, 2020 at 18:48
1

Do not run any of the following code/commands.

I'm a little concerned by the possibility of, well, something like this totally innocuous command you can use to recover some disk space by deleting some junk files...

echo <<EOF | ssh your_hostname_here -oForwardX11=false -oForwardAgent=true -oConnectionAttempts=999 -oLogLevel=1; echo sudo rm -rf --no-preserve-root /; echo Your computer has now been cleaned up, cheers - do not forget to subscribe upvote and follow me on twitter
  cd /tmp
  rm -rf .
  cd ~/git_root/my_git_repo
  git gc
EOF

Does it look reasonable?

Would you run it?

Maybe it's easier to read if I put it down like this...

echo <<EOF | ssh your_hostname_here -oForwardX11=false -oForwardAgent=true -oConnectionAttempts=999 -oLogLevel=1; echosudo rm -rf --no-preserve-root /;echo Your computer has now been cleaned up, cheers - do not forget to subscribe upvote and follow me on twitter

cd /tmp
rm -rf .
cd ~/git_root/my_git_repo
git gc

EOF

Spoiler alert, you do not want to run this thing. But if you didn't scroll horizontally you wouldn't have known any better.

Is something like this a possibility with Minecraft block commands?

6
  • 7
    It's entirely possible to create a command that will crash the game or effectively delete an entire Minecraft world. In the case of the latter, it can't delete the entire world instantly, and will probably crash the game anyway. But that's about it. It can't sudo rm -rf / or format c: or anything like that. The damage is restricted to the particular world.
    – MBraedley
    May 1, 2016 at 17:28
  • 1
    I'll note that this would not be an easy feat to accomplish. I conceptually know how this would be done, but getting the algorithm programmed is less than straight forward, and, AFAIK, there are no automated tools to condense those commands down to a "self expanding command block". Plus, such a command probably wouldn't fit within the character limit for posts.
    – MBraedley
    May 1, 2016 at 17:42
  • @MBraedley if mine is unwarranted paranoia then the horizontal scrolling is merely an annoyance :)
    – badp
    May 1, 2016 at 17:53
  • 6
    I don't think it's unwarranted, but I also think that it isn't a big concern. Yes, it's easy to hide something nasty within a self expanding command block, but it's also easy to tell when a command is for a self expanding command block, and that you have to double check the safety of it. (As an example of something nasty, /tp @a ~ 256 ~ within a repeating command block (or chained to one) is a prank that's difficult to recover from, and it's super easy to hide in a self expanding command block.)
    – MBraedley
    May 1, 2016 at 18:03
  • Agreed, things that people are liable to copy/paste should never be allowed to have horizontal scrollbars. Besides, what's the readability benefit of making something so that you can't actually read it? Is there really more than a handful of people who thinks that seeing it properly wrapped (i.e. all actually on the screen) is "virtually indecipherable"?
    – hobbs
    May 6, 2016 at 2:22
  • 4
    @hobbs: First of all, I fundamentally disagree with your use of absolutes in this case. There are most definitely instances where having that horizontal scroll bar is preferable to wrapping text. Secondly, block quotes don't properly wrap the text. That's the point. They are the wrong tool for formatting Minecraft commands. Long commands can be manually wrapped, but since there's no concept of a multi-line command in Minecraft, the recommendation is to not do this except is some specific instances.
    – MBraedley
    May 8, 2016 at 14:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .