Skip to content
Projects

About

Minecraft game clone written in Rust.

Games & Emulation

How these counts are measured

What you can do

  • Procedurally generated worlds with biomes (Plains, Forest, Mountains, Desert, Savanna, Jungle, Ice Plain, Ice Spikes, Flower plains, Flower forest, Grove, rivers and oceans), trees, cactus, tall grass, ferns and flowers, in four world types: default, large biomes, archipelago and single biome.
  • Villages whose villagers trade, dungeons with loot and guards, and, at the bottom of the world, the Ember Mother, a boss that a depths compass points to. Below ground, hostile mobs get harder and more rewarding with depth.
  • Multiplayer, on a dedicated server with operators, bans and a whitelist.
  • Day/night cycle

Measured star growth

in 24h
0
in 7 days
+2
in 15 days
+2
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

rustcraft

Minecraft game clone written in Rust, using the Bevy game engine.


image

image


Table of contents


Features

  • Procedurally generated worlds with biomes (Plains, Forest, Mountains, Desert, Savanna, Jungle, Ice Plain, Ice Spikes, Flower plains, Flower forest, Grove, rivers and oceans), trees, cactus, tall grass, ferns and flowers, in four world types: default, large biomes, archipelago and single biome.
  • Villages whose villagers trade, dungeons with loot and guards, and, at the bottom of the world, the Ember Mother, a boss that a depths compass points to. Below ground, hostile mobs get harder and more rewarding with depth.
  • Multiplayer, on a dedicated server with operators, bans and a whitelist.
  • Day/night cycle
  • Block breaking and placing mechanics.
  • Inventory system with a functional hotbar.
  • An item browser beside the open inventory: every item of the game, searched by name or by #category and filtered by category chips; a drawer at the right edge in a small window. It is also the recipe book: the recipes and the uses of any item, the furnace's included, the ingredients you lack in red, in Survival what you can craft now, and a button that fills the crafting grid with a recipe, or lays a faint ghost of it over the grid, the lacking cells in red, when ingredients are missing. Ctrl+click on an item fills the grid with its first recipe made now, without opening it. In Creative it hands out stacks of any item, and destroys the stack you hold. A over any item slot bookmarks its item: the bookmarks show above the list, kept for each world and each server, and a Recent row under them holds the last items crafted in the session.
  • World saving and loading.
  • Survival and creative game modes: in survival, players have 10 hearts and cannot fly. They get hurt by falls of more than 3 blocks, run out of air under water, burn in fire and lava, starve, and get attacked by the hostile mobs; the death screen tells what killed them. A dead player drops its whole inventory where it died, for 5 minutes, and respawns at its bedroll or the spawn of the world. New players start in survival.
  • Hunger: 10 drumsticks that efforts empty and food fills: meats raw and roasted, bread, berries, carrots, potatoes. Health only comes back well fed, a hungry player cannot sprint, and an empty bar starves.
  • Fire, lit with a flint and steel, which spreads through what burns and goes out in the rain; and lava, which flows, sets things on fire, fills the bottom of the caves and hardens into obsidian or cobblestone where water meets it.
  • Seven hostile mobs, which spawn in the dark: Gnawers, Brambles, Rollers, Stumplings, Drowners, Cinderlings, which throw embers, and Gust Owls, which dive at the players of the peaks. Blows knock them back; each drops its loot. /difficulty peaceful keeps them away.
  • A furnace that smelts with an input, a fuel and an output slot, also while nobody watches it, as long as its chunk is loaded: iron and gold ore into ingots, diamond ore into diamonds, sand into glass, cobblestone into stone and logs into charcoal. Coal and charcoal burn for 8 items, wood for 1.5, wooden tools and sticks for less. Lit, it glows; it keeps what it holds in the save and drops it when broken.
  • Tool tiers: wooden, stone, iron, golden and diamond pickaxes, axes, shovels, hoes and swords, each tier faster and longer-lasting (gold is the fastest and wears out the soonest). Ores need a pickaxe of their level, or they break without dropping anything: a wooden one for coal, a stone one for iron, an iron one for gold and diamonds, found deep underground. Nine ingots or diamonds make a block of iron, gold or diamond, and a block gives them back.
  • Bow and arrows, a spear, and armour of leather, bronze, iron and diamond.
  • Experience, spent on enchantments at an engraving table: efficiency, durability, sharpness, protection and bow power.
  • Ten kinds of animals, each with its voice, which breed; wolves and cats are tamed and follow their owner.
  • Skins to choose from or to import, worn by a body the other players see; sounds and original music.
  • A world map and a minimap.
  • A bucket, of three iron ingots, takes a water source and pours it elsewhere, where it flows.
  • Weather: clear spells, rain and thunderstorms follow each other on their own, the same for every player and kept in the save. Rain rolls in under thicker, darker clouds and a grey sky that dims the light and closes the fog in; drops slanted by the wind splash on the ground and ring the water, but not under a roof or the leaves; snow falls in the cold, nothing in the deserts. In the High and Ultra shaders the ground open to the rain darkens, glistens and gathers puddles that mirror the sky, and dries after. Thunderstorms strike lightning that lights the world and the clouds, its thunder heard after the flash. The rain hisses in the open and drums on a roof, at its own Weather volume in Settings > Audio.
  • Sprinting, sneaking and swimming.
  • Portals: with the portal gun (/give portal_gun 1), a left click shoots your blue portal at a wall, a floor or a ceiling and a right click your orange one: a glowing bolt flies there, every player sees it, and the portal opens where it lands. Through each, you see what lies in front of the other, yourself included, and two facing portals show each other three times over; walk or fall in and you come out of the other, keeping your speed.
  • Mods: the behaviour of new content is Rust compiled to WebAssembly, which the server loads and swaps while it runs, keeping its state (see Mods). The Abyss, the game's pack, opens a shaft 400 blocks across somewhere in each world (/locate abyss), lit by the sky down to a lake at y -256: the Rim, tiers of turf and limestone with ramps and waterfalls, and under it the Hanging Woods, forests hung under giant ledges, root bridges, and galleries glowing with amber.
  • Credits, opened from the main menu. docs/ASSETS.md says where the textures, sounds and fonts come from.
  • In-game chat, with commands completed as they are typed (Tab, ↑↓): /time set <day|night>, /give <item> <count> (e.g. /give oak_log 64), /gamemode <creative|survival>, /weather <clear|rain|thunder>, /difficulty <peaceful|easy|normal|hard>, /locate <biome|village|ruin|crypt|sanctuary> and /tp <x> <y> <z> (~ for where you are, ~10 for an offset), and the commands of the mods (/locate abyss); on a server they are its operators' (see Operators, bans and the whitelist), and /list names the players online. In Singleplayer you are always an operator.
  • Customizable keybindings, a mouse sensitivity, a field of view, fullscreen, and a render distance set in Settings > Video or with O and P.

Installation

Manual

You can download the game for Windows and Linux from the Releases page of the GitHub repository.

Once downloaded, extract the archive for your operating system. Run bin/rustcraft (bin\rustcraft.exe on Windows); bin/rustcraft-server is the dedicated server. Keep the data folder next to bin. SHA256SUMS.txt of a release holds the checksums of the archives.

On Linux, the game needs a GPU driver with Vulkan.

Package Managers

Arch Linux

There are 2 AUR packages available for rustcraft:

You can install them using your preferred AUR helper, e.g. paru:

paru -S rustcraft

Controls

Category Action Key(s)
Movement Jump Space
Strafe Left A / Arrow Left
Strafe Right D / Arrow Right
Walk Backward S / Arrow Down
Walk Forward W / Arrow Up
Sprint Left Ctrl while walking forward (it lasts until the player stops)
Sneak (slower, and never walks off an edge) Left Shift
Swim where you look Sprint in the water
Swim up / down Space / Left Shift in the water
Toggle Fly Mode (creative only) F
Fly Up Space
Fly Down Left Shift
Fly faster Left Ctrl while flying forward
Gameplay Destroy Block Left Mouse Button
Place Block Right Mouse Button
Open a crafting table, a chest, a furnace or an engraving table, trade with a villager Right Mouse Button (Left Shift: place a block against it)
Fill / empty a bucket Right Mouse Button
Draw / shoot a bow Hold / release Right Mouse Button
Feed or tame an animal Right Mouse Button
Hotbar Select a slot 1–9
Next / previous slot Mouse wheel
Drop one item / the stack of the selected slot Q / Ctrl + Q
Inventory Open/Close Inventory E
Pick up stack Left Click
Pick up half of stack Right Click (with empty mouse)
Deposit 1 item Right Click (over valid stack)
Deposit MAX items Left Click (over valid stack)
Exchange stacks Left Click (over a different stack or full valid stack)
Move a stack between backpack and hotbar, or into the open chest or furnace Shift + Left Click
Split the held stack over cells Hold Left Click and move over them
Drop one item in each cell Hold Right Click and move over them
Gather the stacks of the held item Double Left Click
Move every stack of an item Shift + Double Left Click
Craft as many as possible into the inventory Shift + Left Click on the result
Craft into a hotbar slot 1–9 over the result
Move every stack swept (Inventory tweaks) Hold Shift + Left Click and move over them
Move one item (Inventory tweaks) Mouse wheel over a stack
Turn the inventory tweaks on / off Settings → Controls
Drop one item / the stack of a slot Q / Ctrl + Q over it
Drop the held stack / one item of it Left / Right Click outside the panel
Swap with a hotbar slot 1–9 over a slot
Move between slots Arrows
Take / place Enter
Take half / place one Space
Move to the backpack / hotbar Shift+Enter
Item browser Search the items / or Ctrl+F, inventory open
Go to the first result ↓ in the search
Act on the first result Enter in the search (Shift+Enter: as Shift+click)
Clear / leave the search Escape
Open / close the drawer (small window) B
Recipes of an item R over any item slot; Left Click in the browser (Survival)
Uses of an item U over any item slot; Right Click in the browser (Survival)
Back Escape or the back button
Bookmark an item, or remove it A over any item slot
Fill the crafting grid with a recipe + Fill grid (Shift: as many times as possible)
Show the ghost of a recipe missing ingredients + Fill grid
Fill the grid with an item's first recipe made now Ctrl + Left Click on an item (Ctrl + Shift: as many times as possible)
Take a stack (Creative) Left Click on an item
Take one more (Creative) Right Click on an item
Put a stack into the inventory (Creative) Shift + Left Click on an item
Destroy the held stack (Creative) Left Click on the list or the trash
Chat Open the chat T
Open the chat with a slash /
Send / close Enter / Escape
Recall sent messages ↑ / ↓ in the chat
Scroll the chat PageUp / PageDown, mouse wheel
Map Open / close the world map M / Escape
Zoom in / out = / -, mouse wheel on the world map
Move the world map Drag
Centre it on the player Space
Show / hide the minimap Settings → Interface
Miscellaneous Game menu Escape
Reload Chunks (rebuild their meshes) R
Toggle debug overlay F3
Toggle Perspective F5
Zoom (hold) C
Toggle Chunk Debug F4
Toggle Block Debug F6
Toggle Raycast Debug F7
Decrease render distance O
Increase render distance P

