aboutsummaryrefslogtreecommitdiff
path: root/azalea-core/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-12-24 08:48:36 +0000
committermat <git@matdoes.dev>2024-12-24 08:48:36 +0000
commitf03e0c22355778a9863cccb5a59d852278d60701 (patch)
treef02e7ca3d1e975d486071934a6322d372b7c9a02 /azalea-core/src
parentde5a53ce08de5b9d77bce99dd9ecde3171ebd74e (diff)
downloadazalea-drasl-f03e0c22355778a9863cccb5a59d852278d60701.tar.xz
fix parsing Dust particle and treat waterlogged blocks as liquid in pathfinder
Diffstat (limited to 'azalea-core/src')
-rwxr-xr-xazalea-core/src/bitset.rs4
-rw-r--r--azalea-core/src/color.rs55
-rwxr-xr-xazalea-core/src/lib.rs1
-rwxr-xr-xazalea-core/src/position.rs14
4 files changed, 72 insertions, 2 deletions
diff --git a/azalea-core/src/bitset.rs b/azalea-core/src/bitset.rs
index 76b04885..5af05e19 100755
--- a/azalea-core/src/bitset.rs
+++ b/azalea-core/src/bitset.rs
@@ -12,9 +12,9 @@ const ADDRESS_BITS_PER_WORD: usize = 6;
// the Index trait requires us to return a reference, but we can't do that
impl BitSet {
- pub fn new(size: usize) -> Self {
+ pub fn new(num_bits: usize) -> Self {
BitSet {
- data: vec![0; size.div_ceil(64)],
+ data: vec![0; num_bits.div_ceil(64)],
}
}
diff --git a/azalea-core/src/color.rs b/azalea-core/src/color.rs
new file mode 100644
index 00000000..eddf5035
--- /dev/null
+++ b/azalea-core/src/color.rs
@@ -0,0 +1,55 @@
+use azalea_buf::AzBuf;
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, AzBuf)]
+pub struct RgbColor {
+ value: u32,
+}
+
+impl RgbColor {
+ pub fn new(r: u8, g: u8, b: u8) -> Self {
+ Self {
+ value: (r as u32) << 16 | (g as u32) << 8 | b as u32,
+ }
+ }
+
+ pub fn red(&self) -> u8 {
+ (self.value >> 16) as u8
+ }
+
+ pub fn green(&self) -> u8 {
+ (self.value >> 8) as u8
+ }
+
+ pub fn blue(&self) -> u8 {
+ self.value as u8
+ }
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, AzBuf)]
+pub struct ArgbColor {
+ value: u32,
+}
+
+impl ArgbColor {
+ pub fn new(a: u8, r: u8, g: u8, b: u8) -> Self {
+ Self {
+ value: (a as u32) << 24 | (r as u32) << 16 | (g as u32) << 8 | b as u32,
+ }
+ }
+
+ pub fn alpha(&self) -> u8 {
+ (self.value >> 24) as u8
+ }
+
+ pub fn red(&self) -> u8 {
+ (self.value >> 16) as u8
+ }
+
+ pub fn green(&self) -> u8 {
+ (self.value >> 8) as u8
+ }
+
+ pub fn blue(&self) -> u8 {
+ self.value as u8
+ }
+}
diff --git a/azalea-core/src/lib.rs b/azalea-core/src/lib.rs
index acfb560e..04422146 100755
--- a/azalea-core/src/lib.rs
+++ b/azalea-core/src/lib.rs
@@ -5,6 +5,7 @@
pub mod aabb;
pub mod bitset;
pub mod block_hit_result;
+pub mod color;
pub mod cursor3d;
pub mod delta;
pub mod difficulty;
diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs
index be06e825..ab73c0d1 100755
--- a/azalea-core/src/position.rs
+++ b/azalea-core/src/position.rs
@@ -71,6 +71,7 @@ macro_rules! vec3_impl {
/// Return a new instance of this position with the z coordinate subtracted
/// by the given number.
+ #[inline]
pub fn north(&self, z: $type) -> Self {
Self {
x: self.x,
@@ -80,6 +81,7 @@ macro_rules! vec3_impl {
}
/// Return a new instance of this position with the x coordinate increased
/// by the given number.
+ #[inline]
pub fn east(&self, x: $type) -> Self {
Self {
x: self.x + x,
@@ -89,6 +91,7 @@ macro_rules! vec3_impl {
}
/// Return a new instance of this position with the z coordinate increased
/// by the given number.
+ #[inline]
pub fn south(&self, z: $type) -> Self {
Self {
x: self.x,
@@ -98,6 +101,7 @@ macro_rules! vec3_impl {
}
/// Return a new instance of this position with the x coordinate subtracted
/// by the given number.
+ #[inline]
pub fn west(&self, x: $type) -> Self {
Self {
x: self.x - x,
@@ -110,6 +114,16 @@ macro_rules! vec3_impl {
pub fn dot(&self, other: Self) -> $type {
self.x * other.x + self.y * other.y + self.z * other.z
}
+
+ /// Replace the Y with 0.
+ #[inline]
+ pub fn xz(&self) -> Self {
+ Self {
+ x: self.x,
+ y: <$type>::default(),
+ z: self.z,
+ }
+ }
}
impl Add for &$name {