Skip to content

Commit

Permalink
Merge pull request #97 from bedrock-crustaceans/dev
Browse files Browse the repository at this point in the history
Stabilize Dev
  • Loading branch information
theaddonn authored Dec 30, 2024
2 parents 9bc5fbc + 04ead93 commit 3170ae0
Show file tree
Hide file tree
Showing 796 changed files with 20,867 additions and 5,630 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
on: [push, pull_request]
on: [ push, pull_request ]

name: Continuous integration

Expand Down Expand Up @@ -63,4 +63,3 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ target/
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# Profiler logs
*.opt

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
*.pdb

*.bin

# This is a little hack to allow the tests to be ran and not have a merge conflict
crates/level/test_level/
43 changes: 34 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,51 @@ version = "0.1.0"
edition = "2021"

[workspace]
members = [ "crates/*" ]
members = ["crates/*"]

[dependencies]
bedrockrs_core = { path = "crates/core" }
bedrockrs_shared = { path = "crates/shared" }

bedrockrs_macros = { path = "crates/macros", optional = true }

bedrockrs_addon = { path = "crates/addon", optional = true }

bedrockrs_form = { path = "crates/form", optional = true }

bedrockrs_proto = { path = "crates/proto", optional = true }
bedrockrs_proto_core = { path = "crates/proto_core", optional = true }
bedrockrs_proto_macros = { path = "crates/proto_macros", optional = true }

bedrockrs_addon = { path = "crates/addon", optional = true }
bedrockrs_server = { path = "crates/server", optional = true }

bedrockrs_level = {path = "crates/level", optional = true}

[dev-dependencies]
tokio = { version = "1.40", features = ["full"] }

nbtx = { git = "https://github.com/bedrock-crustaceans/nbtx" }
uuid = { version = "1.11.0", features = ["v4"] }

bedrockrs_form = { path = "crates/form" }

bedrockrs_world = { path = "crates/world", optional = true }
bedrockrs_paletted_storage = { path = "crates/paletted_storage", optional = true }
fern = { version = "0.7", features = ["colored"] }
log = "0.4"
chrono = "0.4"

[features]
full = ["addon", "proto", "world"]

addon = ["dep:bedrockrs_addon"]
proto = ["dep:bedrockrs_proto", "dep:bedrockrs_proto_core", "dep:bedrockrs_proto_macros"]
world = ["dep:bedrockrs_world", "dep:bedrockrs_paletted_storage"]
proto = ["dep:bedrockrs_proto","dep:bedrockrs_proto_core","dep:bedrockrs_macros",]
level = ["dep:bedrockrs_level"]
full = ["addon", "level", "proto", "server"]
form = ["dep:bedrockrs_form"]
server = ["dep:bedrockrs_server", "proto", "level", "form"]

[[example]]
name = "proto_server"
path = "examples/proto/server.rs"
required-features = ["proto"]

[[example]]
name = "proto_parsing"
path = "examples/proto_parsing.rs"
required-features = ["proto"]
113 changes: 86 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,101 @@
# bedrock-rs

_Universal toolkit for MCBE in Rust_
**_Universal Toolkit for Minecraft Bedrock Edition in Rust_**

An easy-to-use universal library for Minecraft Bedrock written in Rust, that aims to provide:
**bedrock-rs** is a comprehensive and user-friendly library written in Rust, designed to provide a universal solution for working with Minecraft Bedrock Edition. This project offers:

- [X] Standards
- [X] Common implementations
- [X] An easy-to-use api
- **Standards:** Adhering to best practices and conventions.
- **Common Implementations:** Reusable components for various Minecraft Bedrock needs.
- **Easy-to-Use API:** Streamlined interfaces to make development efficient and enjoyable.

