Skip to content

Remove and replace vanilla parts

Changing. Follow: #281, #283, #287, #785

This page shows how to build your own server from the same plugins as the stock one, how to leave a plugin out, and how to pass settings to the plugins.

In Paper you start from a finished server and add plugins. In mcrs you start from a group of plugins and take parts out, so a lobby can run without world generation and a test can run without lighting. The examples come from repository files, and we did not run them outside the repository tests.

MinecraftServerPlugins is a Bevy PluginGroup, which is a set of plugins that you add to the app as one value. Its four fields are the parts that take settings:

The fields of the group
pub struct MinecraftServerPlugins {
pub core: ServerCorePlugin,
pub worlds: DimensionWorldsPlugin,
pub world_gen: WorldGenPlugin,
pub network: ServerNetworkPlugin,
}

crates/mcrs_minecraft_server/src/lib.rs:43-48

build() adds the rest of the vanilla server. The members, in the order build() adds them, are the server core, world generation registries, the command engine, vanilla commands, world commands, dimension worlds, chat, entity physics, player pose, entity attributes and player vitals, respawn, death drops, death messages, the sprint attribute, creative reach, item entities, falling blocks, block drops and support, mob brains, item and inventory saving, block placement, arm swings, player attacks, world generation, lighting and the network.1

The members of the group
impl PluginGroup for MinecraftServerPlugins {
fn build(self) -> PluginGroupBuilder {
PluginGroupBuilder::start::<Self>()
.add(self.core)
.add(WorldgenRegistriesPlugin)
.add(CommandPlugin::<VanillaCommands>::new())
.add(VanillaCommandsPlugin)
.add(WorldCommandsPlugin)
.add(self.worlds)
.add(VanillaChatPlugin)
.add(VanillaEntityPhysicsPlugin)
.add(VanillaPlayerPosePlugin)
.add(VanillaEntityAttributesPlugin)
.add(VanillaRespawnPlugin)
.add(VanillaDeathDropsPlugin)
.add(VanillaDeathMessagesPlugin)
.add(VanillaSprintAttributePlugin)
.add(VanillaCreativeRangePlugin)
.add(VanillaItemEntityPlugin)
.add(VanillaFallingBlockPlugin)
.add(VanillaBlocksPlugin::default())
.add(VanillaMobBrainPlugin)
.add(VanillaItemPlugin)
.add(VanillaBlockPlacePlugin)
.add(VanillaSwingPlugin)
.add(VanillaPlayerAttackPlugin)
.add(self.world_gen)
.add(LightingPlugin)
.add(self.network)
}
}

crates/mcrs_minecraft_server/src/lib.rs:85-115

You can disable or replace each member without editing the server crate. A member that needs another one panics when the group builds and names the missing plugin. You get the error at start, so you do not have to trace a missing resource at the first tick.

The vanilla gameplay lives in plugins above the engine. Each of them is removable on its own, and most of them reach every dimension world through add_dimension_plugin.2

The binary switches mob AI off like this:

src/main.rs: switch off mob AI
if !settings.mob_ai {
server = server.disable::<VanillaMobBrainPlugin>();
}

src/main.rs:118-120

disable::<T>() is a method of the Bevy plugin group builder, and T is the plugin you leave out. A repository test uses the same method to start a server without world generation and lighting:

Test: a server without world generation and lighting
fn a_client_without_an_app_joins_the_embedded_server_offline() {
let mut plugins = MinecraftServerPlugins::embedded();
plugins.core.asset_path = Some(ASSETS.to_owned());
plugins.network.announce_on_lan = false;
let mut app = App::new();
app.add_plugins(
plugins
.build()
.disable::<WorldGenPlugin>()
.disable::<LightingPlugin>(),
);
let stop = StopOnDrop(Arc::new(AtomicBool::new(false)));

crates/mcrs_minecraft_server/tests/it/client_join.rs:29-40

That test also calls MinecraftServerPlugins::embedded(). It gives a server that runs inside another process. Such a server listens on loopback only, takes a port that the OS assigns, and leaves the task pools to the host app.

embedded()
impl MinecraftServerPlugins {
#[must_use]
pub fn with_local_packs(mut self, extra: impl IntoIterator<Item = String>) -> Self {
self.core.local_packs.extend(extra);
self
}
pub fn embedded() -> Self {
let defaults = Self::default();
Self {
core: ServerCorePlugin {
owns_task_pools: false,
..defaults.core
},
network: ServerNetworkPlugin::embedded(),
..defaults
}
}
}

crates/mcrs_minecraft_server/src/lib.rs:65-83

To host such a server in your own program, pass a closure that builds the app to ServerThread::start from mcrs_minecraft_engine_server, and the server runs on a thread of its own. address() returns the address once the server listens, request_shutdown() asks the server to disconnect the players, save the world and exit, and finish() asks the same and waits for the thread to end. The client starts its singleplayer server this way, and the field extend_server of its LocalServerPlugin takes a function that adds your own plugins to that server.

The group exposes these members separately:

Member What disabling it removes Replacement
VanillaRespawnPlugin the client’s respawn command becoming a world-spawn request write RespawnRequest in the player’s dimension
VanillaDeathDropsPlugin vanilla inventory, cursor and crafting-grid drops on death read Died and choose your own drop policy
VanillaDeathMessagesPlugin vanilla death text and its chat broadcast write DeathMessage in PlayerDeathSet::Describe; broadcast your text separately if needed
VanillaSwingPlugin punch and piercing-weapon stab inputs write SwingPlayer; accepted placements and hand drops have their own producers
VanillaPlayerAttackPlugin attack packets becoming damage and knockback supply your own attack policy3

Player vitals remain in VanillaEntityAttributesPlugin, which installs PlayerVitalsPlugin alongside the attribute plugins. Replacing the respawn policy keeps health, death packets and the engine’s restore mechanism.4 Death drops and messages are independent members.5 Swing requests use the engine cooldown and observer replication even when your own system writes them.6

Handle damage, death and respawn explains the damage filters and respawn limits. Inventory lists what the drop policy does.

The binary reads its settings from the environment and turns them into plugin fields in src/main.rs:

src/main.rs: from settings to plugin fields
let settings = ServerSettings::read(
|name| std::env::var(format!("MCRS_{name}")).ok(),
|error| {
if matches!(error.name, "FORWARDING" | "PROXY_UPSTREAMS") {
unreadable_proxy_setting.get_or_insert(error);
} else {
bevy_log::warn!("{error}");
}
},
);
if let Some(error) = unreadable_proxy_setting {
bevy_log::error!(
"MCRS_{}={:?} is not {}; the server does not start",
error.name,
error.value,
error.expected
);
return AppExit::error();
}
let network = match network(&settings) {
Ok(network) => network,
Err(error) => {
bevy_log::error!("{error}");
return AppExit::error();
}
};
let mut server = MinecraftServerPlugins {
core: ServerCorePlugin {
compute_threads: settings.compute_threads,
..MinecraftServerPlugins::default().core
},
worlds: DimensionWorldsPlugin {
world: world_folder(),
ops,
seed: settings.world_seed,
preset: settings.world_preset.clone(),
default_game_mode: settings.default_game_mode,
spawn: settings.spawn,
..Default::default()
},
world_gen: WorldGenPlugin,
network,
}
.with_local_packs(settings.local_packs.iter().cloned())
.build();

src/main.rs:73-117

Only the binary does this. A library crate does not read an environment variable or a file for its settings, and every setting is a field of the plugin that uses it.7

The environment variables of the binary are the fields of ServerSettings. Most variables carry the name of their field in upper case with the prefix MCRS_, such as MCRS_MOB_AI for mob_ai. Environment variables has the list with the defaults.

In your own program, skip ServerSettings and fill the plugin fields yourself. An embedded server in a test then starts with explicit settings, whatever the shell exported.

MinecraftServerPlugins::with_local_packs(extra) adds local data pack names to the built-in selection. Add and check data packs describes their layout and precedence. DimensionWorldsPlugin.spawn takes an optional [x, y, z] join position; Worlds and saves describes the override rules. The binary and the client’s integrated server pass both settings through these APIs.8

The neighbour-update chain limit is another plugin field, VanillaBlocksPlugin.chain_limit. Block placing, breaking and drops describes its bounded and unlimited forms.

Next: Hook into block placing, breaking and drops.

  1. Works#279 Splits the server plugin into a group of removable plugins. ↩

  2. Works#282 Moves vanilla gameplay out of the server crate into removable plugins. ↩

  3. Works#1106 Adds a removable player attack plugin and the packet damage filter. ↩

  4. Works#1082 Separates player vitals from the vanilla respawn policy. ↩

  5. Works#1084 Adds separate group members for death drops and death messages. ↩

  6. Works#1064 Adds the vanilla swing input plugin and the public engine request. ↩

  7. Works#278 The server is configured only through its plugin. ↩

  8. Works#1089 Adds local data packs and a join position through plugin settings. ↩

  9. WIP#281 Plans the chunk source as a replaceable plugin point, with empty and flat sources. ↩

Sources and verification

Verified: 26.4-snapshot-7, 1cf84286c, 2026-11-30

Related open issues:

  • #281 WIP Chunk source as a replaceable plugin point, with empty and flat sources
  • #283 Partial Public, cancellable player events
  • #287 WIP Minimal server, lobby and arena examples
  • #785 WIP Block behaviours from plugins: compose them and let a rule emit an effect