Skip to content

Commit

Permalink
Merge branch 'bedrock-crustaceans:proto_rework' into proto_rework
Browse files Browse the repository at this point in the history
  • Loading branch information
OmniacDev authored Dec 25, 2024
2 parents 83d2029 + 964f680 commit 53854d3
Show file tree
Hide file tree
Showing 70 changed files with 158 additions and 553 deletions.
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"
3 changes: 0 additions & 3 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
pub use vec::vec2::Vec2;
pub use vec::vec3::Vec3;

pub mod vec;
2 changes: 0 additions & 2 deletions crates/core/src/vec/mod.rs

This file was deleted.

171 changes: 0 additions & 171 deletions crates/core/src/vec/vec2.rs

This file was deleted.

Loading

0 comments on commit 53854d3

Please sign in to comment.