Multiplayer

There are four ways to play with others. What tells them apart is the machine the world runs on:

Way to play Where the world runs How others join Who must be online
Invite friends Your computer: a world of Singleplayer A code, typed in Join a friend You, the whole time
Server The machine of whoever runs rustcraft-server An address, added with Add server That machine
Realm Rustcraft's machines, for you and your members The owner adds you as a member Nobody: it starts when a member joins
Official server Rustcraft's machines, for everyone One click, with a Rustcraft account Nobody: its lobby starts when a player joins

Behind them is the hub (https://hub.rustcraft.dev by default). It is a service, not a place to play: it keeps the Rustcraft accounts, starts the realms and the official server, and relays the packets of Invite friends. The game says "Rustcraft account" where this document says "an account on the hub". docs/MULTIPLAYER.md has the full picture and the names the code uses.

The Multiplayer screen lists your servers with their status: players, latency, or why they cannot be joined. An address is a host name or an IPv4 address, with or without a port (play.example.com, 10.0.0.2:8000); the port is 8000 when it is left out.

The Realms tab lists your realms, the worlds that the hub runs for you, see Realms.

A dedicated server (rustcraft-server --port 8000) listens for the game on UDP port port (8000 by default), and answers the status requests of the server list on UDP port port + 1. Open both in a firewall or a router: a server whose status port cannot be reached, or an older server that has none, shows as "Offline" in the list, and can still be joined.

Servers, realms included, listen on IPv4 only, and the game joins them over IPv4 only: IPv6 is for a later version.

Stopping a dedicated server with Ctrl-C or SIGTERM (what docker stop sends) saves the world and the connected players, then exits. A second signal while it saves exits at once, with status 130.

Each player sets its render distance, from 1 to 64 chunks (12 by default), in Settings > Video or with O and P; the server sends the chunks within it, up to --max-render-distance chunks (64 by default), and the Video tab says when it grants less. A world of Singleplayer grants all 64. A distance of d is (2d + 1)² columns of up to 17 chunks per player, so a high maximum costs the server memory and generation time.

A release comes with an image of the server (game data goes to a volume):

docker run -p 8000:8000/udp -p 8001:8001/udp -v rustcraft:/root/.local/share/rustcraft \
  ghcr.io/c2i-junia/rustcraft/rustcraft-server:v<version>

While a world opens or a server is joined, a card shows each step and can be cancelled with Escape. When it fails, a card says why, with the way back to the list and, when it may help, "Try again":

  • Cannot reach "…": the server did not answer within 10 seconds. Check that it is running and that its two UDP ports, the game port and the game port + 1, are open in its firewall and forwarded by its router.
  • "…" runs another version: join with the same version of Rustcraft as the server.
  • "…" is full: the server has no room for another player; try again later.
  • "…" refused you: the server closed the connection before letting you in, most often because a player with your name is already on it. Change your name with the button under the version on the main menu, or start the game with another one: rustcraft --player-name <name>.
  • Your name is not accepted: a player name has 1 to 32 characters and no control characters. Change it on the main menu, or start the game with another --player-name.
  • Connection to "…" lost, "…" stopped: the server stopped answering, or shut down. Check your network, or ask whoever runs the server, then try again.
  • Cannot open "…" (a world): the world could not be loaded, and the card gives the reason, often its world.ron; or the last world played is still closing, and this one opens in a moment.
  • Disconnected from "…": the server dismissed you, and the card gives its reason: an operator kicked or banned you, or the server keeps a whitelist you are not on.

Inviting friends to a world of Singleplayer

You can invite friends to a world of Singleplayer, even when neither of you can take a connection in, as on a phone's 4G: the game goes through a relay of the hub. Both players need an account on the hub (Accounts).

  • Invite friends, in the game menu of your world, gives a code such as K7Q-4PM, shown under the button with Copy code. Give it to your friends. Stop inviting closes the world again, and leaving the world closes it too.
  • Your friends click Join a friend on the Multiplayer screen and type it, with or without the dash, in any case. The world is not added to their server list.
  • The packets of the game go through the hub's relay (UDP port 24000), which forwards them between you without reading them; your world stays on your computer.
  • Limits: the packets are not encrypted, and the code is the key: anyone who has it joins while the world is open, so give it only to your friends, and close the world when they have left. A world takes 4 friends at once. They see at most 12 chunks around them; you keep your own render distance. Your friends are not operators of your world and their chat has the limits of any server; you keep the rights of Singleplayer.

Operators, bans and the whitelist

On a dedicated server, the commands are its operators': /gamemode, /give, /time, /weather, /difficulty, /locate, /tp, the commands of the mods and those below. Any other player is answered "You must be an operator to use /…"; /list, the players online, is everyone's. In Singleplayer you are always an operator.

Command What it does
/op <player>, /deop <player> Makes a player an operator, or no longer one.
/kick <player> [reason] Disconnects a player, who sees the reason.
/ban <player> [reason], /pardon <player> Bans a player, disconnected if online and refused when joining with the reason, until pardoned.
/whitelist on|off|list, /whitelist add|remove <player> When the whitelist is on, only the players on it, and the operators, may join.

Names are compared without their case, and one that holds spaces is typed between quotes (/kick "Bad Guy"). The lists are kept in the game folder of the server, next to saves/: ops.ron, banned.ron and whitelist.ron, read when it starts and written at each change; a server whose list cannot be read does not start. The first operator is made with rustcraft-server --op <name>, or by writing ops.ron (["name"]) while the server is stopped.

On a server started with --auth hub a player is its account, not its name: the lists hold entries (id: "<account uuid>", name: "<name>"), an operator stays one when it changes its name, and a player's file is players/<account uuid>.ron (one named after its id by an earlier version is moved there). /op, /ban, /whitelist add and the like find the account of the name among the players online, or ask the hub for it (GET /v1/profiles?name=) and answer when the hub has; --op <name> asks it before the server starts, which fails when the hub does not know the name. A plain name in a list matches the account of that name when it first joins, and is rewritten with its account then. /deop, /pardon and /whitelist remove take first an entry of the name as the list holds it, the name the account had when it was last seen on the server, which the hub may have given to another account since; they ask the hub only when no entry has that name.


Accounts

An account lives on a hub, https://hub.rustcraft.dev by default. It gives you a name no one else can use on the servers that ask for accounts, and it is what the worlds of the hub know you by. You do not need one to play alone or on a server that takes anyone.

The name button under the version on the main menu opens the Account dialog:

  • Create account: a username of 3 to 20 characters and a password of at least 10 (typed hidden). The hub then shows a recovery code, once: write it down. It is the only way back into the account if you forget the password.
  • Log in with them, on this computer or another; a session lasts 90 days after its last use.
  • Recover account: your username, the recovery code and a new password. This ends the other sessions of the account and gives you a new recovery code.
  • Log out, and Play offline as..., which only changes the name you play under without an account.

The game keeps your session in account.ron of the game folder, and asks the hub for a certificate of your game, good for 7 days, that servers check without calling the hub; it renews it in the background. A server that asks for accounts (--auth hub) takes you under your account's name. A server that takes anyone (--auth offline) knows you by your account while you are logged in and by your name while you are not: there you are two players, each with its own inventory and position. Your solo worlds know you by the name you play under (the account's while logged in), never by the account. The hub keeps your username, a hash of your password and of the recovery code, and when you signed up or logged in, with no address (it counts sign-ups per address, but stores only a keyed hash). Too many sign-ups or failed logins from one address in a short while are refused for a time.

