Simulated players
Run scripted play tests of your game on your developer server with players that your script drives.
What a simulated player is
A simulated player is a player on the server with no connection, driven by your script. Use it for scripted play tests of your game on your developer server: a party invite, a match start, a shop, a death and respawn.
It joins and leaves like a real player, so your script sees it as one: the login, join and leave events, get_player_by_uuid and the lookup by name, the tab list, its inventory, teams and boss bars, its death and respawn events.
Turn it on
Add the SDK feature gametest to the dependency line from Get the SDK:
strawberry-plugin-api = { version = "...", registry = "strawberry", features = ["gametest"] }Then gametest::spawn_simulated_player(world, position, name, game_mode) gives you a SimulatedPlayer. The gametest module also gives the types its methods take (BlockPos, GameMode, Direction, NavigationResult), so a test script needs no path into generated code.
Drive it
To do this | Call |
|---|---|
Chat, or run a command |
|
Walk in a straight line |
|
Walk a path the server finds |
|
Move in other ways |
|
Look |
|
Act on blocks and entities |
|
Use and hold items |
|
Respawn or leave |
|
Get it as a |
|
A command runs with the player's own permissions, those of a new player unless you give it more.
Every action is what a player's client sends, and the server checks it at the next tick like any player's input (reach, cooldowns, movement), so your test runs against the game's real rules. A function that returns bool says whether the action was sent, not whether the server accepted it: read the result from the world, the events or the player.
A simulated player can act right after it joins or is teleported: a block it places or uses, a click or an attack in that same tick goes through.
Read what it was sent
SimulatedPlayer::take_messages(max) returns and removes the oldest max messages the server sent to the player: system messages, chat lines, title, subtitle and action bar, as plain text with their kind, oldest first. The player keeps the newest 64 messages and 16 KiB of text. Nothing is kept for real players.
Where it works
- Simulated players exist only on a developer server. Everywhere else the spawn answers with an error and nothing is made.
- A server holds at most 16 at once.
- A simulated player never takes a real player's slot and is not shown in the server list or in Play Strawberry's player counts.
- It is not a verified account: it signs in offline, with a UUID no Minecraft account has.
- Its name cannot be the name of a real player who is online or has played on the server. When a real player joins under a simulated player's name, the simulated player leaves.
- All your simulated players leave when your script is unloaded or the server stops.
A simulated player is a Java player on the server: it tests your game's logic, not what another client is shown.
Play tests
To run a whole play test from a scenario file instead of writing the steps in Rust, use the Creator Kit's runner: see Play tests. That page also covers game tests, which the gametest feature gives too.