aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-05-30 12:59:08 -1345
committermat <git@matdoes.dev>2025-05-30 12:59:08 -1345
commita64c6505049082175224802c5be51ac8f0cf4677 (patch)
tree443877d470fed94810b4b7180b2584dd5ae3fc9d /azalea-protocol/src
parentcfdd8e690f230bc84fc126d5a8bfa13df0f6d781 (diff)
downloadazalea-drasl-a64c6505049082175224802c5be51ac8f0cf4677.tar.xz
make fixedbitset require generic const exprs again :3
Diffstat (limited to 'azalea-protocol/src')
-rw-r--r--azalea-protocol/src/common/client_information.rs4
-rw-r--r--azalea-protocol/src/common/movements.rs4
-rw-r--r--azalea-protocol/src/packets/game/c_boss_event.rs6
-rw-r--r--azalea-protocol/src/packets/game/c_commands.rs16
-rw-r--r--azalea-protocol/src/packets/game/c_player_abilities.rs4
-rw-r--r--azalea-protocol/src/packets/game/c_player_info_update.rs4
-rw-r--r--azalea-protocol/src/packets/game/c_stop_sound.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_chat.rs2
-rw-r--r--azalea-protocol/src/packets/game/s_player_abilities.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_player_input.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_set_command_block.rs4
-rw-r--r--azalea-protocol/src/packets/game/s_set_structure_block.rs4
12 files changed, 31 insertions, 29 deletions
diff --git a/azalea-protocol/src/common/client_information.rs b/azalea-protocol/src/common/client_information.rs
index f2290fe7..6f5e05e2 100644
--- a/azalea-protocol/src/common/client_information.rs
+++ b/azalea-protocol/src/common/client_information.rs
@@ -97,7 +97,7 @@ impl Default for ModelCustomization {
impl AzaleaRead for ModelCustomization {
fn azalea_read(buf: &mut std::io::Cursor<&[u8]>) -> Result<Self, azalea_buf::BufReadError> {
- let set = FixedBitSet::<{ 7_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let set = FixedBitSet::<7>::azalea_read(buf)?;
Ok(Self {
cape: set.index(0),
jacket: set.index(1),
@@ -112,7 +112,7 @@ impl AzaleaRead for ModelCustomization {
impl AzaleaWrite for ModelCustomization {
fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
- let mut set = FixedBitSet::<{ 7_usize.div_ceil(8) }>::new();
+ let mut set = FixedBitSet::<7>::new();
if self.cape {
set.set(0);
}
diff --git a/azalea-protocol/src/common/movements.rs b/azalea-protocol/src/common/movements.rs
index a3898805..cf51a57c 100644
--- a/azalea-protocol/src/common/movements.rs
+++ b/azalea-protocol/src/common/movements.rs
@@ -32,7 +32,7 @@ pub struct RelativeMovements {
impl AzaleaRead for RelativeMovements {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
// yes minecraft seriously wastes that many bits, smh
- let set = FixedBitSet::<{ 32_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let set = FixedBitSet::<32>::azalea_read(buf)?;
Ok(RelativeMovements {
x: set.index(0),
y: set.index(1),
@@ -49,7 +49,7 @@ impl AzaleaRead for RelativeMovements {
impl AzaleaWrite for RelativeMovements {
fn azalea_write(&self, buf: &mut impl Write) -> Result<(), io::Error> {
- let mut set = FixedBitSet::<{ 32_usize.div_ceil(8) }>::new();
+ let mut set = FixedBitSet::<32>::new();
let mut set_bit = |index: usize, value: bool| {
if value {
set.set(index);
diff --git a/azalea-protocol/src/packets/game/c_boss_event.rs b/azalea-protocol/src/packets/game/c_boss_event.rs
index 58d9f4bb..259a2781 100644
--- a/azalea-protocol/src/packets/game/c_boss_event.rs
+++ b/azalea-protocol/src/packets/game/c_boss_event.rs
@@ -36,7 +36,7 @@ impl AzaleaRead for Operation {
_ => {
return Err(BufReadError::UnexpectedEnumVariant {
id: operation_id as i32,
- })
+ });
}
})
}
@@ -116,7 +116,7 @@ pub struct Properties {
impl AzaleaRead for Properties {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let set = FixedBitSet::<{ 3_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let set = FixedBitSet::<3>::azalea_read(buf)?;
Ok(Self {
darken_screen: set.index(0),
play_music: set.index(1),
@@ -127,7 +127,7 @@ impl AzaleaRead for Properties {
impl AzaleaWrite for Properties {
fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
- let mut set = FixedBitSet::<{ 3_usize.div_ceil(8) }>::new();
+ let mut set = FixedBitSet::<3>::new();
if self.darken_screen {
set.set(0);
}
diff --git a/azalea-protocol/src/packets/game/c_commands.rs b/azalea-protocol/src/packets/game/c_commands.rs
index cd21ddd1..c57f3d41 100644
--- a/azalea-protocol/src/packets/game/c_commands.rs
+++ b/azalea-protocol/src/packets/game/c_commands.rs
@@ -46,7 +46,7 @@ impl<T: PartialEq> PartialEq for BrigadierNumber<T> {
impl<T: AzaleaRead> AzaleaRead for BrigadierNumber<T> {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let flags = FixedBitSet::<{ 2_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let flags = FixedBitSet::<2>::azalea_read(buf)?;
let min = if flags.index(0) {
Some(T::azalea_read(buf)?)
} else {
@@ -62,7 +62,7 @@ impl<T: AzaleaRead> AzaleaRead for BrigadierNumber<T> {
}
impl<T: AzaleaWrite> AzaleaWrite for BrigadierNumber<T> {
fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
- let mut flags = FixedBitSet::<{ 2_usize.div_ceil(8) }>::new();
+ let mut flags = FixedBitSet::<2>::new();
if self.min.is_some() {
flags.set(0);
}
@@ -158,7 +158,7 @@ pub struct EntityParser {
}
impl AzaleaRead for EntityParser {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let flags = FixedBitSet::<{ 2_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let flags = FixedBitSet::<2>::azalea_read(buf)?;
Ok(EntityParser {
single: flags.index(0),
players_only: flags.index(1),
@@ -167,7 +167,7 @@ impl AzaleaRead for EntityParser {
}
impl AzaleaWrite for EntityParser {
fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
- let mut flags = FixedBitSet::<{ 2_usize.div_ceil(8) }>::new();
+ let mut flags = FixedBitSet::<2>::new();
if self.single {
flags.set(0);
}
@@ -182,9 +182,11 @@ impl AzaleaWrite for EntityParser {
// TODO: BrigadierNodeStub should have more stuff
impl AzaleaRead for BrigadierNodeStub {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let flags = FixedBitSet::<{ 8_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let flags = FixedBitSet::<8>::azalea_read(buf)?;
if flags.index(5) || flags.index(6) || flags.index(7) {
- warn!("The flags from a Brigadier node are over 31. This is a bug, BrigadierParser probably needs updating.",);
+ warn!(
+ "The flags from a Brigadier node are over 31. This is a bug, BrigadierParser probably needs updating.",
+ );
}
let node_type = u8::from(flags.index(0)) + (u8::from(flags.index(1)) * 2);
@@ -241,7 +243,7 @@ impl AzaleaRead for BrigadierNodeStub {
impl AzaleaWrite for BrigadierNodeStub {
fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
- let mut flags = FixedBitSet::<{ 4_usize.div_ceil(8) }>::new();
+ let mut flags = FixedBitSet::<4>::new();
if self.is_executable {
flags.set(2);
}
diff --git a/azalea-protocol/src/packets/game/c_player_abilities.rs b/azalea-protocol/src/packets/game/c_player_abilities.rs
index fffd320c..c32a99fe 100644
--- a/azalea-protocol/src/packets/game/c_player_abilities.rs
+++ b/azalea-protocol/src/packets/game/c_player_abilities.rs
@@ -23,7 +23,7 @@ pub struct PlayerAbilitiesFlags {
impl AzaleaRead for PlayerAbilitiesFlags {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let set = FixedBitSet::<{ 4_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let set = FixedBitSet::<4>::azalea_read(buf)?;
Ok(PlayerAbilitiesFlags {
invulnerable: set.index(0),
flying: set.index(1),
@@ -35,7 +35,7 @@ impl AzaleaRead for PlayerAbilitiesFlags {
impl AzaleaWrite for PlayerAbilitiesFlags {
fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
- let mut set = FixedBitSet::<{ 4_usize.div_ceil(8) }>::new();
+ let mut set = FixedBitSet::<4>::new();
if self.invulnerable {
set.set(0);
}
diff --git a/azalea-protocol/src/packets/game/c_player_info_update.rs b/azalea-protocol/src/packets/game/c_player_info_update.rs
index db3d38a5..c8e32a33 100644
--- a/azalea-protocol/src/packets/game/c_player_info_update.rs
+++ b/azalea-protocol/src/packets/game/c_player_info_update.rs
@@ -183,7 +183,7 @@ pub struct ActionEnumSet {
impl AzaleaRead for ActionEnumSet {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let set = FixedBitSet::<{ 7_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let set = FixedBitSet::<7>::azalea_read(buf)?;
Ok(ActionEnumSet {
add_player: set.index(0),
initialize_chat: set.index(1),
@@ -199,7 +199,7 @@ impl AzaleaRead for ActionEnumSet {
impl AzaleaWrite for ActionEnumSet {
fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
- let mut set = FixedBitSet::<{ 7_usize.div_ceil(8) }>::new();
+ let mut set = FixedBitSet::<7>::new();
if self.add_player {
set.set(0);
}
diff --git a/azalea-protocol/src/packets/game/c_stop_sound.rs b/azalea-protocol/src/packets/game/c_stop_sound.rs
index aa92c23e..e3cd737e 100644
--- a/azalea-protocol/src/packets/game/c_stop_sound.rs
+++ b/azalea-protocol/src/packets/game/c_stop_sound.rs
@@ -14,7 +14,7 @@ pub struct ClientboundStopSound {
impl AzaleaRead for ClientboundStopSound {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let set = FixedBitSet::<{ 2_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let set = FixedBitSet::<2>::azalea_read(buf)?;
let source = if set.index(0) {
Some(SoundSource::azalea_read(buf)?)
} else {
@@ -32,7 +32,7 @@ impl AzaleaRead for ClientboundStopSound {
impl AzaleaWrite for ClientboundStopSound {
fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
- let mut set = FixedBitSet::<{ 2_usize.div_ceil(8) }>::new();
+ let mut set = FixedBitSet::<2>::new();
if self.source.is_some() {
set.set(0);
}
diff --git a/azalea-protocol/src/packets/game/s_chat.rs b/azalea-protocol/src/packets/game/s_chat.rs
index 07702ddf..f4049243 100644
--- a/azalea-protocol/src/packets/game/s_chat.rs
+++ b/azalea-protocol/src/packets/game/s_chat.rs
@@ -17,6 +17,6 @@ pub struct ServerboundChat {
pub struct LastSeenMessagesUpdate {
#[var]
pub offset: u32,
- pub acknowledged: FixedBitSet<{ 20_usize.div_ceil(8) }>,
+ pub acknowledged: FixedBitSet<20>,
pub checksum: u8,
}
diff --git a/azalea-protocol/src/packets/game/s_player_abilities.rs b/azalea-protocol/src/packets/game/s_player_abilities.rs
index 5e63ef2e..fdf2d8a4 100644
--- a/azalea-protocol/src/packets/game/s_player_abilities.rs
+++ b/azalea-protocol/src/packets/game/s_player_abilities.rs
@@ -13,7 +13,7 @@ pub struct ServerboundPlayerAbilities {
impl AzaleaRead for ServerboundPlayerAbilities {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let set = FixedBitSet::<{ 2_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let set = FixedBitSet::<2>::azalea_read(buf)?;
Ok(Self {
is_flying: set.index(1),
})
@@ -22,7 +22,7 @@ impl AzaleaRead for ServerboundPlayerAbilities {
impl AzaleaWrite for ServerboundPlayerAbilities {
fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
- let mut set = FixedBitSet::<{ 2_usize.div_ceil(8) }>::new();
+ let mut set = FixedBitSet::<2>::new();
if self.is_flying {
set.set(1);
}
diff --git a/azalea-protocol/src/packets/game/s_player_input.rs b/azalea-protocol/src/packets/game/s_player_input.rs
index a16a62d0..7032bcff 100644
--- a/azalea-protocol/src/packets/game/s_player_input.rs
+++ b/azalea-protocol/src/packets/game/s_player_input.rs
@@ -18,7 +18,7 @@ pub struct ServerboundPlayerInput {
impl AzaleaRead for ServerboundPlayerInput {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let set = FixedBitSet::<{ 7_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let set = FixedBitSet::<7>::azalea_read(buf)?;
Ok(Self {
forward: set.index(0),
backward: set.index(1),
@@ -33,7 +33,7 @@ impl AzaleaRead for ServerboundPlayerInput {
impl AzaleaWrite for ServerboundPlayerInput {
fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
- let mut set = FixedBitSet::<{ 7_usize.div_ceil(8) }>::new();
+ let mut set = FixedBitSet::<7>::new();
if self.forward {
set.set(0);
}
diff --git a/azalea-protocol/src/packets/game/s_set_command_block.rs b/azalea-protocol/src/packets/game/s_set_command_block.rs
index ea1af6bb..dacb79de 100644
--- a/azalea-protocol/src/packets/game/s_set_command_block.rs
+++ b/azalea-protocol/src/packets/game/s_set_command_block.rs
@@ -30,7 +30,7 @@ impl AzaleaRead for ServerboundSetCommandBlock {
let command = String::azalea_read(buf)?;
let mode = Mode::azalea_read(buf)?;
- let set = FixedBitSet::<{ 3_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let set = FixedBitSet::<3>::azalea_read(buf)?;
Ok(Self {
pos,
command,
@@ -48,7 +48,7 @@ impl AzaleaWrite for ServerboundSetCommandBlock {
self.command.azalea_write(buf)?;
self.mode.azalea_write(buf)?;
- let mut set = FixedBitSet::<{ 3_usize.div_ceil(8) }>::new();
+ let mut set = FixedBitSet::<3>::new();
if self.track_output {
set.set(0);
}
diff --git a/azalea-protocol/src/packets/game/s_set_structure_block.rs b/azalea-protocol/src/packets/game/s_set_structure_block.rs
index b2f2aeb1..360d34fc 100644
--- a/azalea-protocol/src/packets/game/s_set_structure_block.rs
+++ b/azalea-protocol/src/packets/game/s_set_structure_block.rs
@@ -73,7 +73,7 @@ pub struct Flags {
impl AzaleaRead for Flags {
fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let set = FixedBitSet::<{ 3_usize.div_ceil(8) }>::azalea_read(buf)?;
+ let set = FixedBitSet::<3>::azalea_read(buf)?;
Ok(Self {
ignore_entities: set.index(0),
show_air: set.index(1),
@@ -84,7 +84,7 @@ impl AzaleaRead for Flags {
impl AzaleaWrite for Flags {
fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
- let mut set = FixedBitSet::<{ 3_usize.div_ceil(8) }>::new();
+ let mut set = FixedBitSet::<3>::new();
if self.ignore_entities {
set.set(0);
}