Realms

A realm is a world that the hub runs for you, so that you need neither a server of your own nor an open port. Realms are on the Realms tab of the Multiplayer screen, when you are logged in:

  • The list shows the realms you own and those you are a member of, with their state (stopped, starting, running) and your role. Join starts a stopped realm, waits for it, up to a minute, and joins it. Any member can start a realm.
  • A realm has an owner, operators and members. Only they can join; the owner adds players by their username (Members), makes them operators or members again and removes them. Operators have the commands of an operator, as on any server. The owner changes the members from the game, not with /op, /ban or /whitelist.
  • Create a realm (a name, an optional seed, a game mode, a difficulty and a world type) is for accounts that have been given the host role ("Realm creator" in the web admin), up to their quota of realms; ask whoever runs the hub. Stop has the realm save and stop, and Delete archives it: it leaves your list, and the hub keeps its files for 30 days before it removes them.
  • A realm that nobody plays for 10 minutes stops by itself, after saving, and the hub runs a few at a time (3 on the official one): if they are all taken, starting another says so; try again later.

Whoever runs a hub installs it by the guide in hub/README.md.

Saves

Each world has its own folder under saves/: world.ron holds the metadata (name, seed, time, mobs, game mode, difficulty), chunks/ has one file per region of 8×8×8 chunks, containers/ and furnaces/ what the chests and the furnaces of a chunk hold, and players/ one file per player. The game saves every 60 seconds, when a player leaves and when the game is closed. "Save now" in the game menu saves at once and says when the world is written. Closing the window in a world saves it first, with a card saying so; closing it again quits at once. Worlds saved by older versions are converted on their first load, and the old file is kept as world.ron.legacy. The Singleplayer screen writes world.ron when it creates a world, renames the folder and the name in world.ron when it renames one, and deletes the folder, after asking, when it deletes one. The server list is servers.ron, in the game folder: the Multiplayer screen writes it at once after every add, edit and remove.

