diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2024-11-27 19:31:40 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-27 19:31:40 -0600 |
| commit | 08958c2278b15ebeac8a964f392ebb792e479b61 (patch) | |
| tree | 4ae3664cea38d7fd1a8f1e95ed06fac04ffe519e /azalea-client/src/movement.rs | |
| parent | 139d77d3c2b0922fba5e9d4fa2bd9819d78bd773 (diff) | |
| download | azalea-drasl-08958c2278b15ebeac8a964f392ebb792e479b61.tar.xz | |
Refactor azalea-protocol (#190)
* start updating to 1.21.4
* fix block codegen and stop using block data from burger
* rename packet related modules and structs to be simpler
* ItemSlot -> ItemStack for more consistency with mojmap
* .get() -> .into_packet()
* simplify declare_state_packets by removing packet ids
* rename read_from and write_into to azalea_read and azalea_write
* rename McBufReadable and McBufWritable to AzaleaRead and AzaleaWrite
* McBuf -> AzBuf
* remove most uses of into_variant
* update codegen and use resourcelocation names for packets
* implement #[limit(i)] attribute for AzBuf derive macro
* fixes for 1.21.4
* fix examples
* update some physics code and fix ChatType
* remove unused imports in codegen
* re-add some things to migrate.py and update +mc version numbers automatically
* downgrade to 1.21.3 lol
Diffstat (limited to 'azalea-client/src/movement.rs')
| -rw-r--r-- | azalea-client/src/movement.rs | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/azalea-client/src/movement.rs b/azalea-client/src/movement.rs index 806f8734..3304e27d 100644 --- a/azalea-client/src/movement.rs +++ b/azalea-client/src/movement.rs @@ -5,12 +5,15 @@ use azalea_core::tick::GameTick; use azalea_entity::{metadata::Sprinting, Attributes, Jumping}; use azalea_entity::{InLoadedChunk, LastSentPosition, LookDirection, Physics, Position}; use azalea_physics::{ai_step, PhysicsSet}; -use azalea_protocol::packets::game::serverbound_player_command_packet::ServerboundPlayerCommandPacket; -use azalea_protocol::packets::game::{ - serverbound_move_player_pos_packet::ServerboundMovePlayerPosPacket, - serverbound_move_player_pos_rot_packet::ServerboundMovePlayerPosRotPacket, - serverbound_move_player_rot_packet::ServerboundMovePlayerRotPacket, - serverbound_move_player_status_only_packet::ServerboundMovePlayerStatusOnlyPacket, +use azalea_protocol::packets::game::ServerboundPlayerCommand; +use azalea_protocol::packets::{ + game::{ + s_move_player_pos::ServerboundMovePlayerPos, + s_move_player_pos_rot::ServerboundMovePlayerPosRot, + s_move_player_rot::ServerboundMovePlayerRot, + s_move_player_status_only::ServerboundMovePlayerStatusOnly, + }, + Packet, }; use azalea_world::{MinecraftEntityId, MoveEntityError}; use bevy_app::{App, Plugin, Update}; @@ -188,7 +191,7 @@ pub fn send_position( // } let packet = if sending_position && sending_direction { Some( - ServerboundMovePlayerPosRotPacket { + ServerboundMovePlayerPosRot { x: position.x, y: position.y, z: position.z, @@ -196,33 +199,33 @@ pub fn send_position( y_rot: direction.y_rot, on_ground: physics.on_ground, } - .get(), + .into_variant(), ) } else if sending_position { Some( - ServerboundMovePlayerPosPacket { + ServerboundMovePlayerPos { x: position.x, y: position.y, z: position.z, on_ground: physics.on_ground, } - .get(), + .into_variant(), ) } else if sending_direction { Some( - ServerboundMovePlayerRotPacket { + ServerboundMovePlayerRot { x_rot: direction.x_rot, y_rot: direction.y_rot, on_ground: physics.on_ground, } - .get(), + .into_variant(), ) } else if physics.last_on_ground != physics.on_ground { Some( - ServerboundMovePlayerStatusOnlyPacket { + ServerboundMovePlayerStatusOnly { on_ground: physics.on_ground, } - .get(), + .into_variant(), ) } else { None @@ -244,7 +247,10 @@ pub fn send_position( }; if let Some(packet) = packet { - send_packet_events.send(SendPacketEvent { entity, packet }); + send_packet_events.send(SendPacketEvent { + sent_by: entity, + packet, + }); } } } @@ -257,19 +263,18 @@ fn send_sprinting_if_needed( let was_sprinting = physics_state.was_sprinting; if **sprinting != was_sprinting { let sprinting_action = if **sprinting { - azalea_protocol::packets::game::serverbound_player_command_packet::Action::StartSprinting + azalea_protocol::packets::game::s_player_command::Action::StartSprinting } else { - azalea_protocol::packets::game::serverbound_player_command_packet::Action::StopSprinting + azalea_protocol::packets::game::s_player_command::Action::StopSprinting }; - send_packet_events.send(SendPacketEvent { + send_packet_events.send(SendPacketEvent::new( entity, - packet: ServerboundPlayerCommandPacket { + ServerboundPlayerCommand { id: **minecraft_entity_id, action: sprinting_action, data: 0, - } - .get(), - }); + }, + )); physics_state.was_sprinting = **sprinting; } } |
