aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/game
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2026-03-24 11:15:56 -0500
committerGitHub <noreply@github.com>2026-03-24 11:15:56 -0500
commiteeaf1435e81d9cbd8daa0efa22029c1f259a64b5 (patch)
tree3486e26d5409708370e4e259d240fb77c6e1e439 /azalea-protocol/src/packets/game
parent41a9ae6aaff77646c08c64ac1334a8cc6081c24f (diff)
downloadazalea-drasl-eeaf1435e81d9cbd8daa0efa22029c1f259a64b5.tar.xz
26.1 (#316)
* start updating to 26.1 * start updating to 26.1-snapshot-6 * 26.1-snapshot-6 * 26.1-snapshot-10 * 26.1-rc-1 * fix tests * 26.1-rc-2 and sort default components * 26.1 * update changelog
Diffstat (limited to 'azalea-protocol/src/packets/game')
-rw-r--r--azalea-protocol/src/packets/game/c_game_rule_values.rs9
-rw-r--r--azalea-protocol/src/packets/game/c_low_disk_space_warning.rs5
-rw-r--r--azalea-protocol/src/packets/game/c_set_entity_data.rs22
-rw-r--r--azalea-protocol/src/packets/game/c_set_time.rs13
-rw-r--r--azalea-protocol/src/packets/game/mod.rs5
-rw-r--r--azalea-protocol/src/packets/game/s_attack.rs8
-rw-r--r--azalea-protocol/src/packets/game/s_client_command.rs1
-rw-r--r--azalea-protocol/src/packets/game/s_interact.rs71
-rw-r--r--azalea-protocol/src/packets/game/s_set_game_rule.rs15
-rw-r--r--azalea-protocol/src/packets/game/s_spectate_entity.rs8
10 files changed, 67 insertions, 90 deletions
diff --git a/azalea-protocol/src/packets/game/c_game_rule_values.rs b/azalea-protocol/src/packets/game/c_game_rule_values.rs
new file mode 100644
index 00000000..3fc2b619
--- /dev/null
+++ b/azalea-protocol/src/packets/game/c_game_rule_values.rs
@@ -0,0 +1,9 @@
+use azalea_buf::AzBuf;
+use azalea_protocol_macros::ClientboundGamePacket;
+use azalea_registry::builtin::GameRule;
+use indexmap::IndexMap;
+
+#[derive(Clone, Debug, AzBuf, PartialEq, ClientboundGamePacket)]
+pub struct ClientboundGameRuleValues {
+ pub values: IndexMap<GameRule, String>,
+}
diff --git a/azalea-protocol/src/packets/game/c_low_disk_space_warning.rs b/azalea-protocol/src/packets/game/c_low_disk_space_warning.rs
new file mode 100644
index 00000000..e3b3e72a
--- /dev/null
+++ b/azalea-protocol/src/packets/game/c_low_disk_space_warning.rs
@@ -0,0 +1,5 @@
+use azalea_buf::AzBuf;
+use azalea_protocol_macros::ClientboundGamePacket;
+
+#[derive(Clone, Debug, AzBuf, PartialEq, ClientboundGamePacket)]
+pub struct ClientboundLowDiskSpaceWarning;
diff --git a/azalea-protocol/src/packets/game/c_set_entity_data.rs b/azalea-protocol/src/packets/game/c_set_entity_data.rs
index 1b4b46cd..d3fce384 100644
--- a/azalea-protocol/src/packets/game/c_set_entity_data.rs
+++ b/azalea-protocol/src/packets/game/c_set_entity_data.rs
@@ -9,25 +9,3 @@ pub struct ClientboundSetEntityData {
pub id: MinecraftEntityId,
pub packed_items: EntityMetadataItems,
}
-
-#[cfg(test)]
-mod tests {
- use std::io::Cursor;
-
- use azalea_buf::AzBuf;
-
- use super::*;
-
- #[test]
- fn test_read_6b6t_entity_data() {
- let contents = [
- 254, 180, 160, 8, 11, 33, 190, 230, 102, 102, 0, 0, 0, 0, 191, 0, 0, 0, 12, 33, 63,
- 102, 102, 102, 63, 25, 153, 154, 63, 102, 102, 102, 23, 14, 234, 64, 255,
- ];
- let mut buf = Cursor::new(contents.as_slice());
- let packet = ClientboundSetEntityData::azalea_read(&mut buf).unwrap();
- println!("{packet:?}");
-
- assert_eq!(buf.position(), contents.len() as u64);
- }
-}
diff --git a/azalea-protocol/src/packets/game/c_set_time.rs b/azalea-protocol/src/packets/game/c_set_time.rs
index ff795e87..efc95e0d 100644
--- a/azalea-protocol/src/packets/game/c_set_time.rs
+++ b/azalea-protocol/src/packets/game/c_set_time.rs
@@ -1,9 +1,18 @@
use azalea_buf::AzBuf;
use azalea_protocol_macros::ClientboundGamePacket;
+use azalea_registry::data::WorldClock;
+use indexmap::IndexMap;
#[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)]
pub struct ClientboundSetTime {
pub game_time: u64,
- pub day_time: u64,
- pub tick_day_time: bool,
+ pub clock_updates: IndexMap<WorldClock, ClockState>,
+}
+
+#[derive(AzBuf, Clone, Debug, PartialEq)]
+pub struct ClockState {
+ #[var]
+ pub total_ticks: u64,
+ pub partial_tick: f32,
+ pub rate: f32,
}
diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs
index 3235231c..d42d46eb 100644
--- a/azalea-protocol/src/packets/game/mod.rs
+++ b/azalea-protocol/src/packets/game/mod.rs
@@ -44,6 +44,7 @@ declare_state_packets!(GamePacket,
explode,
forget_level_chunk,
game_event,
+ game_rule_values,
game_test_highlight_pos,
mount_screen_open,
hurt_animation,
@@ -54,6 +55,7 @@ declare_state_packets!(GamePacket,
level_particles,
light_update,
login,
+ low_disk_space_warning,
map_item_data,
merchant_offers,
move_entity_pos,
@@ -147,6 +149,7 @@ declare_state_packets!(GamePacket,
],
Serverbound => [
accept_teleportation,
+ attack,
block_entity_tag_query,
bundle_item_selected,
change_difficulty,
@@ -202,10 +205,12 @@ declare_state_packets!(GamePacket,
set_command_block,
set_command_minecart,
set_creative_mode_slot,
+ set_game_rule,
set_jigsaw_block,
set_structure_block,
set_test_block,
sign_update,
+ spectate_entity,
swing,
teleport_to_entity,
test_instance_block_action,
diff --git a/azalea-protocol/src/packets/game/s_attack.rs b/azalea-protocol/src/packets/game/s_attack.rs
new file mode 100644
index 00000000..0edc2395
--- /dev/null
+++ b/azalea-protocol/src/packets/game/s_attack.rs
@@ -0,0 +1,8 @@
+use azalea_buf::AzBuf;
+use azalea_core::entity_id::MinecraftEntityId;
+use azalea_protocol_macros::ServerboundGamePacket;
+
+#[derive(Clone, Debug, AzBuf, PartialEq, ServerboundGamePacket)]
+pub struct ServerboundAttack {
+ pub entity_id: MinecraftEntityId,
+}
diff --git a/azalea-protocol/src/packets/game/s_client_command.rs b/azalea-protocol/src/packets/game/s_client_command.rs
index 04fe8936..5212b5ee 100644
--- a/azalea-protocol/src/packets/game/s_client_command.rs
+++ b/azalea-protocol/src/packets/game/s_client_command.rs
@@ -10,4 +10,5 @@ pub struct ServerboundClientCommand {
pub enum Action {
PerformRespawn = 0,
RequestStats = 1,
+ RequestGameruleValues = 2,
}
diff --git a/azalea-protocol/src/packets/game/s_interact.rs b/azalea-protocol/src/packets/game/s_interact.rs
index bd04e09d..2f0494ae 100644
--- a/azalea-protocol/src/packets/game/s_interact.rs
+++ b/azalea-protocol/src/packets/game/s_interact.rs
@@ -1,78 +1,17 @@
-use std::io::{self, Cursor, Write};
-
-use azalea_buf::{AzBuf, AzBufVar};
-use azalea_core::{
- entity_id::MinecraftEntityId,
- position::{Vec3, Vec3f32},
-};
+use azalea_buf::AzBuf;
+use azalea_core::{delta::LpVec3, entity_id::MinecraftEntityId};
use azalea_protocol_macros::ServerboundGamePacket;
-use crate::packets::BufReadError;
-
#[derive(AzBuf, Clone, Debug, PartialEq, ServerboundGamePacket)]
pub struct ServerboundInteract {
#[var]
pub entity_id: MinecraftEntityId,
- pub action: ActionType,
- /// Whether the player is sneaking
+ pub hand: InteractionHand,
+ pub location: LpVec3,
+ /// Whether the player is sneaking.
pub using_secondary_action: bool,
}
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum ActionType {
- Interact {
- hand: InteractionHand,
- },
- Attack,
- InteractAt {
- location: Vec3,
- hand: InteractionHand,
- },
-}
-
-impl AzBuf for ActionType {
- fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> {
- let action_type = u32::azalea_read_var(buf)?;
- match action_type {
- 0 => {
- let hand = InteractionHand::azalea_read(buf)?;
- Ok(ActionType::Interact { hand })
- }
- 1 => Ok(ActionType::Attack),
- 2 => {
- let pos = Vec3f32::azalea_read(buf)?;
- let hand = InteractionHand::azalea_read(buf)?;
- Ok(ActionType::InteractAt {
- location: Vec3::from(pos),
- hand,
- })
- }
- _ => Err(BufReadError::UnexpectedEnumVariant {
- id: action_type as i32,
- }),
- }
- }
- fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
- match self {
- ActionType::Interact { hand } => {
- 0u32.azalea_write_var(buf)?;
- hand.azalea_write(buf)?;
- }
- ActionType::Attack => {
- 1u32.azalea_write_var(buf)?;
- }
- ActionType::InteractAt { location, hand } => {
- 2u32.azalea_write_var(buf)?;
- (location.x as f32).azalea_write(buf)?;
- (location.y as f32).azalea_write(buf)?;
- (location.z as f32).azalea_write(buf)?;
- hand.azalea_write(buf)?;
- }
- }
- Ok(())
- }
-}
-
#[derive(AzBuf, Clone, Copy, Debug, Default, PartialEq)]
pub enum InteractionHand {
#[default]
diff --git a/azalea-protocol/src/packets/game/s_set_game_rule.rs b/azalea-protocol/src/packets/game/s_set_game_rule.rs
new file mode 100644
index 00000000..c49d97b9
--- /dev/null
+++ b/azalea-protocol/src/packets/game/s_set_game_rule.rs
@@ -0,0 +1,15 @@
+use azalea_buf::AzBuf;
+use azalea_protocol_macros::ServerboundGamePacket;
+use azalea_registry::identifier::Identifier;
+
+#[derive(Clone, Debug, AzBuf, PartialEq, ServerboundGamePacket)]
+pub struct ServerboundSetGameRule {
+ pub entries: Vec<GameRuleEntry>,
+}
+
+#[derive(Clone, Debug, AzBuf, PartialEq)]
+pub struct GameRuleEntry {
+ /// An identifier for a [`GameRule`](azalea_registry::builtin::GameRule).
+ pub key: Identifier,
+ pub value: String,
+}
diff --git a/azalea-protocol/src/packets/game/s_spectate_entity.rs b/azalea-protocol/src/packets/game/s_spectate_entity.rs
new file mode 100644
index 00000000..c9e5a985
--- /dev/null
+++ b/azalea-protocol/src/packets/game/s_spectate_entity.rs
@@ -0,0 +1,8 @@
+use azalea_buf::AzBuf;
+use azalea_core::entity_id::MinecraftEntityId;
+use azalea_protocol_macros::ServerboundGamePacket;
+
+#[derive(Clone, Debug, AzBuf, PartialEq, ServerboundGamePacket)]
+pub struct ServerboundSpectateEntity {
+ pub entity_id: MinecraftEntityId,
+}