11

Is there a way to automatically run a Minecraft command when starting a new game, loading an existing world, joining a server, or re-spawning?

For example, is there a way to automatically enable keepInventory instead of having to manually enter it?

Granted, this isn’t the best example because it seems that command happens to be persistent, but there are other commands that people might like to run each time they load a game, and could also be useful for multiplayer games if a command could be run on them when they join a server.

A better example is if you want to automatically get a pickaxe after dying so that you can save time, or if you want to automatically /give users a sword whenever they re-spawn on a deathmatch type server.

7
  • 2
    I don't think this is possible. For the respawning thing: you could use a command block and some mechanism that gives the user the items as soon as they leave the safe spawn zone or something like that. Otherwise you have to use a plugin I guess.
    – Gigala
    Commented Nov 9, 2013 at 20:32
  • Such a feature would be often used as PVP cheat. Commented Nov 10, 2013 at 1:20
  • @TomášZato, a pencil can be used to kill, yet they still make them because they are more useful than harmful.
    – Synetech
    Commented Nov 10, 2013 at 15:24
  • 1
    @pppery, four questions how? 🤨 It might have been more helpful to actually write them out. ¬_¬
    – Synetech
    Commented Oct 22, 2020 at 2:08
  • 1
    @pppery, those are only separate questions if they have different answers, but the only way to know if they have different answers is to know the answer(s), in which case, it wouldn't be asked now would it? Regardless, even if they each have completely separate answers, they can all be answered, so for you to complain about it being "too broad" makes no sense since that's not what the "too broad" reason for closing questions is for. "Too broad" is for questions that don't really have a definitive answer, which these would (even if it's "you can't").
    – Synetech
    Commented Oct 23, 2020 at 5:04

5 Answers 5

3

This is what Command Blocks are for: they bridge the gap between in-game events and console commands. You program one with the desired console command, and hook it up to any sort of redstone trigger. So for example, if you put one next to your spawn point with a button attached, you can give yourself a pickaxe when you respawn there or whenever you need one.

There's a good tutorial with some examples on the minecraft wiki.

1
  • 2
    Those are attached to the world though. It doesn't provide a solution for the question's circumstances of all of "starting a new game, loading an existing world, joining a server, or re-spawning". Commented Nov 9, 2013 at 18:32
0

You could try getting AutoHotkey, which allows you to make quick hotkeys that will type out commands for you. You can click here to go to the official site.

For a quick tutorial, once you download and install it, right click on your desktop, hover over 'New' and then click 'AutoHotkey Script'. Name it whatever and then right click and 'Edit Script'. Delete the default text and then your code will be something like this.

^a:: 
send /give playerName 10 10
send {enter}

That will make it so when you press Ctrl + A it will type out the command, then send the Enter key to make it run. Once you have your command save it and double click the script, to exit it, it will be on the bottom right of your desktop as a Tray Icon.

2
  • 3
    Can AutoHotkey scripts be made to trigger automatically without a keypress, which is what the question is looking for? Commented Nov 9, 2013 at 20:24
  • Exactly, the point is to have it done automatically. I already asked about using a hotkey to do things manually, and like I said in that question, AHK doesn’t work because the keys don’t always get sent correctly; some keys get dropped sometimes.
    – Synetech
    Commented Nov 9, 2013 at 22:56
0

I have an answer, but it is more a shortcut than automatically running Minecraft commands.

  • You surely know that Tabis the original key to let you see every players on a server. Well, you can also use it on a command as a shortcut to avoid to write everthing letter by letter: For example, use Tab after you wrote /gamerule would automatically put one of the gamerules of the game. Press Tab again to change of gamerules.

  • The second shortcut is the arrows keys. If you've already wrote a command in the chat and you want to re-run it, then use the up/down arrow keys to select one of the commands you run before. But attention, it won't select the command that were run when you wasn't on the server or when you was on your solo world before you "save & quit to title".

Hope this can help you a bit :)

0

If you put a repeating command block 2 blocks under the spawn that has the command /testfor @a[r=3], then a redstone comparator next to it pointing outwards to an impulse command block that has the command /give @a[x=X coordinate of spawn,y=Y coordinate of spawn,Z coordinate of spawn,r=1] wooden_sword , then it should give all players at spawn a wooden sword.

0

There are some commands that you can use when you are making the settings for a world. But they are only the Gamerule commands. But it can still be helpful.

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.