| .cargo | ||
| .nvim/plugin | ||
| potato | ||
| potato-data | ||
| potato-macro | ||
| potato-server | ||
| scripts | ||
| .envrc | ||
| .gitignore | ||
| .nvim.lua | ||
| Cargo.lock | ||
| Cargo.toml | ||
| flake.lock | ||
| flake.nix | ||
| README.md | ||
Potato Minecraft Server
It runs on a potato.
Crates
potato - Binary crate for the main server, handles starting the server from the CLI.
potato-server - Main server implementation.
potato-api - Defines the api for modules to interact with the server.
potato-data - Internal crate holding types and constants generated from minecraft datagen reports. Intended for use by the core module.
potato-mod-core - Module implementing the core minecraft mechanics for the server. Compiled into the main binary and can't be unloaded.
potato-macro - Macro implementations for both internal and external use.
Module lifecycle
On server startup:
on_loadis called for all modulesreload_resourcesis called for all moduleson_resources_loadedis called for all modules
On module reload:
on_loadis called for the module being reloadedreload_resourcesis called for the module being reloadedon_resources_loadedis called for the module being reloaded
Concepts
Data reload: A reload off all registries. Data-backed registries are automatically repopulated from the available datapacks and code-backed registries are cleared ready for population by code.
Plugins
Plugins are loadable (and unloadable) modules used to extend server functionality. Plugin loading and unloading causes a data reload as it might have inserted entries into a code-backed registry, which will get removed once the plugin is unloaded.
Plugin lifecycle (luau)
Server startup:
- Plugin is discoverd and its
init.luaufile is executed. This should return the plugin table. - After all plugins are discovered, the dependency graph is calculated (TODO).
- Plugins are loaded in order. The
on_loadof a plugin is called. This is the time to create your registries. - A data reload is executed.
Single plugin reload:
- The plugins
on_unloadis called. This is when you should cleanup your registries. - The plugins
on_loadis called. - A data reload is executed.
New plugin load:
- The plugins
on_loadis called. - A data reload is executed.
Plugin unload:
- The plugins
on_unloadis called. - A data reload is executed.
Data reload:
- All registries are cleared.
pre_data_reloadis called for all plugins. This is the time to populate code-backed registries which may be required during the data reload.- A data reload is executed, populating all data-backed registries.
on_data_reloadis called for all plugins. This is the time to populate code-backed registries which depend on data-backed registries.
Registry system
Types of registries
All types of registry can only be read at runtime, and are append-only during a data reload. No way to remove anything except for a full reload. This ensures that data stays available during server runtime.
Data-backed (reloadable): Replacing entries happens through a data reload. Adding entries outside of a data reload is impossible. A data reload causes the world and all clients to fully reload. The world is reloaded from disk and clients are kicked back into configuration for a registry sync.
Code-backed (static): Adding entries happens through code. Doesn't require a data reload so it can happen while the world is loaded. Clearing it is still only possible during a data reload as data-backed registries might depend on it.
IdMapper: A special type of code-backed registry that maps numeric IDs to instances of objects.