We also have a community discord, feel free to join it to learn more about our future and get help when needed: https://discord.com/invite/VCVcrvt3JC
Join our growing community on Discord to learn more about the project’s future, seek support, or collaborate with others:
**[Join our Discord](https://discord.com/invite/VCVcrvt3JC)**

## Crates:
---

- [Core](https://github.com/Adrian8115/bedrock-rs/tree/main/crates/core):
- Provides common base datatypes.
## Crates

- [Shared](https://github.com/Adrian8115/bedrock-rs/tree/main/crates/shared):
- Shared datatypes that can use derive macros defined in other crates.
To maintain modularity and scalability, **bedrock-rs** is divided into multiple crates. Each crate focuses on a specific functionality, making it easier to use and manage. All crates are accessible through the primary `bedrockrs` crate. Additionally, the library offers a variety of optional features you can enable to suit your needs.

- [Proto](https://github.com/Adrian8115/bedrock-rs/tree/main/crates/proto):
- Full implementation of the Bedrock protocol.
- Support for both Server and Client side intended.
- Built-in login procedure.
### Crate Breakdown:

- [World](https://github.com/Adrian8115/bedrock-rs/tree/main/crates/world):
- Implementation of the Bedrock level format using our own `leveldb` bindings for mojangs leveldb fork.
- [`bedrockrs::shared`](crates/shared)
- [X] Shared data types used across other crates.
- [X] Support for deriving macros defined in other modules.

- [Addons](https://github.com/Adrian8115/bedrock-rs/tree/main/crates/addon):
- Datatypes defining the structure of Addons.
- Serialization and Deserialization of addons.
- [`bedrockrs::form`](crates/form)
- [X] Implementation of the JSON form format used by Minecraft Bedrock Edition.

- [Form](https://github.com/Adrian8115/bedrock-rs/tree/main/crates/form):
- Implementation of the JSON form format used in Minecraft Bedrock.
- [`bedrockrs::addon`](crates/addon)
- [X] Datatypes for defining Minecraft Addon structures.
- [X] Serialization and deserialization support for Addons.
- [X] A programmatic approach to creating Addons easily.

## Contributing:
- [`bedrockrs::proto`](crates/proto)
- [X] Complete implementation of the Minecraft Bedrock protocol.
- [X] Support for both server-side and client-side operations.
- [X] Multi-protocol compatibility for handling multiple versions seamlessly.

Feel free to join in at any time. Your contributions are highly valued, and a big thank you to all who participate. We
recommend getting acquainted with the bedrock-rs codebase. Whether it's tackling existing issues, adding new features,
or even introducing entirely fresh modules, your creativity is welcome.
- [`bedrockrs::level`](crates/level)
- [X] Data structures for managing Minecraft Bedrock levels.
- [X] Implementation of Bedrock’s level format using Rust’s LevelDB.

(If you like this library, remember to give bedrockrs a Star!)
- [`bedrockrs::server`](/crates/server)
- [X] A lightweight foundation for Minecraft Bedrock server software.
- [X] Built-in support for multi-protocol handling.
- [X] Asynchronous architecture powered by Tokio.

---

## Features

- **Modular Architecture:** Enable only the features you need for your project.
- **Multi-Protocol Support:** Work with different protocol versions effortlessly.
- **Cross-Platform Compatibility:** Designed to work seamlessly across platforms.
- **Lightweight and Efficient:** Built with Rust’s performance and safety features.

---

## Getting Started

To use **bedrock-rs** in your Rust project, add the following to your `Cargo.toml`:
```toml
[dependencies]
bedrockrs = { git = "https://github.com/bedrock-crustaceans/bedrock-rs.git", features = ["full"] }
```

Refer to the individual crate documentation for details on specific modules and features.

We also plan to release bedrock-rs on [crates.io](https://crates.io) in the future.

---

## Contributors

A huge thank you to all the amazing individuals who have contributed to **bedrock-rs**! Your time, effort, and expertise are what make this project possible.

[![Contributors](https://contrib.rocks/image?repo=bedrock-crustaceans/bedrock-rs)](https://github.com/bedrock-crustaceans/bedrock-rs/graphs/contributors)

Whether it’s fixing bugs, implementing features, or providing feedback, every contribution helps shape the future of this library. We appreciate each and every one of you!

Want to join this incredible group? Check out our Contributing Guide and make your mark on the project.

---

## Contributing

We welcome contributions of all kinds! Whether you're fixing bugs, adding new features, or proposing entirely new modules, your efforts are highly appreciated. Here’s how you can get involved:

1. **Get Familiar with the Codebase:** Explore the existing modules and documentation.
2. **Pick an Issue:** Check out the repository’s issue tracker for tasks you can work on.
3. **Add Your Touch:** Feel free to innovate and bring new ideas to the table.

For guidance or collaboration, feel free to connect with the community on Discord.

If you find **bedrock-rs** helpful, don’t forget to give the repository a ⭐ on GitHub.

---

## License

**bedrock-rs** is open-source software licensed under the [Apache-2.0 License](LICENSE).
9 changes: 6 additions & 3 deletions crates/addon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ version = "0.1.0"
edition = "2021"

[dependencies]
bedrockrs_core = { path = "../core" }

uuid = { version = "1.8", features = ["serde"] }
semver = { version = "1.0", features = ["serde"] }

image = "0.25"
thiserror = "1.0"

vek = "0.17"
thiserror = "2.0"

serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
json_comments = "0.2"

walkdir = "2.5"
8 changes: 4 additions & 4 deletions crates/addon/src/behavior/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Addon for BehaviorPack {
let blocks_path = path.join("blocks");
let mut blocks = HashMap::new();

// If dir exists read all blocks
// If dir exists, read all blocks
if blocks_path.is_dir() {
'blocks_walk: for blocks_entry in WalkDir::new(&blocks_path).into_iter().filter(|v| {
if let Ok(v) = v {
Expand Down Expand Up @@ -88,7 +88,7 @@ impl Addon for BehaviorPack {
let items_path = path.join("items");
let mut items = HashMap::new();

// If dir exists read all items
// If dir exists, read all items
if items_path.is_dir() {
'items_walk: for items_entry in WalkDir::new(&items_path).into_iter().filter(|v| {
if let Ok(v) = v {
Expand Down Expand Up @@ -177,14 +177,14 @@ impl Addon for BehaviorPack {
})
}

fn export(path: impl AsRef<Path>) -> Result<Self, AddonError>
fn export(_path: impl AsRef<Path>) -> Result<Self, AddonError>
where
Self: Sized,
{
unimplemented!()
}

fn merge(addons: Vec<Self>) -> Self
fn merge(_addons: Vec<Self>) -> Self
where
Self: Sized,
{
Expand Down
20 changes: 3 additions & 17 deletions crates/addon/src/language/code.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
use std::fmt::{Debug, Formatter};
use std::fmt::Debug;

use bedrockrs_core::Vec2;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(untagged)]
pub enum LanguageCode {
VanillaCode(String),
CustomCode(Vec2<String>),
}

impl Debug for LanguageCode {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
LanguageCode::VanillaCode(v) => {
write!(f, "VanillaCode({v})")
}
LanguageCode::CustomCode(v) => {
write!(f, "CustomCode([{}, {}])", v.x, v.y)
}
}
}
CustomCode((String, String)),
}
2 changes: 1 addition & 1 deletion crates/addon/src/language/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Languages {
for language in languages_file {
let language_code = match language {
LanguageCode::VanillaCode(v) => v,
LanguageCode::CustomCode(v) => v.x,
LanguageCode::CustomCode(v) => v.1,
};

let language_path = languages_path.join(format!("{language_code}.lang"));
Expand Down
7 changes: 3 additions & 4 deletions crates/addon/src/manifest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use bedrockrs_core::Vec3;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

Expand Down Expand Up @@ -40,9 +39,9 @@ pub struct AddonManifestHeader {
/// For resource packs, an optional string that specifies whether this resource pack can be used across the game or at an individual world level. Valid values are "world", which specifies that a pack is only addable in the context of a world "global", which means that a pack is only addable across the game, and "any" which indicates that a pack can apply either across the game or to a specific world. If not specified, this is interpreted as "any".
pub pack_scope: Option<String>,
/// This is the version of the base game your world template requires, specified as [majorVersion, minorVersion, revision]. We use this to determine what version of the base game resource and behavior packs to apply when your content is used. (world template manifest JSON only)
pub base_game_version: Option<Vec3<u32>>,
pub base_game_version: Option<[u32; 3]>,
/// This is the minimum version of the game that this pack was written for. This is a required field for resource and behavior packs. This helps the game identify whether any backwards compatibility is needed for your pack. You should always use the highest version currently available when creating packs.
pub min_engine_version: Option<Vec3<u32>>,
pub min_engine_version: Option<[u32; 3]>,
}

/// Section containing information regarding the type of content that is being brought in.
Expand Down Expand Up @@ -76,7 +75,7 @@ pub struct AddonManifestDependency {
/// Section containing the metadata about the file such as authors and licensing information.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AddonManifestMetadata {
/// Name of the author(s) of the pack.
/// Name of the pack authors.
pub authors: Option<Vec<String>>,
/// The license of the pack.
pub license: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions crates/addon/src/resource/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ impl Addon for ResourcePack {
})
}

fn export(path: impl AsRef<Path>) -> Result<Self, AddonError>
fn export(_path: impl AsRef<Path>) -> Result<Self, AddonError>
where
Self: Sized,
{
unimplemented!()
}

fn merge(addons: Vec<Self>) -> Self
fn merge(_addons: Vec<Self>) -> Self
where
Self: Sized,
{
Expand Down
16 changes: 3 additions & 13 deletions crates/addon/src/version.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
use std::fmt::{Debug, Formatter};
use std::fmt::Debug;

use bedrockrs_core::Vec3;
use serde::{Deserialize, Serialize};

/// A version used in Addons that is either a Vector [a, b, c] or SemVer String.
#[derive(Serialize, Deserialize, Clone)]
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(untagged)]
pub enum AddonSemanticVersion {
Vector(Vec3<u32>),
Vector([u32; 3]),
SemVer(semver::Version),
}

impl Debug for AddonSemanticVersion {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
AddonSemanticVersion::Vector(v) => f.debug_list().entries([v.x, v.y, v.z]).finish(),
AddonSemanticVersion::SemVer(v) => v.fmt(f),
}
}
}
7 changes: 0 additions & 7 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@ version = "0.1.0"
edition = "2021"

[dependencies]
uuid = { version = "1.8", features = ["v4"] }

bytes = "1.6"
byteorder = "1.5"
varint-rs = "2.2"

serde = "1.0"
Loading

0 comments on commit 3170ae0

Please sign in to comment.