mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
.get() -> .into_packet()
This commit is contained in:
parent
eabb329085
commit
68e3d0104b
29 changed files with 139 additions and 135 deletions
|
@ -90,7 +90,7 @@ pub fn handle_attack_event(
|
|||
action: s_interact::ActionType::Attack,
|
||||
using_secondary_action: **sneaking,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
|
||||
// we can't attack if we're in spectator mode but it still sends the attack
|
||||
|
|
|
@ -274,10 +274,10 @@ pub fn handle_send_chat_kind_event(
|
|||
signature: None,
|
||||
last_seen_messages: LastSeenMessagesUpdate::default(),
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
ChatKind::Command => {
|
||||
// TODO: chat signing
|
||||
ServerboundChatCommand { command: content }.get()
|
||||
ServerboundChatCommand { command: content }.into_variant()
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ pub fn handle_chunk_batch_finished_event(
|
|||
packet: ServerboundChunkBatchReceived {
|
||||
desired_chunks_per_tick,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -356,7 +356,7 @@ impl Client {
|
|||
port: address.port,
|
||||
intention: ClientIntention::Login,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
)
|
||||
.await?;
|
||||
let mut conn = conn.login();
|
||||
|
@ -377,7 +377,7 @@ impl Client {
|
|||
// Uuid::default()
|
||||
profile_id: account.uuid.unwrap_or_default(),
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
@ -443,7 +443,7 @@ impl Client {
|
|||
key_bytes: e.encrypted_public_key,
|
||||
encrypted_challenge: e.encrypted_challenge,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
@ -458,7 +458,8 @@ impl Client {
|
|||
"Got profile {:?}. handshake is finished and we're now switching to the configuration state",
|
||||
p.game_profile
|
||||
);
|
||||
conn.write(ServerboundLoginAcknowledged {}.get()).await?;
|
||||
conn.write(ServerboundLoginAcknowledged {}.into_variant())
|
||||
.await?;
|
||||
break (conn.configuration(), p.game_profile);
|
||||
}
|
||||
ClientboundLoginPacket::LoginDisconnect(p) => {
|
||||
|
@ -600,7 +601,7 @@ impl Client {
|
|||
"Sending client information (already logged in): {:?}",
|
||||
client_information
|
||||
);
|
||||
self.write_packet(azalea_protocol::packets::game::s_client_information::ServerboundClientInformation { information: client_information.clone() }.get())?;
|
||||
self.write_packet(azalea_protocol::packets::game::s_client_information::ServerboundClientInformation { information: client_information.clone() }.into_variant())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -37,7 +37,7 @@ fn handle_in_configuration_state(
|
|||
identifier: ResourceLocation::new("brand"),
|
||||
data: brand_data.into(),
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
|
||||
send_packet_events.send(SendConfigurationEvent {
|
||||
|
@ -45,7 +45,7 @@ fn handle_in_configuration_state(
|
|||
packet: ServerboundClientInformation {
|
||||
information: client_information.clone(),
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ pub fn handle_block_interact_event(
|
|||
block_hit,
|
||||
sequence: sequence_number.0,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ pub fn handle_swing_arm_event(
|
|||
packet: ServerboundSwing {
|
||||
hand: InteractionHand::MainHand,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -632,7 +632,7 @@ fn handle_container_close_event(
|
|||
packet: ServerboundContainerClose {
|
||||
container_id: inventory.id,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
client_side_events.send(ClientSideCloseContainerEvent {
|
||||
entity: event.entity,
|
||||
|
@ -706,7 +706,7 @@ pub fn handle_container_click_event(
|
|||
changed_slots,
|
||||
carried_item: inventory.carried.clone(),
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -768,7 +768,7 @@ fn handle_set_selected_hotbar_slot_event(
|
|||
packet: ServerboundSetCarriedItem {
|
||||
slot: event.slot as u16,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ fn handle_start_mining_block_with_direction_event(
|
|||
direction: event.direction,
|
||||
sequence: 0,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -332,7 +332,7 @@ fn handle_start_mining_block_with_direction_event(
|
|||
direction: event.direction,
|
||||
sequence: **sequence_number,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -502,7 +502,7 @@ pub fn handle_stop_mining_block_event(
|
|||
direction: Direction::Down,
|
||||
sequence: 0,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
commands.entity(event.entity).remove::<Mining>();
|
||||
**mine_progress = 0.;
|
||||
|
@ -576,7 +576,7 @@ pub fn continue_mining_block(
|
|||
direction: mining.dir,
|
||||
sequence: **sequence_number,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
swing_arm_events.send(SwingArmEvent { entity });
|
||||
} else if is_same_mining_target(
|
||||
|
@ -622,7 +622,7 @@ pub fn continue_mining_block(
|
|||
direction: mining.dir,
|
||||
sequence: **sequence_number,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
**mine_progress = 0.;
|
||||
**mine_ticks = 0.;
|
||||
|
|
|
@ -196,7 +196,7 @@ pub fn send_position(
|
|||
y_rot: direction.y_rot,
|
||||
on_ground: physics.on_ground,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
)
|
||||
} else if sending_position {
|
||||
Some(
|
||||
|
@ -206,7 +206,7 @@ pub fn send_position(
|
|||
z: position.z,
|
||||
on_ground: physics.on_ground,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
)
|
||||
} else if sending_direction {
|
||||
Some(
|
||||
|
@ -215,14 +215,14 @@ pub fn send_position(
|
|||
y_rot: direction.y_rot,
|
||||
on_ground: physics.on_ground,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
)
|
||||
} else if physics.last_on_ground != physics.on_ground {
|
||||
Some(
|
||||
ServerboundMovePlayerStatusOnly {
|
||||
on_ground: physics.on_ground,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
|
@ -268,7 +268,7 @@ fn send_sprinting_if_needed(
|
|||
action: sprinting_action,
|
||||
data: 0,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
physics_state.was_sprinting = **sprinting;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
let mut raw_connection = query.get_mut(player_entity).unwrap();
|
||||
|
||||
raw_connection
|
||||
.write_packet(ServerboundFinishConfiguration {}.get())
|
||||
.write_packet(ServerboundFinishConfiguration {}.into_variant())
|
||||
.expect(
|
||||
"we should be in the right state and encoding this packet shouldn't fail",
|
||||
);
|
||||
|
@ -150,7 +150,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
id: p.id,
|
||||
});
|
||||
raw_connection
|
||||
.write_packet(ServerboundKeepAlive { id: p.id }.get())
|
||||
.write_packet(ServerboundKeepAlive { id: p.id }.into_variant())
|
||||
.unwrap();
|
||||
}
|
||||
ClientboundConfigPacket::Ping(p) => {
|
||||
|
@ -161,7 +161,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
let raw_connection = query.get_mut(player_entity).unwrap();
|
||||
|
||||
raw_connection
|
||||
.write_packet(config::s_pong::ServerboundPong { id: p.id }.get())
|
||||
.write_packet(config::s_pong::ServerboundPong { id: p.id }.into_variant())
|
||||
.unwrap();
|
||||
}
|
||||
ClientboundConfigPacket::ResourcePackPush(p) => {
|
||||
|
@ -178,7 +178,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
id: p.id,
|
||||
action: config::s_resource_pack::Action::Accepted,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
ServerboundSelectKnownPacks {
|
||||
known_packs: vec![],
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
@ -340,7 +340,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
);
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: player_entity,
|
||||
packet: azalea_protocol::packets::game::s_client_information::ServerboundClientInformation { information: client_information.clone() }.get(),
|
||||
packet: azalea_protocol::packets::game::s_client_information::ServerboundClientInformation { information: client_information.clone() }.into_variant(),
|
||||
});
|
||||
|
||||
system_state.apply(ecs);
|
||||
|
@ -493,7 +493,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: player_entity,
|
||||
packet: ServerboundAcceptTeleportation { id: p.id }.get(),
|
||||
packet: ServerboundAcceptTeleportation { id: p.id }.into_variant(),
|
||||
});
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: player_entity,
|
||||
|
@ -506,7 +506,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
// this is always false
|
||||
on_ground: false,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
}
|
||||
ClientboundGamePacket::PlayerInfoUpdate(p) => {
|
||||
|
@ -983,7 +983,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
});
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: player_entity,
|
||||
packet: ServerboundKeepAlive { id: p.id }.get(),
|
||||
packet: ServerboundKeepAlive { id: p.id }.into_variant(),
|
||||
});
|
||||
}
|
||||
ClientboundGamePacket::RemoveEntities(p) => {
|
||||
|
@ -1279,7 +1279,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: player_entity,
|
||||
packet: ServerboundPong { id: p.id }.get(),
|
||||
packet: ServerboundPong { id: p.id }.into_variant(),
|
||||
});
|
||||
}
|
||||
ClientboundGamePacket::PlaceGhostRecipe(_) => {}
|
||||
|
@ -1423,7 +1423,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
|
||||
packet_events.send(SendPacketEvent {
|
||||
entity: player_entity,
|
||||
packet: ServerboundConfigurationAcknowledged {}.get(),
|
||||
packet: ServerboundConfigurationAcknowledged {}.into_variant(),
|
||||
});
|
||||
|
||||
commands
|
||||
|
|
|
@ -92,7 +92,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
transaction_id: p.transaction_id,
|
||||
data: None,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -81,13 +81,14 @@ pub async fn ping_server_with_connection(
|
|||
port: address.port,
|
||||
intention: ClientIntention::Status,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
)
|
||||
.await?;
|
||||
let mut conn = conn.status();
|
||||
|
||||
// send the empty status request packet
|
||||
conn.write(ServerboundStatusRequest {}.get()).await?;
|
||||
conn.write(ServerboundStatusRequest {}.into_variant())
|
||||
.await?;
|
||||
|
||||
let packet = conn.read().await?;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ pub fn perform_respawn(
|
|||
packet: ServerboundClientCommand {
|
||||
action: s_client_command::Action::PerformRespawn,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -699,10 +699,10 @@ mod tests {
|
|||
let block_state = world_lock.write().chunks.set_block_state(
|
||||
&BlockPos { x: 0, y: 69, z: 0 },
|
||||
azalea_block::blocks::CobblestoneWall {
|
||||
east: azalea_block::properties::EastWall::Low,
|
||||
north: azalea_block::properties::NorthWall::Low,
|
||||
south: azalea_block::properties::SouthWall::Low,
|
||||
west: azalea_block::properties::WestWall::Low,
|
||||
east: azalea_block::properties::WallEast::Low,
|
||||
north: azalea_block::properties::WallNorth::Low,
|
||||
south: azalea_block::properties::WallSouth::Low,
|
||||
west: azalea_block::properties::WallWest::Low,
|
||||
up: false,
|
||||
waterlogged: false,
|
||||
}
|
||||
|
@ -761,10 +761,10 @@ mod tests {
|
|||
z: -8,
|
||||
},
|
||||
azalea_block::blocks::CobblestoneWall {
|
||||
east: azalea_block::properties::EastWall::Low,
|
||||
north: azalea_block::properties::NorthWall::Low,
|
||||
south: azalea_block::properties::SouthWall::Low,
|
||||
west: azalea_block::properties::WestWall::Low,
|
||||
east: azalea_block::properties::WallEast::Low,
|
||||
north: azalea_block::properties::WallNorth::Low,
|
||||
south: azalea_block::properties::WallSouth::Low,
|
||||
west: azalea_block::properties::WallWest::Low,
|
||||
up: false,
|
||||
waterlogged: false,
|
||||
}
|
||||
|
|
|
@ -20,10 +20,6 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke
|
|||
|
||||
let contents = quote! {
|
||||
impl #ident {
|
||||
pub fn get(self) -> #state {
|
||||
#state::#variant_name(self)
|
||||
}
|
||||
|
||||
pub fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
|
||||
azalea_buf::McBufWritable::write_into(self, buf)
|
||||
}
|
||||
|
@ -32,7 +28,12 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke
|
|||
buf: &mut std::io::Cursor<&[u8]>,
|
||||
) -> Result<#state, azalea_buf::BufReadError> {
|
||||
use azalea_buf::McBufReadable;
|
||||
Ok(Self::read_from(buf)?.get())
|
||||
Ok(Self::read_from(buf)?.into_variant())
|
||||
}
|
||||
|
||||
/// Convert this packet into an variant for the enum of the state and direction.
|
||||
pub fn into_variant(self) -> #state {
|
||||
#state::#variant_name(self)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@ use azalea_protocol::{
|
|||
connect::Connection,
|
||||
packets::{
|
||||
handshake::{
|
||||
client_intention::ClientIntention, ClientboundHandshakePacket,
|
||||
s_client_intention::ServerboundClientIntention, ClientboundHandshakePacket,
|
||||
ServerboundHandshakePacket,
|
||||
},
|
||||
login::{s_hello::ServerboundHello, ServerboundLoginPacket},
|
||||
|
@ -108,12 +108,12 @@ async fn handle_connection(stream: TcpStream) -> anyhow::Result<()> {
|
|||
version: PROXY_VERSION.clone(),
|
||||
enforces_secure_chat: PROXY_SECURE_CHAT,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
ServerboundStatusPacket::PingRequest(p) => {
|
||||
conn.write(ClientboundPongResponse { time: p.time }.get())
|
||||
conn.write(ClientboundPongResponse { time: p.time }.into_variant())
|
||||
.await?;
|
||||
break;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ async fn handle_connection(stream: TcpStream) -> anyhow::Result<()> {
|
|||
|
||||
async fn transfer(
|
||||
mut inbound: TcpStream,
|
||||
intent: ClientIntention,
|
||||
intent: ServerboundClientIntention,
|
||||
hello: ServerboundHello,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
let outbound = TcpStream::connect(PROXY_ADDR).await?;
|
||||
|
@ -189,10 +189,10 @@ async fn transfer(
|
|||
// received earlier to the proxy target
|
||||
let mut outbound_conn: Connection<ClientboundHandshakePacket, ServerboundHandshakePacket> =
|
||||
Connection::wrap(outbound);
|
||||
outbound_conn.write(intent.get()).await?;
|
||||
outbound_conn.write(intent.into_variant()).await?;
|
||||
|
||||
let mut outbound_conn = outbound_conn.login();
|
||||
outbound_conn.write(hello.get()).await?;
|
||||
outbound_conn.write(hello.into_variant()).await?;
|
||||
|
||||
let mut outbound = outbound_conn.unwrap()?;
|
||||
|
||||
|
|
|
@ -139,3 +139,51 @@ impl McBufWritable for ModelCustomization {
|
|||
set.write_into(buf)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::io::Cursor;
|
||||
|
||||
use azalea_buf::{McBufReadable, McBufWritable};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_client_information() {
|
||||
{
|
||||
let data = ClientInformation::default();
|
||||
let mut buf = Vec::new();
|
||||
data.write_into(&mut buf).unwrap();
|
||||
let mut data_cursor: Cursor<&[u8]> = Cursor::new(&buf);
|
||||
|
||||
let read_data = ClientInformation::read_from(&mut data_cursor).unwrap();
|
||||
assert_eq!(read_data, data);
|
||||
}
|
||||
|
||||
let data = ClientInformation {
|
||||
language: "en_gb".to_string(),
|
||||
view_distance: 24,
|
||||
chat_visibility: ChatVisibility::Hidden,
|
||||
chat_colors: false,
|
||||
model_customization: ModelCustomization {
|
||||
cape: false,
|
||||
jacket: false,
|
||||
left_sleeve: true,
|
||||
right_sleeve: false,
|
||||
left_pants: true,
|
||||
right_pants: false,
|
||||
hat: true,
|
||||
},
|
||||
main_hand: HumanoidArm::Left,
|
||||
text_filtering_enabled: true,
|
||||
allows_listing: true,
|
||||
particle_status: ParticleStatus::Decreased,
|
||||
};
|
||||
let mut buf = Vec::new();
|
||||
data.write_into(&mut buf).unwrap();
|
||||
let mut data_cursor: Cursor<&[u8]> = Cursor::new(&buf);
|
||||
|
||||
let read_data = ClientInformation::read_from(&mut data_cursor).unwrap();
|
||||
assert_eq!(read_data, data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ pub struct WriteConnection<W: ProtocolPacket> {
|
|||
/// port: resolved_address.port(),
|
||||
/// intention: ClientIntention::Login,
|
||||
/// }
|
||||
/// .get(),
|
||||
/// .into_variant(),
|
||||
/// )
|
||||
/// .await?;
|
||||
///
|
||||
|
@ -96,7 +96,7 @@ pub struct WriteConnection<W: ProtocolPacket> {
|
|||
/// name: "bot".to_string(),
|
||||
/// profile_id: uuid::Uuid::nil(),
|
||||
/// }
|
||||
/// .get(),
|
||||
/// .into_variant(),
|
||||
/// )
|
||||
/// .await?;
|
||||
///
|
||||
|
@ -111,7 +111,7 @@ pub struct WriteConnection<W: ProtocolPacket> {
|
|||
/// key_bytes: e.encrypted_public_key,
|
||||
/// encrypted_challenge: e.encrypted_challenge,
|
||||
/// }
|
||||
/// .get(),
|
||||
/// .into_variant(),
|
||||
/// )
|
||||
/// .await?;
|
||||
/// conn.set_encryption_key(e.secret_key);
|
||||
|
@ -414,7 +414,7 @@ impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> {
|
|||
/// ServerboundKeyPacket {
|
||||
/// key_bytes: e.encrypted_public_key,
|
||||
/// encrypted_challenge: e.encrypted_challenge,
|
||||
/// }.get()
|
||||
/// }.into_variant()
|
||||
/// ).await?;
|
||||
/// conn.set_encryption_key(e.secret_key);
|
||||
/// }
|
||||
|
|
|
@ -122,7 +122,7 @@ mod tests {
|
|||
name: "test".to_string(),
|
||||
profile_id: Uuid::nil(),
|
||||
}
|
||||
.get();
|
||||
.into_variant();
|
||||
let mut stream = Vec::new();
|
||||
write_packet(&packet, &mut stream, None, &mut None)
|
||||
.await
|
||||
|
@ -130,10 +130,14 @@ mod tests {
|
|||
|
||||
let mut stream = Cursor::new(stream);
|
||||
|
||||
let _ =
|
||||
read::<ServerboundLoginPacket, _>(&mut stream, &mut BytesMut::new(), None, &mut None)
|
||||
.await
|
||||
.unwrap();
|
||||
let _ = read_packet::<ServerboundLoginPacket, _>(
|
||||
&mut stream,
|
||||
&mut BytesMut::new(),
|
||||
None,
|
||||
&mut None,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
@ -142,7 +146,7 @@ mod tests {
|
|||
name: "test".to_string(),
|
||||
profile_id: Uuid::nil(),
|
||||
}
|
||||
.get();
|
||||
.into_variant();
|
||||
let mut stream = Vec::new();
|
||||
write_packet(&packet, &mut stream, None, &mut None)
|
||||
.await
|
||||
|
@ -154,10 +158,10 @@ mod tests {
|
|||
|
||||
let mut buffer = BytesMut::new();
|
||||
|
||||
let _ = read::<ServerboundLoginPacket, _>(&mut stream, &mut buffer, None, &mut None)
|
||||
let _ = read_packet::<ServerboundLoginPacket, _>(&mut stream, &mut buffer, None, &mut None)
|
||||
.await
|
||||
.unwrap();
|
||||
let _ = read::<ServerboundLoginPacket, _>(&mut stream, &mut buffer, None, &mut None)
|
||||
let _ = read_packet::<ServerboundLoginPacket, _>(&mut stream, &mut buffer, None, &mut None)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -174,7 +178,7 @@ mod tests {
|
|||
signature: None,
|
||||
last_seen_messages: LastSeenMessagesUpdate::default(),
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -7,53 +7,3 @@ use crate::common::ClientInformation;
|
|||
pub struct ServerboundClientInformation {
|
||||
pub information: ClientInformation,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::io::Cursor;
|
||||
|
||||
use azalea_buf::{McBufReadable, McBufWritable};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_client_information_packet() {
|
||||
{
|
||||
let data = ClientInformation::default();
|
||||
let mut buf = Vec::new();
|
||||
data.write_into(&mut buf).unwrap();
|
||||
let mut data_cursor: Cursor<&[u8]> = Cursor::new(&buf);
|
||||
|
||||
let read_data = ClientInformation::read_from(&mut data_cursor).unwrap();
|
||||
assert_eq!(read_data, data);
|
||||
}
|
||||
|
||||
{
|
||||
let data = ClientInformation {
|
||||
language: "en_gb".to_string(),
|
||||
view_distance: 24,
|
||||
chat_visibility: ChatVisibility::Hidden,
|
||||
chat_colors: false,
|
||||
model_customization: ModelCustomization {
|
||||
cape: false,
|
||||
jacket: false,
|
||||
left_sleeve: true,
|
||||
right_sleeve: false,
|
||||
left_pants: true,
|
||||
right_pants: false,
|
||||
hat: true,
|
||||
},
|
||||
main_hand: HumanoidArm::Left,
|
||||
text_filtering_enabled: true,
|
||||
allows_listing: true,
|
||||
particle_status: ParticleStatus::Decreased,
|
||||
};
|
||||
let mut buf = Vec::new();
|
||||
data.write_into(&mut buf).unwrap();
|
||||
let mut data_cursor: Cursor<&[u8]> = Cursor::new(&buf);
|
||||
|
||||
let read_data = ClientInformation::read_from(&mut data_cursor).unwrap();
|
||||
assert_eq!(read_data, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,8 +128,8 @@ pub enum BrigadierParser {
|
|||
ScoreHolder { allows_multiple: bool },
|
||||
Swizzle,
|
||||
Team,
|
||||
ItemStack,
|
||||
ItemStacks,
|
||||
ItemSlot,
|
||||
ItemSlots,
|
||||
ResourceLocation,
|
||||
Function,
|
||||
EntityAnchor,
|
||||
|
|
|
@ -160,7 +160,7 @@ mod tests {
|
|||
};
|
||||
let mut buf = Vec::new();
|
||||
packet.write_into(&mut buf).unwrap();
|
||||
let packet2 = ClientboundExplodePacket::read_from(&mut Cursor::new(&buf)).unwrap();
|
||||
let packet2 = ClientboundExplode::read_from(&mut Cursor::new(&buf)).unwrap();
|
||||
assert_eq!(packet, packet2);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -33,7 +33,7 @@ mod tests {
|
|||
][..];
|
||||
let mut bytes = Cursor::new(slice);
|
||||
|
||||
let _packet = ClientboundLevelParticlesPacket::read_from(&mut bytes).unwrap();
|
||||
let _packet = ClientboundLevelParticles::read_from(&mut bytes).unwrap();
|
||||
assert_eq!(bytes.position(), slice.len() as u64);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -308,6 +308,6 @@ mod tests {
|
|||
0,
|
||||
][..],
|
||||
);
|
||||
let _packet = ClientboundPlayerInfoUpdatePacket::read_from(&mut bytes).unwrap();
|
||||
let _packet = ClientboundPlayerInfoUpdate::read_from(&mut bytes).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ mod tests {
|
|||
let mut bytes = Cursor::new(&[
|
||||
10, 9, 0, 5, 101, 120, 116, 114, 97, 10, 0, 0, 0, 3, 1, 0, 4, 98, 111, 108, 100, 1, 8, 0, 4, 116, 101, 120, 116, 0, 16, 50, 66, 85, 73, 76, 68, 69, 82, 83, 50, 84, 79, 79, 76, 83, 10, 8, 0, 5, 99, 111, 108, 111, 114, 0, 4, 103, 114, 97, 121, 0, 8, 0, 0, 0, 1, 10, 0, 8, 0, 5, 99, 111, 108, 111, 114, 0, 4, 103, 111, 108, 100, 8, 0, 4, 116, 101, 120, 116, 0, 27, 80, 101, 110, 100, 105, 110, 103, 32, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 32, 116, 111, 32, 50, 98, 50, 116, 10, 0, 8, 0, 4, 116, 101, 120, 116, 0, 1, 10, 0, 10, 9, 0, 5, 101, 120, 116, 114, 97, 10, 0, 0, 0, 1, 8, 0, 5, 99, 111, 108, 111, 114, 0, 4, 103, 111, 108, 100, 8, 0, 4, 116, 101, 120, 116, 0, 72, 84, 104, 105, 115, 32, 97, 99, 99, 111, 117, 110, 116, 32, 104, 97, 115, 32, 112, 114, 105, 111, 114, 105, 116, 121, 32, 115, 116, 97, 116, 117, 115, 32, 97, 110, 100, 32, 119, 105, 108, 108, 32, 98, 101, 32, 112, 108, 97, 99, 101, 100, 32, 105, 110, 32, 97, 32, 115, 104, 111, 114, 116, 101, 114, 32, 113, 117, 101, 117, 101, 46, 10, 0, 8, 0, 4, 116, 101, 120, 116, 0, 1, 10, 0
|
||||
][..]);
|
||||
let _packet = ClientboundTabListPacket::read_from(&mut bytes).unwrap();
|
||||
let _packet = ClientboundTabList::read_from(&mut bytes).unwrap();
|
||||
assert!(bytes.get_ref()[bytes.position() as usize..].is_empty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1504,8 +1504,8 @@ enum CommandArgumentKind {
|
|||
ScoreHolder => "minecraft:score_holder",
|
||||
Swizzle => "minecraft:swizzle",
|
||||
Team => "minecraft:team",
|
||||
ItemStack => "minecraft:item_slot",
|
||||
ItemStacks => "minecraft:item_slots",
|
||||
ItemSlot => "minecraft:item_slot",
|
||||
ItemSlots => "minecraft:item_slots",
|
||||
ResourceLocation => "minecraft:resource_location",
|
||||
Function => "minecraft:function",
|
||||
EntityAnchor => "minecraft:entity_anchor",
|
||||
|
|
|
@ -36,7 +36,7 @@ fn accept_resource_pack(
|
|||
id: event.id,
|
||||
action: s_resource_pack::Action::Accepted,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: event.entity,
|
||||
|
@ -44,7 +44,7 @@ fn accept_resource_pack(
|
|||
id: event.id,
|
||||
action: s_resource_pack::Action::SuccessfullyLoaded,
|
||||
}
|
||||
.get(),
|
||||
.into_variant(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue