9

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.

  • 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 Nov 9 '13 at 20:32
  • Such a feature would be often used as PVP cheat. – Tomáš Zato Nov 10 '13 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 Nov 10 '13 at 15:24
2

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.

  • 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". – SevenSidedDie Nov 9 '13 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.

  • 3
    Can AutoHotkey scripts be made to trigger automatically without a keypress, which is what the question is looking for? – SevenSidedDie Nov 9 '13 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 Nov 9 '13 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.

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.