The settings are saved as soon as they change, in the game folder: keybindings.ron, audio.ron, interface.ron (UI scale, inventory tweaks), view.ron (mouse sensitivity, field of view, fullscreen) and video.ron (render distance, clouds, shaders and the other video settings). The bookmarks of the item browser are kept there too, in item_browser.ron: one list per world, by its name, and per server, by its address.

The player's name is saved in player.ron, in the game folder. On the first launch the main menu asks for it; the button showing it, under the version, opens the Account dialog: log in to or create an account of the hub, recover one with its recovery code, or log out. "Play offline as..." there changes the name. Logged in, the name is the account's username. --player-name <name> plays under another name for one run, without saving it, and the button then changes the name only. Each world keeps a player's position and inventory under their name: a new name starts afresh.


Command-line options

Both executables print their options with --help and their version with --version. Under cargo run, the options go after --, as in the client recipe of the Justfile: cargo run -p client --bin client -- --player-name PlayerOne.

The game folder holds the saves and the settings. By default it is $XDG_DATA_HOME/rustcraft (~/.local/share/rustcraft) on Linux, %APPDATA%\rustcraft on Windows and ~/Library/Application Support/rustcraft on macOS.

Client

rustcraft [OPTIONS]

Option Description
-g, --game-folder-path <path> The game folder to use instead of the default one. Several clients on one machine each need their own, as just client 1 and just client 2 have.
-a, --assets-folder-path <path> The folder the textures are read from. By default, the data folder shipped with the game.
-p, --player-name <name> Plays under this name for one run, without saving it, instead of the one in player.ron.
--use-custom-textures Reads the block and item textures from graphics/custom_textures/ of the assets folder instead of graphics/base_textures/.

