Minecraft – Stop Minecraft Ticks when zero players online

minecraft-java-editionminecraft-java-edition-server

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