Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6f0c521
Implement auto save
cb341 Jan 16, 2026
f935bc7
L
cb341 Jan 16, 2026
4f25c96
wip
cb341 Jan 16, 2026
363dd9f
wip serialization
cb341 Jan 16, 2026
ef014d8
wip
cb341 Jan 17, 2026
958015c
Fix world update bug
cb341 Jan 17, 2026
f4e1819
Implement world loading
cb341 Jan 17, 2026
b454e7b
Fix world saving, loading
cb341 Jan 17, 2026
4d63616
Update README
cb341 Jan 17, 2026
605b55d
Add clap for cli arg parsing + impl proper load
cb341 Jan 18, 2026
e5e0dd6
changes
cb341 Jan 18, 2026
d2bee58
Update doc
cb341 Jan 18, 2026
60d01ec
Refactor
cb341 Jan 18, 2026
ac7a84f
Apply suggestion from @cb341
cb341 Jan 18, 2026
59b019e
Simpify error handling
cb341 Jan 18, 2026
807c9de
Delete todo.sh
cb341 Jan 18, 2026
12b02e0
Refactor
cb341 Jan 18, 2026
bba7e34
Lint
cb341 Jan 18, 2026
101985f
Remove deps
cb341 Jan 18, 2026
cc43020
Refactor
cb341 Jan 18, 2026
8e72f00
Remove serde_derive (serde with derive flag does the same thing)
cb341 Jan 18, 2026
ac3d050
quickfix
cb341 Jan 18, 2026
073e5f5
Tests
cb341 Jan 18, 2026
2098fbb
Improve stuff
cb341 Jan 18, 2026
dfb0bcb
wip (break stuff)
cb341 Jan 22, 2026
fe9ddf0
Fix everything, wip
cb341 Jan 23, 2026
d6550e7
Refactor
cb341 Jan 23, 2026
1a71526
Refactor
cb341 Jan 23, 2026
9af1d5e
Refactor
cb341 Jan 23, 2026
9bec5bf
Refactor
cb341 Jan 23, 2026
ad7f121
Refactor
cb341 Jan 23, 2026
21c1af2
Move command definition
cb341 Jan 23, 2026
534d8d0
Improve hints
cb341 Jan 23, 2026
e208173
Improvements from chris
cb341 Jan 23, 2026
a02e4ce
Update timers
cb341 Jan 23, 2026
0257e65
word
cb341 Jan 23, 2026
2618536
Refactor
cb341 Jan 23, 2026
9b7df6d
Update READMe
cb341 Jan 23, 2026
70fcc55
Add save on exit
cb341 Jan 23, 2026
dc0a562
Fix world backup on startup
cb341 Jan 23, 2026
2238ec5
Fix lint
cb341 Jan 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
# vim stuff
tree-sitter-rust
*-E

backups/
128 changes: 128 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ bincode = "1.3.3"
rand = {version = "0.9.0", features = ["small_rng"]}
renet = "1.2.0"
serde = { version = "1.0.203", features = ["derive"] }
serde_derive = "1.0.228"
serde-big-array = "0.5.1"
chrono = "0.4.38"
rayon = "1.10.0"
clap = { version = "4.5.54", features = ["derive"] }
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLI arg parsing


[patch.crates-io]
# TODO: Remove patch once egui requirement is more flexible.
Expand All @@ -44,9 +46,6 @@ renet = {git = "https://github.com/cb341/renet.git" }
[profile.dev.package."*"]
opt-level = 3

[profile.dev.package.objc2]
debug-assertions = false

[profile.release]
opt-level = 3

Expand Down
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ A stupid little Minecraft clone written in Rust, powered by the Bevy engine.
* World update synchronization between game clients
* World physics using rapier
* World updates using primitive ray casting
* World saving/loading with `.rsmcw` files
* Periodic world backups in `./backups/` directory
* Modular architecture using ECS

## Installation
Expand All @@ -24,30 +26,29 @@ A stupid little Minecraft clone written in Rust, powered by the Bevy engine.
Just run the cargo command to install the dependencies and start the game:

```bash
cargo run --bin server
cargo run --bin client
cargo rs # run server
cargo rc # run client
```