Server

rustcraft-server [OPTIONS]

Option Default Description
-p, --port <port> 8000 The UDP port of the game. The server also answers the status requests of the server list on port + 1 (see Multiplayer).
-w, --world <name> default The world to load from saves/<name> in the game folder, created when it does not exist yet.
-g, --game-folder-path <path> see above The game folder to use instead of the default one.
--max-render-distance <chunks> 64 The largest render distance a player may ask for, in chunks.
--max-players <count> 64 The most players connected at once, from 1 to 64. The server list shows it.
--seed <number> random The seed of the world, when it is created.
--world-type <type> default The type of the world, when it is created: default, large-biomes, archipelago or single-biome.
--biome <key> The biome of a single-biome world, such as plains.
--game-mode <mode> survival The game mode of the players, when the world is created: survival or creative.
--difficulty <level> normal The difficulty, when the world is created: peaceful, easy, normal or hard.
--op <name> Makes this player an operator, in ops.ron of the game folder, before the server starts: how a server gets its first operator. May be given several times.
--auth <mode> offline Who may join: offline takes anyone under the name they give; hub takes only the players logged in to an account of the hub, under its name.
--hub <url> https://hub.rustcraft.dev The hub whose accounts join with --auth hub: an https:// URL, or http:// to this computer only.
--public-address <host[:port]> An address players join this server at, as they type it (port 8000 when left out). Needed with --auth hub, may be given several times: a player's proof is made for the address they dialed, and one made for another is refused.
--realm <uuid> Runs the realm of this id of the hub, with --auth hub; its token is read from the environment variable RUSTCRAFT_REALM_TOKEN, never from an option. Not with --op.

