ryyanmapes / minecart-mod

An open-source Minecraft mod for 1.16.5 adding new options for rail networks.
https://www.curseforge.com/minecraft/mc-mods/more-minecarts
Other
14 stars 15 forks source link

[Suggestion] Check if player online to automatically disable chunk loader. #63

Open Kurunoa opened 2 years ago

Kurunoa commented 2 years ago

This is an important consideration for server modpacks such as All The Mods 7.

Please add a config option like:

# Chunk loader will check every 1 minute if player is online. If player is offline greater than this value, chunkloader switches itself off.
#Range: 0.0 ~ 9999.0 minutes
chunk_loader_offline_time = 15

This example would make the loader turn itself off after 15m of the player not being online. Of course, if you set it to 0, it just stops immediately. Very public-server friendly.

ryyanmapes commented 2 years ago

I'm going to look into this.

Kurunoa commented 2 years ago

Another mod dev suggested the following design:

When player logs off, start a timer for x minutes. When the timer expires, turn off the loader. If the player logs on, cancel the timer.

ryyanmapes commented 2 years ago

I'm not currently storing who owns the chunk loader, which is kind of the issue.

MuradAkh commented 1 year ago

@ryyanmapes Little Logistics uses a system that lets a player register an entity (or a group of entities if linked), and then the server will handle chunk management for them on a per-player basis. The chunks aren't loaded as ticking chunks - instead they are loaded as non-ticking and entities in a "train" are ticked individually.

We are planning to make this available as a library for other mods, would you be interested?
See this for an example: https://github.com/MuradAkh/LiteLoadLib/blob/main-1.19/src/main/java/dev/murad/liteloadlib/examples/MyExampleEntity.java

You would probably want to add it as a special minecart, and have it keep track of all linked minecarts.

The system is designed to prevent chunk loader minecarts from being abused as stationary chunkloaders.