Skip to content

From objects to data

Changing. Follow: #154, #160, #566

mcrs is built on Bevy ECS, short for entity component system. If you have written plugins for Paper or Minestom, most of what you know about Minecraft still applies. Three habits do not carry over, and this page goes through them one at a time.

In Paper a player is an object. You hold a Player, read its fields and call its methods:

for (Player p : world.getPlayers()) {
if (p.getGameMode() == GameMode.CREATIVE) {
log.info(p.getName());
}
}

mcrs has no player object. A player is an Entity, and an Entity is only an id. Everything the server knows about that player sits in components attached to the id: GameProfile holds the name and the UUID, PlayerGameMode holds the game mode. The code that works with components is an ordinary function, called a system. Here is the same loop as a system (a sketch to show the shape; the tutorials use code from the repository):

// A system is an ordinary function; Bevy calls it and passes in the query result.
fn log_creative_players(
// Entities with GameProfile and PlayerGameMode; With<Player> keeps only players.
players: Query<(&GameProfile, &PlayerGameMode), With<Player>>,
) {
// profile and mode are arbitrary variable names, not parts of GameProfile or PlayerGameMode.
for (profile, mode) in &players {
// mode.0 is the first field of PlayerGameMode, roughly PlayerGameMode[0].
if mode.0 == GameMode::Creative {
info!("{}", profile.username);
}
}
}

Player is an empty struct with no fields (pub struct Player;), a tag that says “this entity is a player”. mode is a reference to a separate PlayerGameMode component on the same entity. For every entity that has all three components, the query hands out references to its GameProfile and PlayerGameMode. The query checks Player but leaves it out of the result.

Entity 42
├─ Player (tag, no data)
├─ GameProfile { username, id, ... }
└─ PlayerGameMode (GameMode::Creative)

mode is an arbitrary variable name that the author of the function picked. It is not a field or any other part of PlayerGameMode. The loop unpacks the pair from the query by position, matching Query<(&GameProfile, &PlayerGameMode), ...>: the first item gets the name profile, the second mode. Write for (p, gm) in &players and the body uses p.username and gm.0; the code works the same.

.0 is not arbitrary. PlayerGameMode is declared as PlayerGameMode(pub GameMode): the struct has one field with no name, and Rust reaches it by number. Read mode.0 as PlayerGameMode[0], the first field of PlayerGameMode, which holds the GameMode. The brackets are only a mental picture; Rust writes .0.

As a database analogy, picture an entity as a row and a component as a column. The Query above reads like SELECT profile, mode FROM entities WHERE has(Player). This is an analogy for selecting components. Players and mobs are Bevy entities; the tile tables used by physics, AI and replication are views for those consumers. World data explains that distinction.

The table below maps what you would reach for in Java to its closest relative here. The rows are analogies to get you started. Paper and Minestom in mcrs terms has the full lookup table.

Java ECS in mcrs
class Player extends LivingEntity An Entity id with components such as Player, GameProfile, PlayerGameMode
A field player.gameMode The component PlayerGameMode on that entity
A method player.fly() A system that reads and writes PlayerFlying
for (Player p : world.getPlayers()) Query<Entity, With<Player>>: the ids of every entity tagged Player
p.getName() and p.getGameMode() inside the loop Components listed in the query: Query<(&GameProfile, &PlayerGameMode), With<Player>>
A reference to a player kept in a field The Entity id kept in a component or a resource
Bukkit.getServer() System parameters: Res<T>, Query<..>, Commands
A Listener method An observer function fn(e: On<Event>), or a system
runTaskTimer A system in FixedUpdate, which runs 20 times per second by default

Your own plugin data follows the same rule. Put it in components and resources, and when you need to remember a player, keep the Entity id and look the player up again when you use it. The game mode component is in player_game_mode.rs, and the components for flying and operator level are in ability.rs.

mcrs has no static entry point. A system lists what it needs as parameters, and Bevy passes those values in each time it runs the system: Res<T> for a shared resource, Query<..> for entities, Commands to create or change them.

If you have used dependency injection, you already know this pattern. The function signature plays the part of the constructor and the Bevy scheduler plays the part of the container. The signature also tells you, and Bevy, exactly what a system reads and what it writes. The next section depends on that.

Bevy compares the signatures of your systems. Two systems that touch different data run at the same time, and you write no code for it. Two systems that write the same data conflict, so you tell Bevy which one goes first with .before() or .after(). Bevy finds these conflicts when it builds the schedule at startup. The Rust compiler does not catch them.

You never call Bukkit.getScheduler().runTask(...) to get back to the main thread, because there is no such thread. The model also differs from Folia. Folia splits the world into regions by position, while mcrs splits the work by the data each system touches.

By default, each dimension has one cell and one simulation world. A static split gives each cell its own world; a query sees only local entities, and cells can tick in parallel. Time, weather and game rules are shared between them, so that data has one writer and every dimension reads a snapshot of it.1 When one dimension needs something from another, it sends a message.

The demo below runs the same herd of cows twice, once in vanilla order and once in mcrs order.

Cows: the same tick, vanilla order and mcrs order - open separately
The demo is in Russian only for now. It shows the idea with a simplified model and does not run the real scheduler.

The tick is designed to give the same result regardless of thread order. Handle damage, death and respawn describes how this applies to damage batches, and How a tick runs in parallel covers the implementation and its tests.

How strict the guarantee is depends on the part of the game. The project defines three tiers:2

Tier Guarantee Examples
Exact The result equals the reference game World generation, player movement arithmetic, rules tied to a saved seed
Independent of the scheduler The same inputs give the same tick in any thread order Most other things
Free Order has no effect, because nothing shares written data Entities and systems that write only their own data

Outside the exact tier, mcrs matches the distributions of the reference game’s random numbers and does not reproduce its exact sequences.

For your plugin this comes down to one rule. If one of your systems must run before another, say so with .before() or .after(), and never rely on the order you happen to observe. CI runs the simulation schedules with ambiguity detection set to error, so an unordered conflict fails a test.3 The tests are tick_determinism.rs and schedule_ambiguity.rs.

The server installs a fallback error handler in src/main.rs. When a system or a command fails with an error that Bevy would panic on, such as a command for an entity that already left the world, the handler logs the error and the server keeps ticking. This is close to an uncaught exception in a Bukkit event handler.

Next: Rust for Java developers.

  1. Works#357 The decision that global mutable state has one writer. ↩

  2. Works#367 The decision that defines the three tiers of determinism. ↩

  3. Works#323 Simulation schedules fail on an ambiguous system order. ↩

Sources and verification

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

Related open issues:

  • #154 WIP Global state has one owner and reaches every dimension as a versioned snapshot
  • #160 WIP Shards form, merge and split from causally connected work and run in parallel
  • #566 Partial Direction: library code without shared ownership, locks, trait objects or hot-path allocation