The options about the seed, type, game mode and difficulty apply only to a world that is created: a world that already exists keeps its own, and the server logs a warning.

With --auth hub, a player proves its account with the certificate the hub gave its game and a signature of the server's challenge, so the server calls the hub only at start, for its keys, and every hour, for the revoked certificates. The keys are kept in hub_keys.ron of the game folder for a start while the hub cannot be reached; a server that has neither does not start. A server in hub mode has its own key in server_key.ron, made at its first start. A hosted world (--realm) reads its members from the hub (GET /v1/realms/<id>/config, with Authorization: Realm <token>) when it starts, which it refuses to do without, and every minute: the whitelist is on and holds exactly the members, and the operators are its operator members and its owner. It reads and writes no ops.ron, banned.ron nor whitelist.ron, and /op, /deop, /ban, /pardon and /whitelist only answer that the members are managed from the Hosted worlds tab of the game. A member removed is dismissed with "You were removed from this world."; a failed read keeps the last members, and a hub that refuses the token or does not know the world (deleted, token renewed) stops the server after saving. Whatever the mode, a client that has not joined 5 seconds after connecting is let go.

A proof is accepted for every address of --public-address. A loopback, private or link-local address (localhost, 127.0.0.1, 192.168.1.10, [fd00::1]) is also that of servers on other networks: listed beside a public one, it lets a server at the same address elsewhere, run by anyone, pass this one the proofs of the players who join it, and so join here under their accounts. List such an address only for a server reached on its own network; the server logs a warning when local and public addresses are mixed.

Both executables also read the RUST_LOG environment variable to choose what they log, e.g. RUST_LOG=server=debug,warn rustcraft-server.


Running a server with Docker

The image ghcr.io/<owner>/rustcraft/rustcraft-server (built from the Dockerfile; :latest and :<version> for a release, :dev-<commit> for the commits of main that change the server) runs the dedicated server as the user rustcraft (uid 10001). Everything it writes goes to the volume /data, so the container can run with a read-only root filesystem:

docker run -d --name rustcraft --read-only \
    -v rustcraft-data:/data -p 8000:8000/udp -p 8001:8001/udp \
    ghcr.io/<owner>/rustcraft/rustcraft-server

Publish the game port and the status port next to it, both in UDP. The arguments after the image name replace the default --world world --port 8000 and are those of the server, e.g. --world survival --seed 42 --max-players 8 --op Alice. A bind mount must be writable by uid 10001. The logs go to stdout (docker logs), and docker stop saves the world and exits with status 0.


How to Build

Prerequisites

To build and run this project, you need the following tools and dependencies installed:

1. Rust

  • Install Rust using Rustup
  • The repository pins its nightly toolchain (with the Cranelift backend) in rust-toolchain.toml: rustup installs it automatically on the first cargo command run in the repository, with the wasm32-wasip2 target the mods are built for. A toolchain installed otherwise needs that target too: rustup target add wasm32-wasip2.

2. Just

  • Just is used in this project to manage build. Install it using Cargo:
    cargo install just
    

Note: You can also install Just using your system's package manager.

3. Dependencies

Install the required dependencies based on your operating system:

Windows

  • Git Bash is required to ensure the commands in the Justfile and scripts run correctly. Download and install Git Bash.
  • After installation, make sure Git Bash is added to your system's PATH. You can verify it by running:
    bash --version
    

Arch Linux

sudo pacman -S base-devel mold clang vulkan-radeon vulkan-tools vulkan-swrast
  • vulkan-swrast is the software renderer the UI screenshot tests draw with.
  • Replace vulkan-radeon with:
      - vulkan-intel for Intel GPUs.
      - nvidia-utils for NVIDIA GPUs.

Ubuntu/Debian

