aboutsummaryrefslogtreecommitdiff
path: root/azalea-core
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-11-12 04:26:02 +0330
committermat <git@matdoes.dev>2025-11-11 18:56:14 -0600
commita4312599f7c04709a92b7be238dcf577bafbb14f (patch)
treebef58dca34239bac54649ab1e0db2597de10212c /azalea-core
parentac2b425615dd6cd8562c290e33b06e553559802d (diff)
downloadazalea-drasl-a4312599f7c04709a92b7be238dcf577bafbb14f.tar.xz
cleanup
- remove deprecated code - add `[lints] workspace=true` to every Cargo.toml, to make modifying clippy lints easier for later - remove some unnecessary #[allow]s - use Vec3i in some parts of the collision code
Diffstat (limited to 'azalea-core')
-rw-r--r--azalea-core/Cargo.toml3
-rw-r--r--azalea-core/src/delta.rs11
-rw-r--r--azalea-core/src/direction.rs10
-rw-r--r--azalea-core/src/position.rs16
4 files changed, 20 insertions, 20 deletions
diff --git a/azalea-core/Cargo.toml b/azalea-core/Cargo.toml
index d36ac038..fa299cc7 100644
--- a/azalea-core/Cargo.toml
+++ b/azalea-core/Cargo.toml
@@ -24,3 +24,6 @@ uuid.workspace = true
[features]
bevy_ecs = ["dep:bevy_ecs"]
strict_registry = []
+
+[lints]
+workspace = true
diff --git a/azalea-core/src/delta.rs b/azalea-core/src/delta.rs
index 50fdeafa..c193649a 100644
--- a/azalea-core/src/delta.rs
+++ b/azalea-core/src/delta.rs
@@ -19,17 +19,6 @@ pub struct PositionDelta8 {
pub za: i16,
}
-impl PositionDelta8 {
- #[deprecated = "Use Self::x, y, z instead"]
- pub fn float(&self) -> (f64, f64, f64) {
- (
- (self.xa as f64) / 4096.0,
- (self.ya as f64) / 4096.0,
- (self.za as f64) / 4096.0,
- )
- }
-}
-
impl PositionDeltaTrait for PositionDelta8 {
fn x(&self) -> f64 {
(self.xa as f64) / 4096.0
diff --git a/azalea-core/src/direction.rs b/azalea-core/src/direction.rs
index c794c79a..fbd7f98b 100644
--- a/azalea-core/src/direction.rs
+++ b/azalea-core/src/direction.rs
@@ -1,6 +1,6 @@
use azalea_buf::AzBuf;
-use crate::position::{BlockPos, Vec3};
+use crate::position::{BlockPos, Vec3, Vec3i};
#[derive(
Clone, Copy, Debug, AzBuf, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize,
@@ -220,11 +220,11 @@ impl AxisCycle {
Self::Backward => Axis::from_ordinal(i32::rem_euclid(axis as i32 - 1, 3) as u32),
}
}
- pub fn cycle_xyz(self, x: i32, y: i32, z: i32, axis: Axis) -> i32 {
+ pub fn cycle_xyz(self, pos: Vec3i, axis: Axis) -> i32 {
match self {
- Self::None => axis.choose(x, y, z),
- Self::Forward => axis.choose(z, x, y),
- Self::Backward => axis.choose(y, z, x),
+ Self::None => axis.choose(pos.x, pos.y, pos.z),
+ Self::Forward => axis.choose(pos.z, pos.x, pos.y),
+ Self::Backward => axis.choose(pos.y, pos.z, pos.x),
}
}
}
diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs
index 7feb24d2..1686a7ad 100644
--- a/azalea-core/src/position.rs
+++ b/azalea-core/src/position.rs
@@ -23,6 +23,13 @@ use crate::{
macro_rules! vec3_impl {
($name:ident, $type:ty) => {
impl $name {
+ /// The position where x, y, and z are all 0.
+ pub const ZERO: Self = Self {
+ x: 0 as $type,
+ y: 0 as $type,
+ z: 0 as $type,
+ };
+
#[inline]
pub const fn new(x: $type, y: $type, z: $type) -> Self {
Self { x, y, z }
@@ -308,8 +315,6 @@ pub struct Vec3 {
vec3_impl!(Vec3, f64);
impl Vec3 {
- pub const ZERO: Vec3 = Vec3::new(0.0, 0.0, 0.0);
-
/// Get the distance of this vector to the origin by doing
/// `sqrt(x^2 + y^2 + z^2)`.
pub fn length(&self) -> f64 {
@@ -472,8 +477,10 @@ impl<'de> serde::Deserialize<'de> for BlockPos {
}
}
-/// Similar to [`BlockPos`] but it's serialized as 3 varints instead of one
-/// 64-bit integer, so it can represent a bigger range of numbers.
+/// An arbitrary position that's represented as 32-bit integers.
+///
+/// This is similar to [`BlockPos`], but isn't limited to representing block
+/// positions and can represent a larger range of numbers.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, AzBuf)]
pub struct Vec3i {
#[var]
@@ -483,6 +490,7 @@ pub struct Vec3i {
#[var]
pub z: i32,
}
+vec3_impl!(Vec3i, i32);
/// Chunk coordinates are used to represent where a chunk is in the world.
///