aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShayne Hartford <shaybox@shaybox.com>2024-10-21 15:11:51 -0400
committerGitHub <noreply@github.com>2024-10-21 14:11:51 -0500
commit58d14857335e130938bde66b5a8b1c6013fe2892 (patch)
tree4b337c408d30aa9a3d3d820470339b2cec1ca850
parent2992fc6b4793e00cb35568e6bc42f7bde02463dd (diff)
downloadazalea-drasl-58d14857335e130938bde66b5a8b1c6013fe2892.tar.xz
Derive Deserialize & Serialize for BlockPos & Vec3 (#175)
(cherry picked from commit f0d15d08320cbca1f3383e60cdd97efc488c3b34)
-rwxr-xr-xazalea-core/src/position.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs
index 31b2d008..310d0390 100755
--- a/azalea-core/src/position.rs
+++ b/azalea-core/src/position.rs
@@ -4,6 +4,8 @@
//! for entity positions and block positions, respectively.
use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable};
+#[cfg(feature = "serde")]
+use serde::{Deserialize, Serialize};
use std::{
fmt,
hash::Hash,
@@ -211,6 +213,7 @@ macro_rules! vec3_impl {
/// Used to represent an exact position in the world where an entity could be.
/// For blocks, [`BlockPos`] is used instead.
#[derive(Clone, Copy, Debug, Default, PartialEq, McBuf)]
+#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
pub struct Vec3 {
pub x: f64,
pub y: f64,
@@ -235,6 +238,7 @@ impl Vec3 {
/// The coordinates of a block in the world. For entities (if the coordinate
/// with decimals), use [`Vec3`] instead.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
+#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
pub struct BlockPos {
pub x: i32,
pub y: i32,