TransWikia.com

Automatically running a Minecraft command

Arqade Asked on August 25, 2021

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.

5 Answers

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.

Answered by Yamikuronue on August 25, 2021

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.

Answered by gm95 on August 25, 2021

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 :)

Answered by Kimatuy on August 25, 2021

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.

Answered by user196045 on August 25, 2021

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.

Answered by Rapster Zeber on August 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP