7

Update: Using this I created this tool for copy & pasting QR codes into Minecraft

I wanted to compose a bunch of commands in an external editor and then paste them all to execute in the Minecraft console (chat window).

But if you paste multiple lines, it seems to just ignore the line breaks. My next thought was to use a separator between commands, such as a semicolon, but after a bit of DuckDuckGoing I couldn't find any such separator.

This is for a realm, and I'm running the Java version.

Example

For example, I'd like to be able to do things like compose a little script like this in an external editor:

/setblock 0 0 0 air
/playsound block.bell.use master @p

Then copy it to clipboard, open Minecraft and press "t" to open the command line / chat. Then if I paste, unfortunately what I get is

/setblock 0 0 0 air/playsound block.bell.use master @p

What I'd like to happen is for it to run several commands.

Update I don't mean functions, as I want anyone to be able to paste in commands, not only realm admins but anyone with cheats on.

2
  • Why do you want to do this? You can just execute the commands one after the other. Commented Feb 16, 2020 at 12:12
  • @FabianRöling For example if I created a tool that turns a 16x16 pixelart into setblock commands, that might be 256 commands, which would be too many to paste in separately. If I require downloading and reuploading the realm, then non-admins would not be able to use it.
    – Bemmu
    Commented Feb 16, 2020 at 12:30

4 Answers 4

8

Before functions and structure blocks existed, the best way to send someone a command block contraption was a "one-command-creation", which summoned a falling command block riding a falling command block riding a falling command block …

Currently there is a bug that breaks these: https://bugs.mojang.com/browse/MC-145113
But you can work around it by using other entities in between that instantly die. So you can for example do it like this:

summon falling_block ~ ~2 ~ {Time:1,BlockState:{Name:"command_block"},TileEntityData:{auto:1,Command:"say 1"},Passengers:[{id:"armor_stand",Health:0,Passengers:[{id:"falling_block",Time:1,BlockState:{Name:"command_block"},TileEntityData:{auto:1,Command:"say 2"},Passengers:[{id:"armor_stand",Health:0,Passengers:[{id:"falling_block",Time:1,BlockState:{Name:"command_block"},TileEntityData:{auto:1,Command:"say 3"}}]}]}]}]}

This executes all three commands, say 1, say 2 and say 3, in that order. If you also want to clean up afterwards, you can simply add another command block that removes the tower:

summon falling_block ~ ~2 ~ {Time:1,BlockState:{Name:"command_block"},TileEntityData:{auto:1,Command:"say 1"},Passengers:[{id:"armor_stand",Health:0,Passengers:[{id:"falling_block",Time:1,BlockState:{Name:"command_block"},TileEntityData:{auto:1,Command:"say 2"},Passengers:[{id:"armor_stand",Health:0,Passengers:[{id:"falling_block",Time:1,BlockState:{Name:"command_block"},TileEntityData:{auto:1,Command:"say 3"},Passengers:[{id:"armor_stand",Health:0,Passengers:[{id:"falling_block",Time:1,BlockState:{Name:"command_block"},TileEntityData:{auto:1,Command:"fill ~ ~-3 ~ ~ ~ ~ air"}}]}]}]}]}]}]}


Michael Dibbets/Tschallacka has created a generator in 2020 for these combined commands: https://www.tschallacka.de/minecraft/multiple-commands-generator (mirror, archive)

Enter your commands in the text field above the red button, one per line, without slashes in front (so like a function) and press the button. The bottom text field will then contain the combined command.
The generator does not validate if the commands are valid and it does not ignore empty lines or lines starting with #, so you cannot simply copy-paste function files into it.

Licensing information on his profile (archive).

13
  • I suspected some hack like this must be possible. Thank you!
    – Bemmu
    Commented Feb 17, 2020 at 11:47
  • 1
    felt inspired by your answer, don't know if there is already one out there jsfiddle.net/Tschallacka/evwb39dr/embedded/result Commented Feb 17, 2020 at 16:18
  • 1
    @FabianRöling updated it, better like this? And I cared because I was thinking of adventure maps etc... where players might slip somehow down. but the command blocks would be sealed off then anyways Commented Feb 18, 2020 at 9:36
  • 1
    @Tschallacka Your command generator is now only in the bottom right part of the website and there's a lot of other stuff that is probably not meant to be there. Commented Nov 26, 2020 at 1:00
  • 1
    @FabianRöling jsfiddle doesn't seem to want to do full screen anymore. I've ported it to my website. Do note my website sometimes is slow as molasses as it's on shared hosting and sometimes the server gets shut off due to inactivity because nobody visits ;-) Just be patient for it to load. tschallacka.de/minecraft/multiple-commands-generator Commented Nov 26, 2020 at 8:45
8

You could do this by writing a function (.mcfunction file) and placing it in a datapack in the map folder. To create a function, follow these steps:

  1. Open notepad (or your text editor of choice), and enter the commands you wish to run, each on their own line.

  2. Save the file, name it whatever you want, (replace .txt with .mcfunction) on your desktop.

  3. Create folders in this order:

    datapacks / [name of datapack] / data / [namespace] / functions

  4. Move the .mcfunction file you created into the functions folder, and move the datapacks folder into your world folder. (for a Realm, you will first need to download the map - go to World backups and Download latest)

  5. (for a Realm) Upload the modified map to the Realm.

  6. Run the function with /function [namespace] : [function name]. This can be done by a player or from a command block.

Note: @p selector will be relative to the command block or player that ran the function, in this usecase I'm assuming @a would fit better.

3
  • Thanks, so sounds like pasting multiple isn't possible. I wanted anyone on a realm to be able to paste the commands, not just admins, and would have been more user-friendly to not require downloading and uploading.
    – Bemmu
    Commented Feb 16, 2020 at 11:35
  • 1
    As an admin/just a guy who runs his own server, this is perfect! Now I can script up all my command files and just run them from my world
    – tmck-code
    Commented May 3, 2020 at 23:09
  • Note: plugin commands cannot be executed using datapack functions, only vanilla commands. Also - in order for function to be available, datapack must contain pack.mcmeta file and must be then enabled. Commented Jul 27, 2023 at 15:48
1

You could have the pixel art already created then clone it to the position then play the bell sound to the player, this is best done with tags so everything goes to the right player .

One thing you could also do is to have a structure block with the commands already inside, then have setblock command that places preset structureblock

0

One can copy multiple commands into the clipboard then paste into a Minecraft server window. I show how in YouTube post at

Alternatively, one can use AutoHotKey to load a text file into a Minecraft client (game window). Also available on my channel.

1
  • 1
    Links and videos are helpful in a post, but make sure the post is still clear without them. You should explain in your post directly what this will do, and go into more detail on how to do it.
    – One 2 Many
    Commented Nov 3, 2020 at 4:28

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.