diff options
Diffstat (limited to 'azalea-core')
| -rwxr-xr-x | azalea-core/Cargo.toml | 12 | ||||
| -rwxr-xr-x | azalea-core/src/delta.rs | 1 | ||||
| -rwxr-xr-x | azalea-core/src/particle/mod.rs | 1 | ||||
| -rwxr-xr-x | azalea-core/src/position.rs | 14 | ||||
| -rwxr-xr-x | azalea-core/src/resource_location.rs | 3 |
5 files changed, 25 insertions, 6 deletions
diff --git a/azalea-core/Cargo.toml b/azalea-core/Cargo.toml index 9addac59..e102594d 100755 --- a/azalea-core/Cargo.toml +++ b/azalea-core/Cargo.toml @@ -3,13 +3,17 @@ description = "Miscellaneous things in Azalea." edition = "2021" license = "MIT" name = "azalea-core" -version = "0.5.0" repository = "https://github.com/mat-1/azalea/tree/main/azalea-core" +version = "0.5.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -azalea-buf = {path = "../azalea-buf", version = "^0.5.0" } -azalea-chat = {path = "../azalea-chat", version = "^0.5.0" } -azalea-nbt = {path = "../azalea-nbt", version = "^0.5.0" } +azalea-buf = {path = "../azalea-buf", version = "^0.5.0"} +azalea-chat = {path = "../azalea-chat", version = "^0.5.0"} +azalea-nbt = {path = "../azalea-nbt", version = "^0.5.0"} +bevy_ecs = {version = "0.9.1", default-features = false, optional = true} uuid = "^1.1.2" + +[features] +bevy_ecs = ["dep:bevy_ecs"] diff --git a/azalea-core/src/delta.rs b/azalea-core/src/delta.rs index 4f730d14..ce49ab50 100755 --- a/azalea-core/src/delta.rs +++ b/azalea-core/src/delta.rs @@ -39,6 +39,7 @@ impl PositionDeltaTrait for PositionDelta8 { } impl Vec3 { + #[must_use] pub fn with_delta(&self, delta: &dyn PositionDeltaTrait) -> Vec3 { Vec3 { x: self.x + delta.x(), diff --git a/azalea-core/src/particle/mod.rs b/azalea-core/src/particle/mod.rs index 44c7c2f5..8dc9f8c6 100755 --- a/azalea-core/src/particle/mod.rs +++ b/azalea-core/src/particle/mod.rs @@ -1,6 +1,7 @@ use crate::{BlockPos, Slot}; use azalea_buf::McBuf; +#[cfg_attr(feature = "bevy_ecs", derive(bevy_ecs::component::Component))] #[derive(Debug, Clone, McBuf, Default)] pub struct Particle { #[var] diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs index ea54c60c..d04f58cc 100755 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -1,5 +1,5 @@ use crate::ResourceLocation; -use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; +use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable}; use std::{ io::{Cursor, Write}, ops::{Add, AddAssign, Mul, Rem, Sub}, @@ -109,7 +109,7 @@ macro_rules! vec3_impl { }; } -#[derive(Clone, Copy, Debug, Default, PartialEq)] +#[derive(Clone, Copy, Debug, Default, PartialEq, McBuf)] pub struct Vec3 { pub x: f64, pub y: f64, @@ -270,12 +270,22 @@ impl From<&Vec3> for BlockPos { } } } +impl From<Vec3> for BlockPos { + fn from(pos: Vec3) -> Self { + BlockPos::from(&pos) + } +} impl From<&Vec3> for ChunkPos { fn from(pos: &Vec3) -> Self { ChunkPos::from(&BlockPos::from(pos)) } } +impl From<Vec3> for ChunkPos { + fn from(pos: Vec3) -> Self { + ChunkPos::from(&pos) + } +} const PACKED_X_LENGTH: u64 = 1 + 25; // minecraft does something a bit more complicated to get this 25 const PACKED_Z_LENGTH: u64 = PACKED_X_LENGTH; diff --git a/azalea-core/src/resource_location.rs b/azalea-core/src/resource_location.rs index e810b96e..4e25d00e 100755 --- a/azalea-core/src/resource_location.rs +++ b/azalea-core/src/resource_location.rs @@ -3,6 +3,9 @@ use azalea_buf::{BufReadError, McBufReadable, McBufWritable}; use std::io::{Cursor, Write}; +// TODO: make a `resourcelocation!("minecraft:overwolrd")` macro that checks if +// it's correct at compile-time. + #[derive(Hash, Clone, PartialEq, Eq)] pub struct ResourceLocation { pub namespace: String, |
