Rusted
Rusted is a Minecraft: Bedrock Edition server written in Rust, ported from PowerNukkitX. It supports Bedrock 1.26.60.
It's an alpha. You can join, survive, build redstone, go to the Nether and the End and trade with villagers, but some features are still missing or simpler than in PNX. The porting status page lists what's done.
Where to start
- Running a server: Getting started, then Configuration.
- Hosting it for friends: Hosting on a VPS.
- Writing plugins: Your first plugin.
Links
- Source code: github.com/RustedMC/Rusted
- Discord: discord.gg/HBegxHxREc
- Bugs and ideas: GitHub issues
Getting started
What you need
- Rust (stable)
- On Windows, the Visual Studio C++ build tools (rustup offers to install them)
- Git
Build and run
git clone https://github.com/RustedMC/Rusted.git
cd Rusted
cargo run --release
The first build takes a few minutes. After that the server starts in a couple of seconds.
Join
In Minecraft, go to Play → Servers → Add Server and enter:
- Address: your machine's IP (
127.0.0.1if Minecraft runs on the same PC) - Port:
19132
Files it creates
| File / folder | What it is |
|---|---|
server.properties | Settings, see Configuration |
identity.pem | The server's private key. Don't share it. |
worlds/ | Your worlds |
players/ | Player inventories, XP and positions |
ops.txt, whitelist.txt, banned-players.txt | Operators, allowlist and bans |
plugins/<name>/config.txt | Plugin settings |
Structures
Mansions, end cities, bastions and a few other structures need a template file,
data/structures.nbt, which isn't in the repo yet. Without it those structures are skipped
and everything else generates normally.
Stopping
Press Ctrl+C. The server saves the world and every player before it exits.
Configuration
Settings live in server.properties, created with defaults on the first run. It uses the
same key=value format as vanilla and PNX. Restart the server after editing.
| Key | Default | What it does |
|---|---|---|
server-port | 19132 | Port players connect to (UDP and TCP) |
motd | Rusted | Server name in the server list |
sub-motd | Rusted | Second line in the server list |
max-players | 35 | Player limit |
level-name | world | World folder under worlds/ |
level-type | normal | normal, legacy, flat, void, or a plugin generator. Only used when the world is created. |
level-seed | (empty) | Number or text. Empty picks a random seed. Only used when the world is created. |
flat-layers | bedrock,2*dirt,grass_block | Layers for flat worlds, bottom up |
gamemode | survival | Default game mode for new players |
difficulty | normal | peaceful, easy, normal or hard |
view-distance | 16 | Max chunk radius sent to each player (2–96) |
white-list | false | Only players in whitelist.txt can join |
spawn-protection | 16 | Radius around the world spawn where only operators can build. 0 turns it off |
pvp | true | Players can hurt each other |
plugins | false | Loads the built-in plugins (lobby, economy, ranks, kits, homes, auction house, scoreboard...). Off so a fresh server is plain vanilla |
backup-interval | 60 | Minutes between world backups into backups/. 0 turns them off |
backup-keep | 5 | How many backups to keep; the oldest are deleted |
player-idle-timeout | 0 | Kick players who don't move for this many minutes. 0 = never. Operators are never kicked |
join-message | §e{player} joined the game | Chat message when someone joins. {player} is their name; empty for none |
leave-message | §e{player} left the game | Same, when someone leaves |
enable-rcon | false | Remote console for hosting panels and tools like mcrcon |
rcon.port | 25575 | TCP port for RCON |
rcon.password | (empty) | Required: RCON won't start without one |
Console
Run start.bat (Windows) or ./start.sh (Linux) and type commands straight into the window,
without a /: help, op Steve, say hello, stop. Commands from the console run as an
operator. If the server crashes, the start script starts it again; stop shuts it down for
good.
Remote console (RCON)
Set enable-rcon=true and a strong rcon.password, restart, and connect with any RCON client,
for example mcrcon -H your.server -P 25575 -p yourpassword "list". Don't open the RCON port to
the internet unless you need to.
Operators
Players in ops.txt (one name per line) can use admin commands. Add someone in game with
/op <name>, or from the console.
Allowlist and bans
/whitelist on,/whitelist add <name>,/whitelist remove <name>/ban <name>,/pardon <name>
Hosting on a VPS
These steps are for Debian or Ubuntu. Other Linux distros work the same way with their own package manager.
1. Build
sudo apt install build-essential git
curl https://sh.rustup.rs -sSf | sh
git clone https://github.com/RustedMC/Rusted.git && cd Rusted
cargo build --release
2. Install as a service
Run it as its own user, so a bug in the server can't touch the rest of the machine:
sudo useradd -r -m -d /opt/rusted rusted
sudo cp target/release/rusted /opt/rusted/ && sudo cp -r data /opt/rusted/
sudo chown -R rusted: /opt/rusted
sudo cp deploy/rusted.service /etc/systemd/system/
sudo systemctl enable --now rusted
The service starts on boot and restarts by itself if the server crashes. Stopping it saves the world and players first.
3. Open the port
sudo ufw allow 19132
Open both UDP and TCP 19132, here and in your provider's firewall panel if it has one.
Newer clients join over TCP, older ones over UDP.
Everyday use
| Task | Command |
|---|---|
| Watch the logs | journalctl -u rusted -f |
| Restart | sudo systemctl restart rusted |
| Change settings | edit /opt/rusted/server.properties, then restart |
Updating
cd Rusted && git pull && cargo build --release
sudo cp target/release/rusted /opt/rusted/
sudo systemctl restart rusted
Hosting at home
The same steps work on any Linux machine. Friends outside your network also need you to
forward port 19132 (UDP and TCP) on your router to that machine.
Commands
Rusted uses the vanilla Bedrock commands and syntax, so most guides for vanilla commands apply here. A few examples:
| Command | Example |
|---|---|
/gamemode | /gamemode creative @s |
/tp | /tp Steve 0 80 0 |
/give | /give @p diamond 5 |
/time | /time set night |
/weather | /weather rain |
/gamerule | /gamerule keepInventory true |
/effect | /effect @a speed 30 1 |
/summon | /summon zombie ~ ~ ~ |
/scoreboard | /scoreboard objectives add kills playerKillCount Kills |
/whitelist | /whitelist add Steve |
Two commands are Rusted's own:
/pllists loaded plugins/vershows the Rusted version
Target selectors
@p (nearest), @a (everyone), @r (random) and @s (yourself) work, with filters like
name=, r=, c= and scores=:
/tp @a[name=!Steve] 0 80 0
/give @a[r=10] bread 3
Selectors only pick players for now. @e works like @a, mobs aren't selectable yet.
Not there yet
/execute, /locate and /function aren't ported yet. See Porting status.
Your first plugin
Plugins are Rust code compiled into the server. There's no separate plugin jar or loader yet: you add your plugin to the source and rebuild.
Plugins only load when plugins=true is set in server.properties (it's off by default, so a
fresh server is plain vanilla).
1. Write it
Make a new file, src/greeter.rs:
#![allow(unused)] fn main() { use crate::players::{PlayerInfo, Server}; use crate::plugin::Plugin; pub struct Greeter; impl Plugin for Greeter { fn name(&self) -> &str { "greeter" } fn on_join(&self, server: &Server, player: &PlayerInfo) { server.broadcast(&format!("§e{} joined the game", player.name)); server.tell(player.id, "§aWelcome! Type /help to get started."); } } }
Every event has a default that does nothing, so you only write the ones you need.
Plugin info
These are optional, and /pl shows the name and version:
#![allow(unused)] fn main() { fn version(&self) -> &str { "1.2.0" } fn description(&self) -> &str { "Greets players" } fn authors(&self) -> &[&str] { &["Steve"] } /// Needed: if "economy" isn't loaded, this plugin isn't either. fn depends(&self) -> &[&str] { &["economy"] } /// Used if present: loads first when it's there, ignored when it isn't. fn soft_depends(&self) -> &[&str] { &["chat-format"] } }
Plugins load in dependency order: a plugin's on_server_start runs after the plugins it
depends on, and its on_server_stop runs before theirs.
To talk to another plugin, look it up by name with server.plugins.get("economy").
2. Register it
In src/main.rs, add the module next to the others:
#![allow(unused)] fn main() { mod greeter; }
Then add it to all() in src/plugin.rs:
#![allow(unused)] fn main() { pub fn all() -> Vec<Box<dyn Plugin>> { vec![Box::new(crate::greeter::Greeter)] } }
3. Build and test
cargo run --release
Join the server and you'll see the greeting. /pl lists loaded plugins, so greeter should
show up there.
Next
- Events: everything a plugin can react to
- Commands: adding your own
/commands - Scheduler: running things later or on a timer
Events
Override any of these methods on your Plugin. Every one has a default that does nothing.
Cancellable events return bool: return false to stop the action. Events that pass a
&mut String let you rewrite the text.
Priority
When several plugins handle the same event, they run by priority:
#![allow(unused)] fn main() { fn priority(&self) -> Priority { Priority::High } }
| Priority | Use it for |
|---|---|
Lowest, Low | Runs first. Good for setting things up that others may override. |
Normal | The default. |
High, Highest | Runs later, so it gets the final say. Protection plugins usually go here. |
Monitor | Runs last, only for events nobody cancelled. Its bool is ignored. Use it for logging and stats, never to change anything. |
The first plugin that returns false cancels the event, and plugins after it don't see it.
Plugins with the same priority run in load order.
Players
| Method | When | Cancel / edit |
|---|---|---|
on_pre_login(server, name, xuid) -> Option<String> | Someone is logging in, before they join | Return a message to refuse them |
on_join(server, player) | Player finished joining | |
on_leave(server, player) | Player left, kicks and disconnects included | |
on_chat(server, player, message: &mut String) -> bool | Before a chat message is shown | Edit message, or false to block it |
on_command_preprocess(server, player, line: &mut String) -> bool | A typed command (without /), before it runs | Rewrite line, or false to drop it |
on_player_damage(server, player, cause: &str, amount: f32) -> bool | About to take damage. cause is like "fall", "lava" or "Zombie" | false cancels the damage |
on_player_death(server, player, message: &mut String) | Player died | Edit the death message, empty hides it |
on_player_respawn(server, player) | Player respawned | |
on_player_interact(server, player, pos, item: &str) -> bool | Right-clicking a block holding item | false means nothing happens |
on_item_use(server, player, item: &Stack) -> bool | Right-click with an item in hand, in the air or on a block | false cancels the normal use |
on_gamemode_change(server, player, mode: &str) -> bool | Game mode about to change to "survival", "creative"... | false keeps the old mode |
on_item_drop(server, player, item: &str, count: i8) | Player threw items out of their inventory | |
on_item_pickup(server, player, item: &str, count: i8) -> bool | About to pick up items off the ground | false leaves them there |
on_move(server, player, to) -> bool | Moved (to is the eye position) | false puts them back |
on_sneak(server, player, sneaking: bool) | Started or stopped sneaking | |
on_sprint(server, player, sprinting: bool) | Started or stopped sprinting | |
on_held_change(server, player, slot: u32, item: Option<&str>) | Switched hotbar slot or what's in hand | |
on_consume(server, player, item: &str) -> bool | Finished eating or drinking | false: nothing is eaten |
on_container_open(server, player, pos, block: &str) -> bool | Opening a chest, furnace or other block screen | false keeps it shut |
on_teleport(server, player, to) | Teleported (commands, pearls, plugins), feet position | |
on_dimension_change(server, player, to: u8) | Went to another dimension: 0 overworld, 1 Nether, 2 End | |
on_xp_change(server, player, points: &mut i32) | Getting XP (negative takes it away) | Change points, 0 cancels |
on_sign_change(server, player, pos, front: &mut String, back: &mut String) -> bool | Wrote a sign | Edit the text, or false keeps the old text |
on_bed_enter(server, player, pos) -> bool | Right-clicked a bed (sets spawn) | false stops it |
on_craft(server, player, item: &str, count: i32) -> bool | Crafting something at a table or in the inventory | false refuses the craft |
on_projectile_hit(server, shooter, target: Target) -> bool | Their arrow or trident hit Target::Mob(id) or Target::Player(id) | false: no damage |
Blocks
| Method | When | Cancel |
|---|---|---|
on_block_break(server, player, pos, block: i32) -> bool | Player breaking a block | false cancels |
on_block_place(server, player, pos, block: i32) -> bool | Player placing a block | false cancels |
pos is (x, y, z) as i32. block is the block's runtime id.
Mobs and the world
| Method | When | Cancel |
|---|---|---|
on_entity_damage(server, player, mob: i64, kind: &str, damage: f32) -> bool | Player hitting a mob, e.g. kind = "minecraft:cow" | false cancels the hit |
on_entity_death(server, kind, pos, killer: Option<i64>) | Mob died. killer is the player id if a player did it | |
on_entity_spawn(server, kind, pos) -> bool | Mob about to spawn (natural, /summon, breeding) | false stops it |
on_explosion(server, pos, power: f32) -> bool | Creeper, TNT or respawn anchor about to explode | false stops it |
on_mob_target(server, mob: i64, kind: &str, player) -> bool | A hostile mob wants to go after a player | false leaves them alone |
on_block_burn(server, pos, block: &str, spread: bool) -> bool | Fire spreading to a block (spread) or burning one away | false stops it |
on_explosion_blocks(server, at, blocks: &mut Vec<pos>) | An explosion is about to break these blocks | Remove positions to keep them, clear for no block damage |
on_entity_tame(server, player, mob, kind) -> bool | Trying to tame a wolf, cat or horse | false stops it |
on_entity_breed(server, kind, parents) -> bool | Two mobs are about to breed | false: no baby |
on_portal_create(server, player, kind: &str) -> bool | Lighting a "nether" or "end" portal | false keeps it unlit |
on_block_grow(server, pos, from: &str, to: &str) -> bool | A block changes by itself: crops, saplings, grass spreading, leaves decaying, ice melting | false keeps it as it is |
on_weather_change(server, weather: &str) -> bool | Weather changing to "clear", "rain" or "thunder" | false keeps it |
| on_mob_damage(server, mob, kind: &str, damage, from) -> bool | A mob is hurt by anything but a player: another mob, fire, a fall, an explosion | false cancels the damage |
| on_inventory_action(server, player, action: &str, container: &str) -> bool | A player moves items in any screen. action is "take", "place", "swap", "drop", "destroy", "craft" or "other" | false undoes the move |
| on_chunk_load(server, player, chunk: (i32, i32)) | A chunk is sent to a player as it comes into view | |
Mob positions are (f32, f32, f32).
Server
| Method | When |
|---|---|
on_server_start(server) | Worlds loaded, about to accept players. A good place to start scheduled tasks. |
on_server_stop(server) | Server stopping, before the final save |
Example: a no-grief zone
#![allow(unused)] fn main() { fn on_block_break(&self, server: &Server, player: &PlayerInfo, pos: (i32, i32, i32), _block: i32) -> bool { let (x, _, z) = pos; let in_spawn = x.abs() < 50 && z.abs() < 50; if in_spawn { server.tell(player.id, "§cYou can't build at spawn."); } !in_spawn } }
The server handle
Every event gets server: &Server. It's how a plugin talks to the game.
Players
| Call | Does |
|---|---|
server.tell(id, "text") | Message one player |
server.broadcast("text") | Message everyone |
server.get(id) -> Option<PlayerInfo> | Look up a player by id |
server.find_by_name("Steve") -> Option<i64> | Player id from a name |
server.all() -> Vec<PlayerInfo> | Everyone online |
Messages support Minecraft colour codes with §, like §a green, §c red, §e yellow and
§l bold.
PlayerInfo
| Field | Type | |
|---|---|---|
id | i64 | Runtime id, use it with tell, get and forms |
name | String | Gamertag |
uuid | Uuid | |
xuid | String | Xbox user id, stable across name changes |
pos | (f32, f32, f32) | Position |
rot | (f32, f32) | Pitch and yaw |
World
| Call | Does |
|---|---|
server.set_block(by, x, y, z, block) | Place a block and update it. by is the player id responsible, or 0 |
server.set_block_quiet(by, x, y, z, block) | Same, without block updates |
server.occupied(x, y, z) -> bool | Is there a player or mob in that block |
server.time() -> i32 | Time of day in ticks |
server.set_time(ticks) | Set the time of day |
Other handles
server.scheduler: run code later or on a timer, see Schedulerserver.plugins: the loaded pluginsserver.world,server.mobs,server.containers: lower-level access to the world, mobs and chests. These are less stable than the calls above and may change between versions.
Commands
A plugin adds commands with two methods: commands() lists them (for autocomplete), and
on_command() runs them.
#![allow(unused)] fn main() { impl Plugin for Spawn { fn name(&self) -> &str { "spawn" } fn commands(&self) -> Vec<(&'static str, &'static str)> { vec![ ("spawn", "Teleport to spawn"), ("online", "List players online"), ] } fn on_command(&self, server: &Server, player: &PlayerInfo, name: &str, args: &[&str]) -> Option<String> { match name { "online" => { let names: Vec<String> = server.all().into_iter().map(|p| p.name).collect(); Some(format!("Online ({}): {}", names.len(), names.join(", "))) } "spawn" => { // args are the words after the command: /spawn foo bar -> ["foo", "bar"] let _ = args; Some("§aOff you go!".into()) } _ => None, } } } }
nameis the command without the/.argsis the rest of the line, split on spaces.- Whatever text you return is sent to the player who typed it. Return
Noneto send nothing.
If two plugins register the same command, the first one in all() handles it.
To change or block other commands before they run, use
on_command_preprocess.
Permissions
Permissions are dot-separated names like homes.set or homes.admin.delete. A plugin
declares the ones it uses and who gets them by default:
#![allow(unused)] fn main() { use crate::plugin::Access; fn permissions(&self) -> Vec<(&'static str, Access)> { vec![ ("homes.set", Access::Everyone), ("homes.others", Access::Ops), ] } }
| Access | Default |
|---|---|
Everyone | Every player has it |
Ops | Only operators (ops.txt) |
Nobody | Nobody, unless granted in permissions.txt |
Permissions nobody declared count as Ops.
Protecting a command
#![allow(unused)] fn main() { fn command_permission(&self, command: &str) -> Option<&'static str> { match command { "sethome" => Some("homes.set"), "home" => None, // anyone _ => None, } } }
Players without the permission get "You do not have permission to use this command" and your
on_command isn't called.
Checking in code
#![allow(unused)] fn main() { if server.plugins.allowed(&player.name, "homes.others") { // ... } }
permissions.txt
Server owners grant or take away permissions in permissions.txt, next to ops.txt. It has
one <player> <permission> per line:
# Steve can do everything in homes, except delete
Steve homes.*
Steve -homes.delete
# Alex has every permission
Alex *
-in front takes a permission away, even from ops.homes.*matches every permission starting withhomes..- The most specific line wins, so
homes.deletebeatshomes.*, which beats*. - Names aren't case-sensitive.
- The file is re-read automatically when it changes, so no restart is needed.
Scheduler
server.scheduler runs code on the game tick. There are 20 ticks a second, so 20 is one
second and 1200 is one minute.
Run once, later
#![allow(unused)] fn main() { server.scheduler.run_later(100, |server| { server.broadcast("Five seconds have passed."); }); }
Run on a timer
run_repeating(delay, period, f) waits delay ticks, then runs f every period ticks.
Return false from f to stop.
#![allow(unused)] fn main() { fn on_server_start(&self, server: &Server) { server.scheduler.run_repeating(20 * 60, 20 * 60 * 10, |server| { server.broadcast("§7Remember to vote for the server!"); true // keep going }); } }
Cancel
Both calls return an id:
#![allow(unused)] fn main() { let id = server.scheduler.run_repeating(20, 20, |_| true); // later server.scheduler.cancel(id); }
Slow work
Tasks run one after another on the tick thread, so something slow, like a web request or a
database query, holds up the whole server. Use run_async for that. The first closure runs on
its own thread. The second gets the result back on the tick, where it's safe to touch players
and the world:
#![allow(unused)] fn main() { let name = player.name.clone(); let id = player.id; server.scheduler.run_async( move || look_up_rank_online(&name), // own thread: don't touch the server here move |server, rank| server.tell(id, &format!("Your rank: {rank}")), ); }
Tasks need to be Send + 'static, so move what they need into the closure (move |server| ...)
and use Arc for anything shared.
Config files
Plugins get a simple settings file at plugins/<name>/config.txt, with one key = value per
line. Lines starting with # are comments.
#![allow(unused)] fn main() { use crate::plugin::Config; fn on_server_start(&self, server: &Server) { let mut config = Config::load("greeter"); let message = config.get_or("join-message", "Welcome to the server!"); let _ = config.save(); // writes the defaults so server owners can see every setting // ... } }
| Call | Does |
|---|---|
Config::load("name") | Read plugins/name/config.txt. A missing file is fine, you get an empty config. |
config.get("key") -> Option<&str> | The value, if set |
config.get_or("key", "default") -> String | The value, or default. The default is also added to the file on the next save(). |
config.set("key", "value") | Change a value |
config.save() | Write the file, creating the folder if needed |
Saving data per player
Config::player gives each player their own file for your plugin, at
plugins/<name>/players/<player>.txt. It's keyed by Xbox id, so the data survives name changes.
#![allow(unused)] fn main() { fn on_join(&self, server: &Server, player: &PlayerInfo) { let mut data = Config::player("greeter", player); let visits: u32 = data.get_or("visits", "0").parse().unwrap_or(0) + 1; data.set("visits", &visits.to_string()); let _ = data.save(); server.tell(player.id, &format!("Visit number {visits}!")); } }
Numbers
Values are text. Parse numbers yourself:
#![allow(unused)] fn main() { let radius: i32 = config.get_or("spawn-radius", "50").parse().unwrap_or(50); }
Items, menus and player control
Rusted ships a small demo plugin, src/demo.rs, that uses everything on this page. Type /lobby in game to try it.
Custom items
plugin::item builds an item with a name, lore and hidden tags only plugins can see:
#![allow(unused)] fn main() { use crate::plugin; let compass = plugin::item("minecraft:compass")? .name("§aServer selector") .lore(&["§7Right-click to pick a game"]) .tag("menu", "servers") .build(); server.give(player.id, compass); }
The tags stay on the item in the player's inventory. Read them back with
plugin::tag(&item, "menu").
Reacting to an item
on_item_use runs whenever a player right-clicks with something in hand, in the air or on
a block. Return false to stop the normal action (placing, eating, shooting):
#![allow(unused)] fn main() { fn on_item_use(&self, server: &Server, player: &PlayerInfo, item: &Stack) -> bool { if plugin::tag(item, "menu").as_deref() == Some("servers") { open_selector(server, player.id); return false; } true } }
Chest menus
ui::menu shows a chest-style menu. Players can't take items out of it. Each click calls
your function with the slot number (0-26). Return false to close the menu:
#![allow(unused)] fn main() { use crate::ui; fn open_selector(server: &Server, to: i64) { let icon = |name: &str, label: &str| plugin::item(name).map(|i| i.name(label).build()); let mut items = vec![None; 27]; items[11] = icon("minecraft:diamond_sword", "§cPvP"); items[13] = icon("minecraft:grass_block", "§aSurvival"); items[15] = icon("minecraft:bow", "§eMinigames"); ui::menu(server, to, "§lPick a game", items, |server, player, slot| { match slot { 11 => server.transfer(player.id, "pvp.example.com", 19132), 13 => server.transfer(player.id, "survival.example.com", 19132), 15 => server.transfer(player.id, "games.example.com", 19132), _ => return true, // empty slot: keep the menu open } false }); } }
Calling ui::menu again while one is open swaps its items, which is how you make
multi-page menus.
Player control
All of these are on server:
| Call | Does |
|---|---|
give(id, item) | Gives an item (from plugin::item); what doesn't fit drops at their feet |
teleport(id, (x, y, z)) | Moves them, feet position |
title(id, "Title", "subtitle") | Big text on screen |
actionbar(id, "text") | Text above the hotbar |
set_gamemode(id, "creative") | Survival, creative, adventure or spectator |
effect(id, effect, amplifier, seconds) | Status effect (ids in effects) |
sound(id, "random.levelup") | A sound only they hear |
kick(id, "reason") | Kicks them |
transfer(id, "address", port) | Sends them to another server: lobbies, minigames, networks |
run_as(id, "any command") | Runs any vanilla command as them, without the op check |
run_as is the catch-all: anything a command can do to a player, a plugin can do too.
Forms, scoreboards and boss bars
Everything here lives in crate::ui.
Forms
Forms are the pop-up menus Bedrock players see. ui::show sends one, and your callback gets
the answer.
Buttons
#![allow(unused)] fn main() { use crate::ui::{self, Form, Response}; let form = Form::Simple { title: "Warps".into(), content: "Where to?".into(), buttons: vec![ ("Spawn".into(), Some("textures/items/compass_item".into())), ("Shop".into(), None), ], }; ui::show(server, player.id, form, |server, player, answer| { match answer { Response::Button(0) => server.tell(player.id, "Going to spawn"), Response::Button(1) => server.tell(player.id, "Going to the shop"), _ => {} // closed } }); }
A button image can be a texture path or an https:// URL.
Yes / no
#![allow(unused)] fn main() { let form = Form::Modal { title: "Reset".into(), content: "Reset your home?".into(), yes: "Reset".into(), no: "Cancel".into(), }; ui::show(server, player.id, form, |server, player, answer| { if answer == Response::Choice(true) { server.tell(player.id, "Home reset."); } }); }
Inputs, toggles and sliders
#![allow(unused)] fn main() { use crate::ui::Element; let form = Form::Custom { title: "Settings".into(), elements: vec![ Element::Label("Pick your options".into()), Element::Input { text: "Nickname".into(), placeholder: "Steve".into(), default: String::new() }, Element::Toggle { text: "Show sidebar".into(), default: true }, Element::Slider { text: "Render distance".into(), min: 4.0, max: 32.0, step: 1.0, default: 16.0 }, Element::Dropdown { text: "Team".into(), options: vec!["Red".into(), "Blue".into()], default: 0 }, ], }; ui::show(server, player.id, form, |server, player, answer| { if let Response::Values(values) = answer { // one JSON value per element, in order. Labels give null. let nickname = values[1].as_str().unwrap_or(""); server.tell(player.id, &format!("Hi {nickname}")); } }); }
| Response | Means |
|---|---|
Button(i) | Simple form, button i pressed |
Choice(bool) | Modal, true for the first button |
Values(vec) | Custom form, one value per element |
Closed | Player closed the form |
Scoreboards
Scoreboards work the same as the vanilla /scoreboard command. From a plugin:
#![allow(unused)] fn main() { ui::set_score(server, "kills", &player.name, 10); // shows right away if displayed let kills = ui::score("kills", &player.name); // Option<i32> }
Create objectives and pick where they show with /scoreboard objectives add and
/scoreboard objectives setdisplay. Scores are saved with the world.
Boss bars
#![allow(unused)] fn main() { // colours: 0 pink, 1 blue, 2 red, 3 green, 4 yellow, 5 purple, 6 white ui::boss_bar(server, player.id, "§6Event ends soon", 0.75, 4); ui::remove_boss_bar(server, player.id); }
percent goes from 0.0 (empty) to 1.0 (full).
Changelog
0.3.0
Mobs
- Mob speeds and attack timing follow PowerNukkitX.
- Wolves, cats, iron golems and flying mobs use the mob brain. Pets sit, fight, follow their owner and catch up when left far behind.
- Skeletons, pillagers, vindicators and piglins hold their weapons.
Blocks and items
- Water and lava flow toward drops and wash away plants, torches and rails, which drop as items. Lava meeting water makes obsidian, cobblestone or stone.
- Pressure plates feel mobs and items. Weighted plates give a signal by count.
- Sculk sensors hear footsteps and blocks changing nearby, and give a redstone signal. Shriekers shriek, give Darkness and call a warden on the fourth warning.
- Firework rockets: craft them, launch them from the ground, fire them from crossbows, and see them while gliding. Bursts with stars hurt what's nearby.
- Arrows fall at vanilla speed.
World generation
- Nether ruined portals.
- End city chests have loot.
- Nether lava springs flow.
- Mineshafts have chest minecarts with loot. Hoppers empty them, and they keep their items over a restart.
Fixes from testing
- Fences, iron bars, glass panes, walls, redstone dust and stairs join their neighbours. Bedrock now expects the server to work these out.
- Structures have their fences back.
- Zombies don't burn at night anymore. The server's clock stops with
doDaylightCycleoff and resyncs with players every 12 seconds. - Survival mining works like vanilla: other players see the cracks, and breaks finish properly.
- Breaking either half of tall grass or a large fern removes both halves.
For server owners
start.batandstart.shopen a console you can type commands into, like PocketMine and PowerNukkitX. They restart the server after a crash.- Automatic world backups (
backup-interval,backup-keep). - RCON for hosting panels (
enable-rcon,rcon.port,rcon.password). spawn-protection,player-idle-timeout, and customjoin-messageandleave-message.- New settings are added to an existing
server.propertiesautomatically. - Quieter console output by default. Set
RUST_LOG=debugfor everything.
Commands and plugins
- Command replies use vanilla wording.
- New plugin events:
on_mob_damage,on_inventory_actionandon_chunk_load.on_container_openalso fires for chest minecarts.
0.2.0
Riding and vehicles
- You now sit in the right spot on horses, donkeys, mules, pigs, striders, camels, boats and minecarts. Before, riders sank into the mob and drifted down into the void.
- Boats and minecarts no longer throw you off with a horse sound.
- In a boat you can only turn your head sideways and forward, as in vanilla.
Blocks
- Placing a block into water, lava, grass or snow layers replaces it.
- Torches, flowers, rails and other blocks you can walk through can be placed where you're standing.
- Redstone dust, repeaters, comparators, string and sugar cane are now placed by the server, so they power and light up.
- New rails now show their turned shape to everyone.
- Flint and steel only makes its own ignite sound.
Items and combat
- Shields and totems go in the offhand. Crouching with a shield raises it.
- A totem of undying plays its pop animation and sound.
- Crossbows load when fully charged.
- Fishing works as in vanilla: a fish swims toward the bobber and bites, and the catch flies out of the water to you. Switching slots reels the line in.
- Beacon effects now apply.
- The creative menu has banners, fireworks, firework stars, enchanted books and other items with data.
- Skeletons, pillagers, vindicators and piglins hold their weapons.
- Knockback uses PowerNukkitX's formula.
World and mobs
- Hostile mobs no longer spawn in daylight under leaves.
- More blocks give off light.
- Creative and spectator players only die from
/killand the void. - Villagers run from zombies, go to their job block by day and look for cover at night.
- Fish dart away from players.
Server
- Going to the Nether or the End loads much faster. It uses the same dimension handshake as PowerNukkitX.
- Logging in again while your old connection is still open drops the old one, so "joined the game" no longer shows twice.
- Command autocomplete shows vanilla arguments, such as
/tp <victim> <destination>and/give <player> <item>. /versionno longer lists credits.
0.1.0
First release.
Porting status
Rusted is a port of PowerNukkitX. The up-to-date breakdown of what's ported, part by part, is kept in the repo:
- PORTING.md: what's done, what's partial
- ROADMAP.md: what's next
In short
Works: overworld, Nether and End generation (seed-exact with PNX), survival, enchanting, brewing, anvils, smithing, effects, bows and tridents, redstone, 71 mob types, villager trading, raids, the dragon fight, vanilla commands with selectors, forms, scoreboards and boss bars, riding and taming horses, boats, minecarts and rails, structure chest loot and spawners, fishing, shields, totems, crossbows and elytra.
Next up: beacons and looms.
Contributing
Pull requests are welcome. The full guide is CONTRIBUTING.md.
How ported code is written
- Same rules, numbers and random-number order as PNX. Where Java needed objects and virtual calls, plain Rust data does the same job.
- Credit the source with a
// from PNX <Class>comment. - Leave a
// TODO:where something isn't ported properly yet. - Add a test for the behaviour you ported.
Before opening a PR
cargo test
cargo clippy --all-targets
Both should pass with no warnings.
Editing these docs
The docs are plain Markdown in the docs/
folder, built with mdBook. Every page has an edit button
in the top right. To preview locally:
cargo install mdbook
mdbook serve docs --open