Loading world

```bash
car rs -- -w my_world.rsmcw
```

### More optimal setup

Release Builds (for better performance):

```bash
cargo run --bin server --release
cargo run --bin client --release
cargo run rs --release
cargo run rc --release
```

Dynamic Linking (to reduce compile times):
```bash
cargo run --bin server --features dynamic_linking
cargo run --bin client --features dynamic_linking
```
Hot reload client

Automatic Reloading (with [cargo watch](https://docs.rs/crate/cargo-watch)):
```bash
cargo watch -x 'run --bin server'
cargo watch -x 'run --bin client'
bin/dev
```

### Installation on NixOS
Expand All @@ -56,10 +57,10 @@ Nix shell can be used to run the code using the given [Nix Shell Config File](./
Strongly inspired by the [Bevy NixOS installation guide](https://github.com/bevyengine/bevy/blob/latest/docs/linux_dependencies.md)

```bash
nix-shell --run "cargo run --bin server"
nix-shell --run "cargo run --bin client"
nix-shell --run "cargo rs"
nix-shell --run "cargo rc"
```

## Notes

Checkout the [Wiki](https://github.com/CuddlyBunion341/rsmc/wiki) for additional project information.
Checkout the [Wiki](https://github.com/cb341/rsmc/wiki) for additional project information.
2 changes: 1 addition & 1 deletion src/client/terrain/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn handle_chunk_mesh_update_events_system(
"Received chunk mesh update event for chunk {:?}",
event.chunk_position
);
let chunk_option = chunk_manager.get_chunk(event.chunk_position);
let chunk_option = chunk_manager.get_chunk(&event.chunk_position);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated refactoring.

match chunk_option {
Some(chunk) => {
tasks.task_list.push(FutureChunkMesh {
Expand Down
19 changes: 18 additions & 1 deletion src/server/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pub mod player;
pub mod prelude;
pub mod terrain;

use clap::Parser;

#[cfg(feature = "egui_layer")]
use bevy::DefaultPlugins;
#[cfg(feature = "egui_layer")]
Expand All @@ -14,8 +16,16 @@ use bevy::log::LogPlugin;

use crate::prelude::*;

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
#[arg(short, long, default_value = None)]
world_file_path: Option<String>,
}

fn main() {
let mut app = App::new();

#[cfg(not(feature = "egui_layer"))]
{
app.add_plugins(MinimalPlugins);
Expand All @@ -30,9 +40,16 @@ fn main() {
app.add_systems(Startup, gui::setup_camera_system);
}

let args = Args::parse();
let file_path = args.world_file_path;
let terrain_plugin = file_path
.as_ref()
.and_then(|path| terrain::TerrainPlugin::from_path(path).ok())
.unwrap_or_else(|| terrain::TerrainPlugin::from_seed(0));
app.add_plugins(terrain_plugin);

app.add_plugins(player::PlayerPlugin);
app.add_plugins(networking::NetworkingPlugin);
app.add_plugins(terrain::TerrainPlugin);

#[cfg(feature = "chat")]
app.add_plugins(chat::ChatPlugin);
Expand Down
2 changes: 2 additions & 0 deletions src/server/networking/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub fn receive_message_system(
mut server: ResMut<RenetServer>,
mut player_states: ResMut<player_resources::PlayerStates>,
mut past_block_updates: ResMut<terrain_resources::PastBlockUpdates>,
mut chunk_manager: ResMut<ChunkManager>,
mut request_queue: ResMut<terrain_resources::ClientChunkRequests>,
#[cfg(feature = "chat")] mut chat_message_events: MessageWriter<
chat_events::PlayerChatMessageSendEvent,
Expand All @@ -20,6 +21,7 @@ pub fn receive_message_system(
"Received block update from client {} {} {:?}",
client_id, position, block
);
chunk_manager.update_block(position, block);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💀

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't spot this one as the clients always receive world updates.
The world serializer doesn't take the diff into consideration but rather the physical chunks from the ChunkManager.

past_block_updates
.updates
.push(terrain_events::BlockUpdateEvent { position, block });
Expand Down
Loading