Stop Minecraft Ticks when zero players online
As we all know , a Minecraft Server keeps the spawn chunks loaded all the time (if you don't know, read these questions: one two). So ticks keep passing by. I'm keen of the fact that in these ticks not everything is processed like there is a player nearby that is responsible for the loaded chunks.
Normally these questions go in the direction "I want something loaded and processed" but I'm looking for the opposite. In normal vanilla Minecraft there is no calendar, there is only day and night. Because of this the impact of ticking is not quite as relevant. But for mods like TerraFirmaCraft with calendar and stuff, this is a bit of a problem because you will starve while you're, for example, at work.
I found some scripts in python that act like some kind of proxy. Listening to the default Minecraft port 25565 and if they get any connection starting up a real server in the background passing the traffic over. If all players disconnect, after some time, the server gets shut down and the whole process starts over again.
As I'm using a hosted solution I can only run *.jars, so python and shell scripts are out for this. Is there any solution using Forge or a Java Wrapper to accomplish this type of behavior?
Manually starting and stopping the server all the time is no solution in this case.
Best Answer
In the spawn chunks, use a command block with the command:
/testfor @a
With a comparator coming out of it connected to a block, place redstone dust on top of the block leading to a command block with the command:
/gamerule randomTickSpeed (speed, default is 3)
and a torch going out of the block with redstone dust connecting it to a command block with the command:
/gamerule randomTickSpeed 0
Pictures about "Stop Minecraft Ticks when zero players online"



How do you stop a tick in Minecraft?
The program loop of Minecraft runs at a fixed speed of 20 ticks/second. To change the tick speed, you have to use the command \u201c/gamerule randomTickSpeed <|your tick number|>\u201d after enabling the cheats. For example, \u201c/gamerule randomTickSpeed 80\u201d. This command will set your tick to change every 4 seconds.Do Minecraft servers pause without players?
Simple utility mod that allows servers (including integrated servers) to pause when all connected clients are paused/on a pauseable screen. You can also configure it to pause servers when there are no clients connected (to save your CPU!) and to send a chat message when the server pauses.How do you go invisible on a Minecraft server?
Just do /invis and you turn invisible!How do you pause Minecraft multiplayer?
The /stop command is a server command that stops a Minecraft server and then saves all of the server data such as players, worlds, chunks for the Overworld, chunks for the Nether and chunks for the End.Why Sudo Is The Best Command in Minecraft
More answers regarding stop Minecraft Ticks when zero players online
Answer 2
Spawn chunks, as far as I know, do not stay active as long as no players are currently in that dimension. If all players are in the Nether or End, the overworld spawn chunks cease to tick. If no players are online, it's the same result. The day cycle continues as normal, as does anything else that doesn't have to do with physical chunks. While I don't know about Forge (I use command blocks for everything), all chunks should stop ticking when nobody is online. I do have one solution to try, though. If the modification you're using uses the day cycle to run it's calender, you can stop the day cycle with ' /gamerule doDaylightCycle false ', or use some kind of plugin to do that for you. I hope that I helped in some way. Have good luck.
Answer 3
Ifound this thing for you. Maybe you can do something with it, perhaps you will need some script or so, but that is up to you. http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2421222-tickratechanger-change-the-speed-that-your-game
Answer 4
I would suggest you would switch to Bukkit or a fork (Spigot) as they allow the opportunity to shut down the server at regular intervals if no players are online or could possibly unload any chunks at an interval where players are not nearby.
You can also combine this with Remote Toolkit so you can easily allow an automatic restart when the server is stopped.
Answer 5
The system you are requesting is based on Heartbeat activation.
Sadly as far as I know port listening and handling will need to be handled outside of the normal jars that run the game.
Essentially you would need to have a trigger detecting port activity that switches everything on and off but as you have no access to python or other scripts outside of Minecraft this would need a custom Minecraft server jar to handle the port listening.
I would suggest migrating your server to a system with higher levels of control.
Answer 6
Check out this link on Github. It's a python script that listen for connections and when a player connects it launches the Minecraft server. If there are no players it just stops the Minecraft server.
(It's made for Minecraft vanilla but it's so easy to configure also for other types of Minecraft servers (just follow the guide))
And it's updated to 2019 if someone needs it!
i created this myself and would be happy if you used this!
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Laura James, Laura James, Laura James, Ketut Subiyanto
