From 58c1e40de8673b7cd0b3ea4d5c284bf5100d9f7d Mon Sep 17 00:00:00 2001 From: Amber Kowalski Date: Wed, 3 Mar 2021 10:52:57 -0600 Subject: [PATCH] Move types and rename to be more generic. (#23) * Add interaction enums for block placement. * Make enums more generic and move into potentially more proper locations. --- crates/core/src/interaction.rs | 16 ---------------- crates/core/src/lib.rs | 8 +++++--- crates/core/src/player.rs | 7 +++++++ crates/core/src/positions.rs | 10 ++++++++++ 4 files changed, 22 insertions(+), 19 deletions(-) create mode 100644 crates/core/src/player.rs diff --git a/crates/core/src/interaction.rs b/crates/core/src/interaction.rs index a829fe8..24d020a 100644 --- a/crates/core/src/interaction.rs +++ b/crates/core/src/interaction.rs @@ -6,19 +6,3 @@ pub enum InteractionType { Attack, InteractAt, } - -#[derive(Debug, Serialize, Deserialize)] -pub enum InteractHand { - Main, - Offhand, -} - -#[derive(Debug, Serialize, Deserialize)] -pub enum InteractBlockFace { - Bottom, - Top, - North, - South, - West, - East, -} diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 4145d96..03df157 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -8,6 +8,7 @@ mod entity; mod gamemode; mod gamerules; mod interaction; +mod player; mod positions; pub use biome::Biome; @@ -16,8 +17,9 @@ pub use enchantment::{Enchantment, EnchantmentKind}; pub use entity::EntityKind; pub use gamemode::Gamemode; pub use gamerules::GameRules; -pub use interaction::{InteractBlockFace, InteractHand, InteractionType}; +pub use interaction::InteractionType; +pub use player::Hand; pub use positions::{ - vec3, Aabb, BlockPosition, ChunkPosition, Mat4f, Position, Vec2d, Vec2f, Vec2i, Vec3d, Vec3f, - Vec3i, Vec4d, Vec4f, Vec4i, + vec3, Aabb, BlockFace, BlockPosition, ChunkPosition, Mat4f, Position, Vec2d, Vec2f, Vec2i, + Vec3d, Vec3f, Vec3i, Vec4d, Vec4f, Vec4i, }; diff --git a/crates/core/src/player.rs b/crates/core/src/player.rs new file mode 100644 index 0000000..3d1c75f --- /dev/null +++ b/crates/core/src/player.rs @@ -0,0 +1,7 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Serialize, Deserialize)] +pub enum Hand { + Main, + Offhand, +} diff --git a/crates/core/src/positions.rs b/crates/core/src/positions.rs index cb37bc9..e1f3691 100644 --- a/crates/core/src/positions.rs +++ b/crates/core/src/positions.rs @@ -420,3 +420,13 @@ impl From for ChunkPosition { } } } + +#[derive(Debug, Serialize, Deserialize)] +pub enum BlockFace { + Bottom, + Top, + North, + South, + West, + East, +}