sudo apt install -y build-essential mold clang mesa-vulkan-drivers vulkan-tools pkg-config libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev libfontconfig1-dev
  • For NVIDIA GPUs, also install:
    sudo apt install -y nvidia-driver nvidia-vulkan-icd
    

Fedora

sudo dnf install gcc gcc-c++ mold clang pkgconf-pkg-config alsa-lib-devel systemd-devel wayland-devel libxkbcommon-devel fontconfig-devel mesa-vulkan-drivers vulkan-tools
  • mesa-vulkan-drivers also provides lavapipe, the software renderer the UI screenshot tests draw with.
  • For NVIDIA GPUs, install the driver from RPM Fusion (akmod-nvidia).

Running the Project

To compile and run the game locally, use the following commands:

Note: the first compilation will be slow depending on your hardware, next compilations will be incremental and thus faster.

# Clone the repository
git clone https://github.com/c2i-junia/rustcraft

# Navigate to the project directory
cd rustcraft

The commands are recipes of just (cargo install just); just --list lists them all.

just play                    # the client at release speed, quick to rebuild: to play and test

just client                  # the client in debug, with the debug logs of the game
just client 2                # a second client, with its own game folder and name
just server                  # (optional) a dedicated server on port 8000, to test multiplayer

just profile=play client 2   # `client` and `server` in another profile: play or release

Release mode:

# Build the project in release mode
just generate-release-folder

# Run the executable
./release/bin/rustcraft         # run the client

./release/bin/rustcraft-server  # (optional) do this only to test multiplayer features

Mods

The mods of the packs (data/content/<pack>/mod/) are built to .wasm files beside their pack, which git ignores: just play, just debug, just release, just test, just check and the release folders build them first.

just build-mods              # every pack; `just build-mods abyss` for one
just mod-dev abyss           # rebuilds the pack at each save: a running game loads it a moment later
just check-content           # also loads the built mods and runs their init

In a running game or server, /reload reads the content files and the mods again. How to write a mod: docs/MODS.md.


Contributing

Feel free to submit issues or open pull requests. If you want to know where to help, refer to the existing issues.

docs/ARCHITECTURE.md explains how the crates fit together, the order of a server tick and of a client frame, and the save format.

Guidelines

Checks

Run just check before committing: it checks the formatting (cargo fmt), runs clippy without any warning allowed, and runs the tests (just test). The CI runs the same three steps.

just test runs every test, the client's beside the other crates' rather than after them: about 4 minutes on 32 threads. While working, just test-fast runs the tests without the end-to-end ones of client/src/e2e/ (docs/TESTING.md): about 10 s.

UI tests

On Linux, the tests also draw the UI off screen and compare it with golden screenshots, and end-to-end tests drive the whole client like a player. How they work, how to write one and how to update the goldens: docs/TESTING.md.

Commit messages:

  • We follow the Conventional Commit specification. Our commit types are inspired by the Karma specification

    <type>[optional scope]: <description>
    
    [optional body]
    
    [optional footer(s)]
    

    Allowed values:

    • feat for a new feature for the user, not a new feature for build script. Such commit will trigger a release bumping a MINOR version.
    • fix for a bug fix for the user, not a fix to a build script. Such commit will trigger a release bumping a PATCH version.
    • perf for performance improvements. Such commit will trigger a release bumping a PATCH version.
    • docs for changes to the documentation.
    • style for formatting changes, missing semicolons, etc.
    • refactor for refactoring production code, e.g. renaming a variable.
    • test for adding missing tests, refactoring tests; no production code change.
    • build for updating build configuration, development tools or other changes irrelevant to the user.
  • Write commit messages in the present tense (e.g., "Add feature X" instead of "Added feature X").

Branches

  • Use the naming convention <type>/<name> for branches introducing new features. Only use lowercase letters, numbers, and dashes.
  • The main branch should always compile successfully and be free of warnings. Use cargo check.
  • Experimental branches are allowed to include code that does not build successfully.
  • Prefer rebasing over merging.

Explore related projects

Loading…