mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
rename packet related modules and structs to be simpler
This commit is contained in:
parent
a2a941f92a
commit
4dcd95e182
293 changed files with 1275 additions and 1319 deletions
|
@ -4,9 +4,7 @@ use azalea_entity::{
|
|||
update_bounding_box, Attributes, Physics,
|
||||
};
|
||||
use azalea_physics::PhysicsSet;
|
||||
use azalea_protocol::packets::game::serverbound_interact_packet::{
|
||||
self, ServerboundInteractPacket,
|
||||
};
|
||||
use azalea_protocol::packets::game::s_interact::{self, ServerboundInteract};
|
||||
use azalea_world::MinecraftEntityId;
|
||||
use bevy_app::{App, Plugin, Update};
|
||||
use bevy_ecs::prelude::*;
|
||||
|
@ -87,9 +85,9 @@ pub fn handle_attack_event(
|
|||
});
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: event.entity,
|
||||
packet: ServerboundInteractPacket {
|
||||
packet: ServerboundInteract {
|
||||
entity_id: *event.target,
|
||||
action: serverbound_interact_packet::ActionType::Attack,
|
||||
action: s_interact::ActionType::Attack,
|
||||
using_secondary_action: **sneaking,
|
||||
}
|
||||
.get(),
|
||||
|
|
|
@ -7,11 +7,11 @@ use std::{
|
|||
|
||||
use azalea_chat::FormattedText;
|
||||
use azalea_protocol::packets::game::{
|
||||
clientbound_disguised_chat_packet::ClientboundDisguisedChatPacket,
|
||||
clientbound_player_chat_packet::ClientboundPlayerChatPacket,
|
||||
clientbound_system_chat_packet::ClientboundSystemChatPacket,
|
||||
serverbound_chat_command_packet::ServerboundChatCommandPacket,
|
||||
serverbound_chat_packet::{LastSeenMessagesUpdate, ServerboundChatPacket},
|
||||
c_disguised_chat::ClientboundDisguisedChat,
|
||||
c_player_chat::ClientboundPlayerChat,
|
||||
c_system_chat::ClientboundSystemChat,
|
||||
s_chat::{LastSeenMessagesUpdate, ServerboundChat},
|
||||
s_chat_command::ServerboundChatCommand,
|
||||
};
|
||||
use bevy_app::{App, Plugin, Update};
|
||||
use bevy_ecs::{
|
||||
|
@ -29,10 +29,10 @@ use crate::{
|
|||
|
||||
/// A chat packet, either a system message or a chat message.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum ChatPacket {
|
||||
System(Arc<ClientboundSystemChatPacket>),
|
||||
Player(Arc<ClientboundPlayerChatPacket>),
|
||||
Disguised(Arc<ClientboundDisguisedChatPacket>),
|
||||
pub enum Chat {
|
||||
System(Arc<ClientboundSystemChat>),
|
||||
Player(Arc<ClientboundPlayerChat>),
|
||||
Disguised(Arc<ClientboundDisguisedChat>),
|
||||
}
|
||||
|
||||
macro_rules! regex {
|
||||
|
@ -42,13 +42,13 @@ macro_rules! regex {
|
|||
}};
|
||||
}
|
||||
|
||||
impl ChatPacket {
|
||||
impl Chat {
|
||||
/// Get the message shown in chat for this packet.
|
||||
pub fn message(&self) -> FormattedText {
|
||||
match self {
|
||||
ChatPacket::System(p) => p.content.clone(),
|
||||
ChatPacket::Player(p) => p.message(),
|
||||
ChatPacket::Disguised(p) => p.message(),
|
||||
Chat::System(p) => p.content.clone(),
|
||||
Chat::Player(p) => p.message(),
|
||||
Chat::Disguised(p) => p.message(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ impl ChatPacket {
|
|||
/// None.
|
||||
pub fn split_sender_and_content(&self) -> (Option<String>, String) {
|
||||
match self {
|
||||
ChatPacket::System(p) => {
|
||||
Chat::System(p) => {
|
||||
let message = p.content.to_string();
|
||||
// Overlay messages aren't in chat
|
||||
if p.overlay {
|
||||
|
@ -72,13 +72,13 @@ impl ChatPacket {
|
|||
|
||||
(None, message)
|
||||
}
|
||||
ChatPacket::Player(p) => (
|
||||
Chat::Player(p) => (
|
||||
// If it's a player chat packet, then the sender and content
|
||||
// are already split for us.
|
||||
Some(p.chat_type.name.to_string()),
|
||||
p.body.content.clone(),
|
||||
),
|
||||
ChatPacket::Disguised(p) => (
|
||||
Chat::Disguised(p) => (
|
||||
// disguised chat packets are basically the same as player chat packets but without
|
||||
// the chat signing things
|
||||
Some(p.chat_type.name.to_string()),
|
||||
|
@ -99,9 +99,9 @@ impl ChatPacket {
|
|||
/// when a server uses a plugin to modify chat messages).
|
||||
pub fn uuid(&self) -> Option<Uuid> {
|
||||
match self {
|
||||
ChatPacket::System(_) => None,
|
||||
ChatPacket::Player(m) => Some(m.sender),
|
||||
ChatPacket::Disguised(_) => None,
|
||||
Chat::System(_) => None,
|
||||
Chat::Player(m) => Some(m.sender),
|
||||
Chat::Disguised(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,10 +112,10 @@ impl ChatPacket {
|
|||
self.split_sender_and_content().1
|
||||
}
|
||||
|
||||
/// Create a new ChatPacket from a string. This is meant to be used as a
|
||||
/// Create a new Chat from a string. This is meant to be used as a
|
||||
/// convenience function for testing.
|
||||
pub fn new(message: &str) -> Self {
|
||||
ChatPacket::System(Arc::new(ClientboundSystemChatPacket {
|
||||
Chat::System(Arc::new(ClientboundSystemChat {
|
||||
content: FormattedText::from(message),
|
||||
overlay: false,
|
||||
}))
|
||||
|
@ -142,7 +142,7 @@ impl Client {
|
|||
self.ecs.lock().send_event(SendChatKindEvent {
|
||||
entity: self.entity,
|
||||
content: message.to_string(),
|
||||
kind: ChatPacketKind::Message,
|
||||
kind: ChatKind::Message,
|
||||
});
|
||||
self.run_schedule_sender.send(()).unwrap();
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ impl Client {
|
|||
self.ecs.lock().send_event(SendChatKindEvent {
|
||||
entity: self.entity,
|
||||
content: command.to_string(),
|
||||
kind: ChatPacketKind::Command,
|
||||
kind: ChatKind::Command,
|
||||
});
|
||||
self.run_schedule_sender.send(()).unwrap();
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ impl Plugin for ChatPlugin {
|
|||
#[derive(Event, Debug, Clone)]
|
||||
pub struct ChatReceivedEvent {
|
||||
pub entity: Entity,
|
||||
pub packet: ChatPacket,
|
||||
pub packet: Chat,
|
||||
}
|
||||
|
||||
/// Send a chat message (or command, if it starts with a slash) to the server.
|
||||
|
@ -216,13 +216,13 @@ pub fn handle_send_chat_event(
|
|||
send_chat_kind_events.send(SendChatKindEvent {
|
||||
entity: event.entity,
|
||||
content: event.content[1..].to_string(),
|
||||
kind: ChatPacketKind::Command,
|
||||
kind: ChatKind::Command,
|
||||
});
|
||||
} else {
|
||||
send_chat_kind_events.send(SendChatKindEvent {
|
||||
entity: event.entity,
|
||||
content: event.content.clone(),
|
||||
kind: ChatPacketKind::Message,
|
||||
kind: ChatKind::Message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -241,11 +241,11 @@ pub fn handle_send_chat_event(
|
|||
pub struct SendChatKindEvent {
|
||||
pub entity: Entity,
|
||||
pub content: String,
|
||||
pub kind: ChatPacketKind,
|
||||
pub kind: ChatKind,
|
||||
}
|
||||
|
||||
/// A kind of chat packet, either a chat message or a command.
|
||||
pub enum ChatPacketKind {
|
||||
pub enum ChatKind {
|
||||
Message,
|
||||
Command,
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ pub fn handle_send_chat_kind_event(
|
|||
.take(256)
|
||||
.collect::<String>();
|
||||
let packet = match event.kind {
|
||||
ChatPacketKind::Message => ServerboundChatPacket {
|
||||
ChatKind::Message => ServerboundChat {
|
||||
message: content,
|
||||
timestamp: SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
|
@ -275,9 +275,9 @@ pub fn handle_send_chat_kind_event(
|
|||
last_seen_messages: LastSeenMessagesUpdate::default(),
|
||||
}
|
||||
.get(),
|
||||
ChatPacketKind::Command => {
|
||||
ChatKind::Command => {
|
||||
// TODO: chat signing
|
||||
ServerboundChatCommandPacket { command: content }.get()
|
||||
ServerboundChatCommand { command: content }.get()
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ use std::{
|
|||
|
||||
use azalea_core::position::ChunkPos;
|
||||
use azalea_protocol::packets::game::{
|
||||
clientbound_level_chunk_with_light_packet::ClientboundLevelChunkWithLightPacket,
|
||||
serverbound_chunk_batch_received_packet::ServerboundChunkBatchReceivedPacket,
|
||||
c_level_chunk_with_light::ClientboundLevelChunkWithLight,
|
||||
s_chunk_batch_received::ServerboundChunkBatchReceived,
|
||||
};
|
||||
use bevy_app::{App, Plugin, Update};
|
||||
use bevy_ecs::prelude::*;
|
||||
|
@ -51,7 +51,7 @@ impl Plugin for ChunkPlugin {
|
|||
#[derive(Event)]
|
||||
pub struct ReceiveChunkEvent {
|
||||
pub entity: Entity,
|
||||
pub packet: ClientboundLevelChunkWithLightPacket,
|
||||
pub packet: ClientboundLevelChunkWithLight,
|
||||
}
|
||||
|
||||
#[derive(Component, Clone, Debug)]
|
||||
|
@ -161,7 +161,7 @@ pub fn handle_chunk_batch_finished_event(
|
|||
let desired_chunks_per_tick = chunk_batch_info.desired_chunks_per_tick();
|
||||
send_packets.send(SendPacketEvent {
|
||||
entity: event.entity,
|
||||
packet: ServerboundChunkBatchReceivedPacket {
|
||||
packet: ServerboundChunkBatchReceived {
|
||||
desired_chunks_per_tick,
|
||||
}
|
||||
.get(),
|
||||
|
|
|
@ -17,22 +17,18 @@ use azalea_entity::{
|
|||
};
|
||||
use azalea_physics::PhysicsPlugin;
|
||||
use azalea_protocol::{
|
||||
common::ClientInformation,
|
||||
connect::{Connection, ConnectionError, Proxy},
|
||||
packets::{
|
||||
configuration::{
|
||||
serverbound_client_information_packet::ClientInformation,
|
||||
ClientboundConfigurationPacket, ServerboundConfigurationPacket,
|
||||
},
|
||||
config::{ClientboundConfigPacket, ServerboundConfigPacket},
|
||||
game::ServerboundGamePacket,
|
||||
handshaking::{
|
||||
client_intention_packet::ClientIntentionPacket, ClientboundHandshakePacket,
|
||||
handshake::{
|
||||
s_client_intention::ServerboundClientIntention, ClientboundHandshakePacket,
|
||||
ServerboundHandshakePacket,
|
||||
},
|
||||
login::{
|
||||
serverbound_hello_packet::ServerboundHelloPacket,
|
||||
serverbound_key_packet::ServerboundKeyPacket,
|
||||
serverbound_login_acknowledged_packet::ServerboundLoginAcknowledgedPacket,
|
||||
ClientboundLoginPacket,
|
||||
s_hello::ServerboundHello, s_key::ServerboundKey,
|
||||
s_login_acknowledged::ServerboundLoginAcknowledged, ClientboundLoginPacket,
|
||||
},
|
||||
ClientIntention, ConnectionProtocol, PROTOCOL_VERSION,
|
||||
},
|
||||
|
@ -347,14 +343,14 @@ impl Client {
|
|||
address: &ServerAddress,
|
||||
) -> Result<
|
||||
(
|
||||
Connection<ClientboundConfigurationPacket, ServerboundConfigurationPacket>,
|
||||
Connection<ClientboundConfigPacket, ServerboundConfigPacket>,
|
||||
GameProfile,
|
||||
),
|
||||
JoinError,
|
||||
> {
|
||||
// handshake
|
||||
conn.write(
|
||||
ClientIntentionPacket {
|
||||
ServerboundClientIntention {
|
||||
protocol_version: PROTOCOL_VERSION,
|
||||
hostname: address.host.clone(),
|
||||
port: address.port,
|
||||
|
@ -375,7 +371,7 @@ impl Client {
|
|||
|
||||
// login
|
||||
conn.write(
|
||||
ServerboundHelloPacket {
|
||||
ServerboundHello {
|
||||
name: account.username.clone(),
|
||||
// TODO: pretty sure this should generate an offline-mode uuid instead of just
|
||||
// Uuid::default()
|
||||
|
@ -443,7 +439,7 @@ impl Client {
|
|||
}
|
||||
|
||||
conn.write(
|
||||
ServerboundKeyPacket {
|
||||
ServerboundKey {
|
||||
key_bytes: e.encrypted_public_key,
|
||||
encrypted_challenge: e.encrypted_challenge,
|
||||
}
|
||||
|
@ -462,8 +458,7 @@ impl Client {
|
|||
"Got profile {:?}. handshake is finished and we're now switching to the configuration state",
|
||||
p.game_profile
|
||||
);
|
||||
conn.write(ServerboundLoginAcknowledgedPacket {}.get())
|
||||
.await?;
|
||||
conn.write(ServerboundLoginAcknowledged {}.get()).await?;
|
||||
break (conn.configuration(), p.game_profile);
|
||||
}
|
||||
ClientboundLoginPacket::LoginDisconnect(p) => {
|
||||
|
@ -605,7 +600,7 @@ impl Client {
|
|||
"Sending client information (already logged in): {:?}",
|
||||
client_information
|
||||
);
|
||||
self.write_packet(azalea_protocol::packets::game::serverbound_client_information_packet::ServerboundClientInformationPacket { information: client_information.clone() }.get())?;
|
||||
self.write_packet(azalea_protocol::packets::game::s_client_information::ServerboundClientInformation { information: client_information.clone() }.get())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
use azalea_buf::McBufWritable;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol::packets::configuration::{
|
||||
serverbound_client_information_packet::{
|
||||
ClientInformation, ServerboundClientInformationPacket,
|
||||
use azalea_protocol::{
|
||||
common::ClientInformation,
|
||||
packets::config::{
|
||||
s_client_information::ServerboundClientInformation,
|
||||
s_custom_payload::ServerboundCustomPayload,
|
||||
},
|
||||
serverbound_custom_payload_packet::ServerboundCustomPayloadPacket,
|
||||
};
|
||||
use bevy_app::prelude::*;
|
||||
use bevy_ecs::prelude::*;
|
||||
|
||||
use crate::{
|
||||
client::InConfigurationState, packet_handling::configuration::SendConfigurationPacketEvent,
|
||||
};
|
||||
use crate::{client::InConfigurationState, packet_handling::configuration::SendConfigurationEvent};
|
||||
|
||||
pub struct ConfigurationPlugin;
|
||||
impl Plugin for ConfigurationPlugin {
|
||||
|
@ -26,24 +25,24 @@ impl Plugin for ConfigurationPlugin {
|
|||
|
||||
fn handle_in_configuration_state(
|
||||
query: Query<(Entity, &ClientInformation), Added<InConfigurationState>>,
|
||||
mut send_packet_events: EventWriter<SendConfigurationPacketEvent>,
|
||||
mut send_packet_events: EventWriter<SendConfigurationEvent>,
|
||||
) {
|
||||
for (entity, client_information) in query.iter() {
|
||||
let mut brand_data = Vec::new();
|
||||
// they don't have to know :)
|
||||
"vanilla".write_into(&mut brand_data).unwrap();
|
||||
send_packet_events.send(SendConfigurationPacketEvent {
|
||||
send_packet_events.send(SendConfigurationEvent {
|
||||
entity,
|
||||
packet: ServerboundCustomPayloadPacket {
|
||||
packet: ServerboundCustomPayload {
|
||||
identifier: ResourceLocation::new("brand"),
|
||||
data: brand_data.into(),
|
||||
}
|
||||
.get(),
|
||||
});
|
||||
|
||||
send_packet_events.send(SendConfigurationPacketEvent {
|
||||
send_packet_events.send(SendConfigurationEvent {
|
||||
entity,
|
||||
packet: ServerboundClientInformationPacket {
|
||||
packet: ServerboundClientInformation {
|
||||
information: client_information.clone(),
|
||||
}
|
||||
.get(),
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::sync::Arc;
|
|||
use azalea_chat::FormattedText;
|
||||
use azalea_core::tick::GameTick;
|
||||
use azalea_protocol::packets::game::{
|
||||
clientbound_player_combat_kill_packet::ClientboundPlayerCombatKillPacket, ClientboundGamePacket,
|
||||
c_player_combat_kill::ClientboundPlayerCombatKill, ClientboundGamePacket,
|
||||
};
|
||||
use azalea_world::{InstanceName, MinecraftEntityId};
|
||||
use bevy_app::{App, Plugin, PreUpdate, Update};
|
||||
|
@ -21,7 +21,7 @@ use derive_more::{Deref, DerefMut};
|
|||
use tokio::sync::mpsc;
|
||||
|
||||
use crate::{
|
||||
chat::{ChatPacket, ChatReceivedEvent},
|
||||
chat::{Chat, ChatReceivedEvent},
|
||||
disconnect::DisconnectEvent,
|
||||
packet_handling::game::{
|
||||
AddPlayerEvent, DeathEvent, KeepAliveEvent, PacketEvent, RemovePlayerEvent,
|
||||
|
@ -62,7 +62,7 @@ pub enum Event {
|
|||
/// The client is now in the world. Fired when we receive a login packet.
|
||||
Login,
|
||||
/// A chat message was sent in the game chat.
|
||||
Chat(ChatPacket),
|
||||
Chat(Chat),
|
||||
/// Happens 20 times per second, but only when the world is loaded.
|
||||
Tick,
|
||||
/// We received a packet from the server.
|
||||
|
@ -93,7 +93,7 @@ pub enum Event {
|
|||
/// name, or latency changed).
|
||||
UpdatePlayer(PlayerInfo),
|
||||
/// The client player died in-game.
|
||||
Death(Option<Arc<ClientboundPlayerCombatKillPacket>>),
|
||||
Death(Option<Arc<ClientboundPlayerCombatKill>>),
|
||||
/// A `KeepAlive` packet was sent by the server.
|
||||
KeepAlive(u64),
|
||||
/// The client disconnected from the server.
|
||||
|
|
|
@ -13,9 +13,9 @@ use azalea_entity::{
|
|||
use azalea_inventory::{ItemSlot, ItemSlotData};
|
||||
use azalea_physics::clip::{BlockShapeType, ClipContext, FluidPickType};
|
||||
use azalea_protocol::packets::game::{
|
||||
serverbound_interact_packet::InteractionHand,
|
||||
serverbound_swing_packet::ServerboundSwingPacket,
|
||||
serverbound_use_item_on_packet::{BlockHit, ServerboundUseItemOnPacket},
|
||||
s_interact::InteractionHand,
|
||||
s_swing::ServerboundSwing,
|
||||
s_use_item_on::{BlockHit, ServerboundUseItemOn},
|
||||
};
|
||||
use azalea_registry::DataComponentKind;
|
||||
use azalea_world::{Instance, InstanceContainer, InstanceName};
|
||||
|
@ -150,7 +150,7 @@ pub fn handle_block_interact_event(
|
|||
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity,
|
||||
packet: ServerboundUseItemOnPacket {
|
||||
packet: ServerboundUseItemOn {
|
||||
hand: InteractionHand::MainHand,
|
||||
block_hit,
|
||||
sequence: sequence_number.0,
|
||||
|
@ -304,7 +304,7 @@ pub fn handle_swing_arm_event(
|
|||
for event in events.read() {
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: event.entity,
|
||||
packet: ServerboundSwingPacket {
|
||||
packet: ServerboundSwing {
|
||||
hand: InteractionHand::MainHand,
|
||||
}
|
||||
.get(),
|
||||
|
|
|
@ -10,9 +10,8 @@ use azalea_inventory::{
|
|||
},
|
||||
};
|
||||
use azalea_protocol::packets::game::{
|
||||
serverbound_container_click_packet::ServerboundContainerClickPacket,
|
||||
serverbound_container_close_packet::ServerboundContainerClosePacket,
|
||||
serverbound_set_carried_item_packet::ServerboundSetCarriedItemPacket,
|
||||
s_container_click::ServerboundContainerClick, s_container_close::ServerboundContainerClose,
|
||||
s_set_carried_item::ServerboundSetCarriedItem,
|
||||
};
|
||||
use azalea_registry::MenuKind;
|
||||
use bevy_app::{App, Plugin, Update};
|
||||
|
@ -630,7 +629,7 @@ fn handle_container_close_event(
|
|||
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity,
|
||||
packet: ServerboundContainerClosePacket {
|
||||
packet: ServerboundContainerClose {
|
||||
container_id: inventory.id,
|
||||
}
|
||||
.get(),
|
||||
|
@ -698,7 +697,7 @@ pub fn handle_container_click_event(
|
|||
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity,
|
||||
packet: ServerboundContainerClickPacket {
|
||||
packet: ServerboundContainerClick {
|
||||
container_id: event.window_id,
|
||||
state_id: inventory.state_id,
|
||||
slot_num: event.operation.slot_num().map(|n| n as i16).unwrap_or(-999),
|
||||
|
@ -766,7 +765,7 @@ fn handle_set_selected_hotbar_slot_event(
|
|||
inventory.selected_hotbar_slot = event.slot;
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: event.entity,
|
||||
packet: ServerboundSetCarriedItemPacket {
|
||||
packet: ServerboundSetCarriedItem {
|
||||
slot: event.slot as u16,
|
||||
}
|
||||
.get(),
|
||||
|
|
|
@ -30,7 +30,7 @@ pub mod respawn;
|
|||
pub mod task_pool;
|
||||
|
||||
pub use account::{Account, AccountOpts};
|
||||
pub use azalea_protocol::packets::configuration::serverbound_client_information_packet::ClientInformation;
|
||||
pub use azalea_protocol::common::ClientInformation;
|
||||
pub use client::{
|
||||
start_ecs_runner, Client, DefaultPlugins, JoinError, JoinedClientBundle, StartClientOpts,
|
||||
TickBroadcast,
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::{collections::HashMap, io, sync::Arc};
|
|||
use azalea_auth::game_profile::GameProfile;
|
||||
use azalea_core::game_type::GameMode;
|
||||
use azalea_entity::Dead;
|
||||
use azalea_protocol::packets::game::clientbound_player_abilities_packet::ClientboundPlayerAbilitiesPacket;
|
||||
use azalea_protocol::packets::game::c_player_abilities::ClientboundPlayerAbilities;
|
||||
use azalea_world::{Instance, PartialInstance};
|
||||
use bevy_ecs::{component::Component, prelude::*};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
|
@ -62,8 +62,8 @@ pub struct PlayerAbilities {
|
|||
/// Used for the fov
|
||||
pub walking_speed: f32,
|
||||
}
|
||||
impl From<&ClientboundPlayerAbilitiesPacket> for PlayerAbilities {
|
||||
fn from(packet: &ClientboundPlayerAbilitiesPacket) -> Self {
|
||||
impl From<&ClientboundPlayerAbilities> for PlayerAbilities {
|
||||
fn from(packet: &ClientboundPlayerAbilities) -> Self {
|
||||
Self {
|
||||
invulnerable: packet.flags.invulnerable,
|
||||
flying: packet.flags.flying,
|
||||
|
|
|
@ -3,9 +3,7 @@ use azalea_core::{direction::Direction, game_type::GameMode, position::BlockPos,
|
|||
use azalea_entity::{mining::get_mine_progress, FluidOnEyes, Physics};
|
||||
use azalea_inventory::ItemSlot;
|
||||
use azalea_physics::PhysicsSet;
|
||||
use azalea_protocol::packets::game::serverbound_player_action_packet::{
|
||||
self, ServerboundPlayerActionPacket,
|
||||
};
|
||||
use azalea_protocol::packets::game::s_player_action::{self, ServerboundPlayerAction};
|
||||
use azalea_world::{InstanceContainer, InstanceName};
|
||||
use bevy_app::{App, Plugin, Update};
|
||||
use bevy_ecs::prelude::*;
|
||||
|
@ -255,8 +253,8 @@ fn handle_start_mining_block_with_direction_event(
|
|||
// send a packet to stop mining since we just changed target
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: event.entity,
|
||||
packet: ServerboundPlayerActionPacket {
|
||||
action: serverbound_player_action_packet::Action::AbortDestroyBlock,
|
||||
packet: ServerboundPlayerAction {
|
||||
action: s_player_action::Action::AbortDestroyBlock,
|
||||
pos: current_mining_pos
|
||||
.expect("IsMining is true so MineBlockPos must be present"),
|
||||
direction: event.direction,
|
||||
|
@ -328,8 +326,8 @@ fn handle_start_mining_block_with_direction_event(
|
|||
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: event.entity,
|
||||
packet: ServerboundPlayerActionPacket {
|
||||
action: serverbound_player_action_packet::Action::StartDestroyBlock,
|
||||
packet: ServerboundPlayerAction {
|
||||
action: s_player_action::Action::StartDestroyBlock,
|
||||
pos: event.position,
|
||||
direction: event.direction,
|
||||
sequence: **sequence_number,
|
||||
|
@ -498,8 +496,8 @@ pub fn handle_stop_mining_block_event(
|
|||
mine_block_pos.expect("IsMining is true so MineBlockPos must be present");
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: event.entity,
|
||||
packet: ServerboundPlayerActionPacket {
|
||||
action: serverbound_player_action_packet::Action::AbortDestroyBlock,
|
||||
packet: ServerboundPlayerAction {
|
||||
action: s_player_action::Action::AbortDestroyBlock,
|
||||
pos: mine_block_pos,
|
||||
direction: Direction::Down,
|
||||
sequence: 0,
|
||||
|
@ -572,8 +570,8 @@ pub fn continue_mining_block(
|
|||
*sequence_number += 1;
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity,
|
||||
packet: ServerboundPlayerActionPacket {
|
||||
action: serverbound_player_action_packet::Action::StartDestroyBlock,
|
||||
packet: ServerboundPlayerAction {
|
||||
action: s_player_action::Action::StartDestroyBlock,
|
||||
pos: mining.pos,
|
||||
direction: mining.dir,
|
||||
sequence: **sequence_number,
|
||||
|
@ -618,8 +616,8 @@ pub fn continue_mining_block(
|
|||
});
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity,
|
||||
packet: ServerboundPlayerActionPacket {
|
||||
action: serverbound_player_action_packet::Action::StopDestroyBlock,
|
||||
packet: ServerboundPlayerAction {
|
||||
action: s_player_action::Action::StopDestroyBlock,
|
||||
pos: mining.pos,
|
||||
direction: mining.dir,
|
||||
sequence: **sequence_number,
|
||||
|
|
|
@ -5,12 +5,12 @@ 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::s_player_command::ServerboundPlayerCommand;
|
||||
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,
|
||||
s_move_player_pos::ServerboundMovePlayerPos,
|
||||
s_move_player_pos_rot::ServerboundMovePlayerPosRot,
|
||||
s_move_player_rot::ServerboundMovePlayerRot,
|
||||
s_move_player_status_only::ServerboundMovePlayerStatusOnly,
|
||||
};
|
||||
use azalea_world::{MinecraftEntityId, MoveEntityError};
|
||||
use bevy_app::{App, Plugin, Update};
|
||||
|
@ -188,7 +188,7 @@ pub fn send_position(
|
|||
// }
|
||||
let packet = if sending_position && sending_direction {
|
||||
Some(
|
||||
ServerboundMovePlayerPosRotPacket {
|
||||
ServerboundMovePlayerPosRot {
|
||||
x: position.x,
|
||||
y: position.y,
|
||||
z: position.z,
|
||||
|
@ -200,7 +200,7 @@ pub fn send_position(
|
|||
)
|
||||
} else if sending_position {
|
||||
Some(
|
||||
ServerboundMovePlayerPosPacket {
|
||||
ServerboundMovePlayerPos {
|
||||
x: position.x,
|
||||
y: position.y,
|
||||
z: position.z,
|
||||
|
@ -210,7 +210,7 @@ pub fn send_position(
|
|||
)
|
||||
} else if sending_direction {
|
||||
Some(
|
||||
ServerboundMovePlayerRotPacket {
|
||||
ServerboundMovePlayerRot {
|
||||
x_rot: direction.x_rot,
|
||||
y_rot: direction.y_rot,
|
||||
on_ground: physics.on_ground,
|
||||
|
@ -219,7 +219,7 @@ pub fn send_position(
|
|||
)
|
||||
} else if physics.last_on_ground != physics.on_ground {
|
||||
Some(
|
||||
ServerboundMovePlayerStatusOnlyPacket {
|
||||
ServerboundMovePlayerStatusOnly {
|
||||
on_ground: physics.on_ground,
|
||||
}
|
||||
.get(),
|
||||
|
@ -257,13 +257,13 @@ 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 {
|
||||
entity,
|
||||
packet: ServerboundPlayerCommandPacket {
|
||||
packet: ServerboundPlayerCommand {
|
||||
id: **minecraft_entity_id,
|
||||
action: sprinting_action,
|
||||
data: 0,
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
use std::io::Cursor;
|
||||
|
||||
use azalea_entity::indexing::EntityIdIndex;
|
||||
use azalea_protocol::packets::configuration::serverbound_finish_configuration_packet::ServerboundFinishConfigurationPacket;
|
||||
use azalea_protocol::packets::configuration::serverbound_keep_alive_packet::ServerboundKeepAlivePacket;
|
||||
use azalea_protocol::packets::configuration::serverbound_pong_packet::ServerboundPongPacket;
|
||||
use azalea_protocol::packets::configuration::serverbound_resource_pack_packet::ServerboundResourcePackPacket;
|
||||
use azalea_protocol::packets::configuration::serverbound_select_known_packs_packet::ServerboundSelectKnownPacksPacket;
|
||||
use azalea_protocol::packets::configuration::{
|
||||
ClientboundConfigurationPacket, ServerboundConfigurationPacket,
|
||||
};
|
||||
use azalea_protocol::packets::config::s_finish_configuration::ServerboundFinishConfiguration;
|
||||
use azalea_protocol::packets::config::s_keep_alive::ServerboundKeepAlive;
|
||||
use azalea_protocol::packets::config::s_select_known_packs::ServerboundSelectKnownPacks;
|
||||
use azalea_protocol::packets::config::{self, ClientboundConfigPacket, ServerboundConfigPacket};
|
||||
use azalea_protocol::packets::ConnectionProtocol;
|
||||
use azalea_protocol::read::deserialize_packet;
|
||||
use bevy_ecs::prelude::*;
|
||||
|
@ -23,16 +19,16 @@ use crate::raw_connection::RawConnection;
|
|||
use crate::InstanceHolder;
|
||||
|
||||
#[derive(Event, Debug, Clone)]
|
||||
pub struct ConfigurationPacketEvent {
|
||||
pub struct ConfigurationEvent {
|
||||
/// The client entity that received the packet.
|
||||
pub entity: Entity,
|
||||
/// The packet that was actually received.
|
||||
pub packet: ClientboundConfigurationPacket,
|
||||
pub packet: ClientboundConfigPacket,
|
||||
}
|
||||
|
||||
pub fn send_packet_events(
|
||||
query: Query<(Entity, &RawConnection), With<InConfigurationState>>,
|
||||
mut packet_events: ResMut<Events<ConfigurationPacketEvent>>,
|
||||
mut packet_events: ResMut<Events<ConfigurationEvent>>,
|
||||
) {
|
||||
// we manually clear and send the events at the beginning of each update
|
||||
// since otherwise it'd cause issues with events in process_packet_events
|
||||
|
@ -43,9 +39,9 @@ pub fn send_packet_events(
|
|||
let mut packets = packets_lock.lock();
|
||||
if !packets.is_empty() {
|
||||
for raw_packet in packets.iter() {
|
||||
let packet = match deserialize_packet::<ClientboundConfigurationPacket>(
|
||||
&mut Cursor::new(raw_packet),
|
||||
) {
|
||||
let packet = match deserialize_packet::<ClientboundConfigPacket>(&mut Cursor::new(
|
||||
raw_packet,
|
||||
)) {
|
||||
Ok(packet) => packet,
|
||||
Err(err) => {
|
||||
error!("failed to read packet: {:?}", err);
|
||||
|
@ -53,7 +49,7 @@ pub fn send_packet_events(
|
|||
continue;
|
||||
}
|
||||
};
|
||||
packet_events.send(ConfigurationPacketEvent {
|
||||
packet_events.send(ConfigurationEvent {
|
||||
entity: player_entity,
|
||||
packet,
|
||||
});
|
||||
|
@ -66,10 +62,9 @@ pub fn send_packet_events(
|
|||
|
||||
pub fn process_packet_events(ecs: &mut World) {
|
||||
let mut events_owned = Vec::new();
|
||||
let mut system_state: SystemState<EventReader<ConfigurationPacketEvent>> =
|
||||
SystemState::new(ecs);
|
||||
let mut system_state: SystemState<EventReader<ConfigurationEvent>> = SystemState::new(ecs);
|
||||
let mut events = system_state.get_mut(ecs);
|
||||
for ConfigurationPacketEvent {
|
||||
for ConfigurationEvent {
|
||||
entity: player_entity,
|
||||
packet,
|
||||
} in events.read()
|
||||
|
@ -79,7 +74,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
}
|
||||
for (player_entity, packet) in events_owned {
|
||||
match packet {
|
||||
ClientboundConfigurationPacket::RegistryData(p) => {
|
||||
ClientboundConfigPacket::RegistryData(p) => {
|
||||
let mut system_state: SystemState<Query<&mut InstanceHolder>> =
|
||||
SystemState::new(ecs);
|
||||
let mut query = system_state.get_mut(ecs);
|
||||
|
@ -90,10 +85,10 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
instance.registries.append(p.registry_id, p.entries);
|
||||
}
|
||||
|
||||
ClientboundConfigurationPacket::CustomPayload(p) => {
|
||||
ClientboundConfigPacket::CustomPayload(p) => {
|
||||
debug!("Got custom payload packet {p:?}");
|
||||
}
|
||||
ClientboundConfigurationPacket::Disconnect(p) => {
|
||||
ClientboundConfigPacket::Disconnect(p) => {
|
||||
warn!("Got disconnect packet {p:?}");
|
||||
let mut system_state: SystemState<EventWriter<DisconnectEvent>> =
|
||||
SystemState::new(ecs);
|
||||
|
@ -103,7 +98,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
reason: Some(p.reason.clone()),
|
||||
});
|
||||
}
|
||||
ClientboundConfigurationPacket::FinishConfiguration(p) => {
|
||||
ClientboundConfigPacket::FinishConfiguration(p) => {
|
||||
debug!("got FinishConfiguration packet: {p:?}");
|
||||
|
||||
let mut system_state: SystemState<Query<&mut RawConnection>> =
|
||||
|
@ -112,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(ServerboundFinishConfigurationPacket {}.get())
|
||||
.write_packet(ServerboundFinishConfiguration {}.get())
|
||||
.expect(
|
||||
"we should be in the right state and encoding this packet shouldn't fail",
|
||||
);
|
||||
|
@ -140,7 +135,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
_local_entity: azalea_entity::LocalEntity,
|
||||
});
|
||||
}
|
||||
ClientboundConfigurationPacket::KeepAlive(p) => {
|
||||
ClientboundConfigPacket::KeepAlive(p) => {
|
||||
debug!("Got keep alive packet (in configuration) {p:?} for {player_entity:?}");
|
||||
|
||||
let mut system_state: SystemState<(
|
||||
|
@ -155,10 +150,10 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
id: p.id,
|
||||
});
|
||||
raw_connection
|
||||
.write_packet(ServerboundKeepAlivePacket { id: p.id }.get())
|
||||
.write_packet(ServerboundKeepAlive { id: p.id }.get())
|
||||
.unwrap();
|
||||
}
|
||||
ClientboundConfigurationPacket::Ping(p) => {
|
||||
ClientboundConfigPacket::Ping(p) => {
|
||||
debug!("Got ping packet {p:?}");
|
||||
|
||||
let mut system_state: SystemState<Query<&RawConnection>> = SystemState::new(ecs);
|
||||
|
@ -166,10 +161,10 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
let raw_connection = query.get_mut(player_entity).unwrap();
|
||||
|
||||
raw_connection
|
||||
.write_packet(ServerboundPongPacket { id: p.id }.get())
|
||||
.write_packet(config::s_pong::ServerboundPong { id: p.id }.get())
|
||||
.unwrap();
|
||||
}
|
||||
ClientboundConfigurationPacket::ResourcePackPush(p) => {
|
||||
ClientboundConfigPacket::ResourcePackPush(p) => {
|
||||
debug!("Got resource pack packet {p:?}");
|
||||
|
||||
let mut system_state: SystemState<Query<&RawConnection>> = SystemState::new(ecs);
|
||||
|
@ -177,35 +172,38 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
let raw_connection = query.get_mut(player_entity).unwrap();
|
||||
|
||||
// always accept resource pack
|
||||
raw_connection.write_packet(
|
||||
ServerboundResourcePackPacket {
|
||||
id: p.id,
|
||||
action: azalea_protocol::packets::configuration::serverbound_resource_pack_packet::Action::Accepted
|
||||
}.get()
|
||||
).unwrap();
|
||||
raw_connection
|
||||
.write_packet(
|
||||
config::s_resource_pack::ServerboundResourcePack {
|
||||
id: p.id,
|
||||
action: config::s_resource_pack::Action::Accepted,
|
||||
}
|
||||
.get(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
ClientboundConfigurationPacket::ResourcePackPop(_) => {
|
||||
ClientboundConfigPacket::ResourcePackPop(_) => {
|
||||
// we can ignore this
|
||||
}
|
||||
ClientboundConfigurationPacket::UpdateEnabledFeatures(p) => {
|
||||
ClientboundConfigPacket::UpdateEnabledFeatures(p) => {
|
||||
debug!("Got update enabled features packet {p:?}");
|
||||
}
|
||||
ClientboundConfigurationPacket::UpdateTags(_p) => {
|
||||
ClientboundConfigPacket::UpdateTags(_p) => {
|
||||
debug!("Got update tags packet");
|
||||
}
|
||||
ClientboundConfigurationPacket::CookieRequest(p) => {
|
||||
ClientboundConfigPacket::CookieRequest(p) => {
|
||||
debug!("Got cookie request packet {p:?}");
|
||||
}
|
||||
ClientboundConfigurationPacket::ResetChat(p) => {
|
||||
ClientboundConfigPacket::ResetChat(p) => {
|
||||
debug!("Got reset chat packet {p:?}");
|
||||
}
|
||||
ClientboundConfigurationPacket::StoreCookie(p) => {
|
||||
ClientboundConfigPacket::StoreCookie(p) => {
|
||||
debug!("Got store cookie packet {p:?}");
|
||||
}
|
||||
ClientboundConfigurationPacket::Transfer(p) => {
|
||||
ClientboundConfigPacket::Transfer(p) => {
|
||||
debug!("Got transfer packet {p:?}");
|
||||
}
|
||||
ClientboundConfigurationPacket::SelectKnownPacks(p) => {
|
||||
ClientboundConfigPacket::SelectKnownPacks(p) => {
|
||||
debug!("Got select known packs packet {p:?}");
|
||||
|
||||
let mut system_state: SystemState<Query<&RawConnection>> = SystemState::new(ecs);
|
||||
|
@ -215,7 +213,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
// resource pack management isn't implemented
|
||||
raw_connection
|
||||
.write_packet(
|
||||
ServerboundSelectKnownPacksPacket {
|
||||
ServerboundSelectKnownPacks {
|
||||
known_packs: vec![],
|
||||
}
|
||||
.get(),
|
||||
|
@ -229,13 +227,13 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
/// An event for sending a packet to the server while we're in the
|
||||
/// `configuration` state.
|
||||
#[derive(Event)]
|
||||
pub struct SendConfigurationPacketEvent {
|
||||
pub struct SendConfigurationEvent {
|
||||
pub entity: Entity,
|
||||
pub packet: ServerboundConfigurationPacket,
|
||||
pub packet: ServerboundConfigPacket,
|
||||
}
|
||||
|
||||
pub fn handle_send_packet_event(
|
||||
mut send_packet_events: EventReader<SendConfigurationPacketEvent>,
|
||||
mut send_packet_events: EventReader<SendConfigurationEvent>,
|
||||
mut query: Query<&mut RawConnection>,
|
||||
) {
|
||||
for event in send_packet_events.read() {
|
||||
|
|
|
@ -18,13 +18,11 @@ use azalea_entity::{
|
|||
};
|
||||
use azalea_protocol::{
|
||||
packets::game::{
|
||||
clientbound_player_combat_kill_packet::ClientboundPlayerCombatKillPacket,
|
||||
serverbound_accept_teleportation_packet::ServerboundAcceptTeleportationPacket,
|
||||
serverbound_configuration_acknowledged_packet::ServerboundConfigurationAcknowledgedPacket,
|
||||
serverbound_keep_alive_packet::ServerboundKeepAlivePacket,
|
||||
serverbound_move_player_pos_rot_packet::ServerboundMovePlayerPosRotPacket,
|
||||
serverbound_pong_packet::ServerboundPongPacket, ClientboundGamePacket,
|
||||
ServerboundGamePacket,
|
||||
c_player_combat_kill::ClientboundPlayerCombatKill,
|
||||
s_accept_teleportation::ServerboundAcceptTeleportation,
|
||||
s_configuration_acknowledged::ServerboundConfigurationAcknowledged,
|
||||
s_keep_alive::ServerboundKeepAlive, s_move_player_pos_rot::ServerboundMovePlayerPosRot,
|
||||
s_pong::ServerboundPong, ClientboundGamePacket, ServerboundGamePacket,
|
||||
},
|
||||
read::deserialize_packet,
|
||||
};
|
||||
|
@ -35,7 +33,7 @@ use tracing::{debug, error, trace, warn};
|
|||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
chat::{ChatPacket, ChatReceivedEvent},
|
||||
chat::{Chat, ChatReceivedEvent},
|
||||
chunks,
|
||||
disconnect::DisconnectEvent,
|
||||
inventory::{
|
||||
|
@ -103,12 +101,12 @@ pub struct UpdatePlayerEvent {
|
|||
}
|
||||
|
||||
/// Event for when an entity dies. dies. If it's a local player and there's a
|
||||
/// reason in the death screen, the [`ClientboundPlayerCombatKillPacket`] will
|
||||
/// reason in the death screen, the [`ClientboundPlayerCombatKill`] will
|
||||
/// be included.
|
||||
#[derive(Event, Debug, Clone)]
|
||||
pub struct DeathEvent {
|
||||
pub entity: Entity,
|
||||
pub packet: Option<ClientboundPlayerCombatKillPacket>,
|
||||
pub packet: Option<ClientboundPlayerCombatKill>,
|
||||
}
|
||||
|
||||
/// A KeepAlive packet is sent from the server to verify that the client is
|
||||
|
@ -342,7 +340,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
);
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: player_entity,
|
||||
packet: azalea_protocol::packets::game::serverbound_client_information_packet::ServerboundClientInformationPacket { information: client_information.clone() }.get(),
|
||||
packet: azalea_protocol::packets::game::s_client_information::ServerboundClientInformation { information: client_information.clone() }.get(),
|
||||
});
|
||||
|
||||
system_state.apply(ecs);
|
||||
|
@ -495,11 +493,11 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: player_entity,
|
||||
packet: ServerboundAcceptTeleportationPacket { id: p.id }.get(),
|
||||
packet: ServerboundAcceptTeleportation { id: p.id }.get(),
|
||||
});
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: player_entity,
|
||||
packet: ServerboundMovePlayerPosRotPacket {
|
||||
packet: ServerboundMovePlayerPosRot {
|
||||
x: new_pos.x,
|
||||
y: new_pos.y,
|
||||
z: new_pos.z,
|
||||
|
@ -985,7 +983,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
});
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: player_entity,
|
||||
packet: ServerboundKeepAlivePacket { id: p.id }.get(),
|
||||
packet: ServerboundKeepAlive { id: p.id }.get(),
|
||||
});
|
||||
}
|
||||
ClientboundGamePacket::RemoveEntities(p) => {
|
||||
|
@ -1032,7 +1030,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
|
||||
chat_events.send(ChatReceivedEvent {
|
||||
entity: player_entity,
|
||||
packet: ChatPacket::Player(Arc::new(p.clone())),
|
||||
packet: Chat::Player(Arc::new(p.clone())),
|
||||
});
|
||||
}
|
||||
ClientboundGamePacket::SystemChat(p) => {
|
||||
|
@ -1044,7 +1042,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
|
||||
chat_events.send(ChatReceivedEvent {
|
||||
entity: player_entity,
|
||||
packet: ChatPacket::System(Arc::new(p.clone())),
|
||||
packet: Chat::System(Arc::new(p.clone())),
|
||||
});
|
||||
}
|
||||
ClientboundGamePacket::DisguisedChat(p) => {
|
||||
|
@ -1056,7 +1054,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
|
||||
chat_events.send(ChatReceivedEvent {
|
||||
entity: player_entity,
|
||||
packet: ChatPacket::Disguised(Arc::new(p.clone())),
|
||||
packet: Chat::Disguised(Arc::new(p.clone())),
|
||||
});
|
||||
}
|
||||
ClientboundGamePacket::Sound(_p) => {
|
||||
|
@ -1096,7 +1094,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
}
|
||||
}
|
||||
ClientboundGamePacket::GameEvent(p) => {
|
||||
use azalea_protocol::packets::game::clientbound_game_event_packet::EventType;
|
||||
use azalea_protocol::packets::game::c_game_event::EventType;
|
||||
|
||||
debug!("Got game event packet {p:?}");
|
||||
|
||||
|
@ -1281,7 +1279,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
|
||||
send_packet_events.send(SendPacketEvent {
|
||||
entity: player_entity,
|
||||
packet: ServerboundPongPacket { id: p.id }.get(),
|
||||
packet: ServerboundPong { id: p.id }.get(),
|
||||
});
|
||||
}
|
||||
ClientboundGamePacket::PlaceGhostRecipe(_) => {}
|
||||
|
@ -1425,7 +1423,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
|
||||
packet_events.send(SendPacketEvent {
|
||||
entity: player_entity,
|
||||
packet: ServerboundConfigurationAcknowledgedPacket {}.get(),
|
||||
packet: ServerboundConfigurationAcknowledged {}.get(),
|
||||
});
|
||||
|
||||
commands
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
use std::{collections::HashSet, sync::Arc};
|
||||
|
||||
use azalea_protocol::packets::login::{
|
||||
serverbound_custom_query_answer_packet::ServerboundCustomQueryAnswerPacket,
|
||||
ClientboundLoginPacket, ServerboundLoginPacket,
|
||||
s_custom_query_answer::ServerboundCustomQueryAnswer, ClientboundLoginPacket,
|
||||
ServerboundLoginPacket,
|
||||
};
|
||||
use bevy_ecs::{prelude::*, system::SystemState};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
|
@ -88,7 +88,7 @@ pub fn process_packet_events(ecs: &mut World) {
|
|||
|
||||
send_packet_events.send(SendLoginPacketEvent {
|
||||
entity: player_entity,
|
||||
packet: ServerboundCustomQueryAnswerPacket {
|
||||
packet: ServerboundCustomQueryAnswer {
|
||||
transaction_id: p.transaction_id,
|
||||
data: None,
|
||||
}
|
||||
|
|
|
@ -61,9 +61,9 @@ impl Plugin for PacketHandlerPlugin {
|
|||
)
|
||||
// we do this instead of add_event so we can handle the events ourselves
|
||||
.init_resource::<Events<game::PacketEvent>>()
|
||||
.init_resource::<Events<configuration::ConfigurationPacketEvent>>()
|
||||
.init_resource::<Events<configuration::ConfigurationEvent>>()
|
||||
.add_event::<game::SendPacketEvent>()
|
||||
.add_event::<configuration::SendConfigurationPacketEvent>()
|
||||
.add_event::<configuration::SendConfigurationEvent>()
|
||||
.add_event::<AddPlayerEvent>()
|
||||
.add_event::<RemovePlayerEvent>()
|
||||
.add_event::<UpdatePlayerEvent>()
|
||||
|
|
|
@ -5,14 +5,13 @@ use std::io;
|
|||
use azalea_protocol::{
|
||||
connect::{Connection, ConnectionError, Proxy},
|
||||
packets::{
|
||||
handshaking::{
|
||||
client_intention_packet::ClientIntentionPacket, ClientboundHandshakePacket,
|
||||
handshake::{
|
||||
s_client_intention::ServerboundClientIntention, ClientboundHandshakePacket,
|
||||
ServerboundHandshakePacket,
|
||||
},
|
||||
status::{
|
||||
clientbound_status_response_packet::ClientboundStatusResponsePacket,
|
||||
serverbound_status_request_packet::ServerboundStatusRequestPacket,
|
||||
ClientboundStatusPacket,
|
||||
c_status_response::ClientboundStatusResponse,
|
||||
s_status_request::ServerboundStatusRequest, ClientboundStatusPacket,
|
||||
},
|
||||
ClientIntention, PROTOCOL_VERSION,
|
||||
},
|
||||
|
@ -49,7 +48,7 @@ pub enum PingError {
|
|||
/// ```
|
||||
pub async fn ping_server(
|
||||
address: impl TryInto<ServerAddress>,
|
||||
) -> Result<ClientboundStatusResponsePacket, PingError> {
|
||||
) -> Result<ClientboundStatusResponse, PingError> {
|
||||
let address: ServerAddress = address.try_into().map_err(|_| PingError::InvalidAddress)?;
|
||||
let resolved_address = resolver::resolve_address(&address).await?;
|
||||
let conn = Connection::new(&resolved_address).await?;
|
||||
|
@ -60,7 +59,7 @@ pub async fn ping_server(
|
|||
pub async fn ping_server_with_proxy(
|
||||
address: impl TryInto<ServerAddress>,
|
||||
proxy: Proxy,
|
||||
) -> Result<ClientboundStatusResponsePacket, PingError> {
|
||||
) -> Result<ClientboundStatusResponse, PingError> {
|
||||
let address: ServerAddress = address.try_into().map_err(|_| PingError::InvalidAddress)?;
|
||||
let resolved_address = resolver::resolve_address(&address).await?;
|
||||
let conn = Connection::new_with_proxy(&resolved_address, proxy).await?;
|
||||
|
@ -73,10 +72,10 @@ pub async fn ping_server_with_proxy(
|
|||
pub async fn ping_server_with_connection(
|
||||
address: ServerAddress,
|
||||
mut conn: Connection<ClientboundHandshakePacket, ServerboundHandshakePacket>,
|
||||
) -> Result<ClientboundStatusResponsePacket, PingError> {
|
||||
) -> Result<ClientboundStatusResponse, PingError> {
|
||||
// send the client intention packet and switch to the status state
|
||||
conn.write(
|
||||
ClientIntentionPacket {
|
||||
ServerboundClientIntention {
|
||||
protocol_version: PROTOCOL_VERSION,
|
||||
hostname: address.host.clone(),
|
||||
port: address.port,
|
||||
|
@ -88,7 +87,7 @@ pub async fn ping_server_with_connection(
|
|||
let mut conn = conn.status();
|
||||
|
||||
// send the empty status request packet
|
||||
conn.write(ServerboundStatusRequestPacket {}.get()).await?;
|
||||
conn.write(ServerboundStatusRequest {}.get()).await?;
|
||||
|
||||
let packet = conn.read().await?;
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
use azalea_protocol::packets::game::serverbound_client_command_packet::{
|
||||
self, ServerboundClientCommandPacket,
|
||||
};
|
||||
use azalea_protocol::packets::game::s_client_command::{self, ServerboundClientCommand};
|
||||
use bevy_app::{App, Plugin, Update};
|
||||
use bevy_ecs::prelude::*;
|
||||
|
||||
|
@ -28,8 +26,8 @@ pub fn perform_respawn(
|
|||
for event in events.read() {
|
||||
send_packets.send(SendPacketEvent {
|
||||
entity: event.entity,
|
||||
packet: ServerboundClientCommandPacket {
|
||||
action: serverbound_client_command_packet::Action::PerformRespawn,
|
||||
packet: ServerboundClientCommand {
|
||||
action: s_client_command::Action::PerformRespawn,
|
||||
}
|
||||
.get(),
|
||||
});
|
||||
|
|
|
@ -41,68 +41,68 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke
|
|||
}
|
||||
|
||||
#[proc_macro_derive(ServerboundGamePacket, attributes(var))]
|
||||
pub fn derive_serverbound_game_packet(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_s_game_packet(input: TokenStream) -> TokenStream {
|
||||
as_packet_derive(input, quote! {crate::packets::game::ServerboundGamePacket})
|
||||
}
|
||||
#[proc_macro_derive(ServerboundHandshakePacket, attributes(var))]
|
||||
pub fn derive_serverbound_handshake_packet(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_s_handshake_packet(input: TokenStream) -> TokenStream {
|
||||
as_packet_derive(
|
||||
input,
|
||||
quote! {crate::packets::handshaking::ServerboundHandshakePacket},
|
||||
quote! {crate::packets::handshake::ServerboundHandshakePacket},
|
||||
)
|
||||
}
|
||||
#[proc_macro_derive(ServerboundLoginPacket, attributes(var))]
|
||||
pub fn derive_serverbound_login_packet(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_s_login_packet(input: TokenStream) -> TokenStream {
|
||||
as_packet_derive(
|
||||
input,
|
||||
quote! {crate::packets::login::ServerboundLoginPacket},
|
||||
)
|
||||
}
|
||||
#[proc_macro_derive(ServerboundStatusPacket, attributes(var))]
|
||||
pub fn derive_serverbound_status_packet(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_s_status_packet(input: TokenStream) -> TokenStream {
|
||||
as_packet_derive(
|
||||
input,
|
||||
quote! {crate::packets::status::ServerboundStatusPacket},
|
||||
)
|
||||
}
|
||||
#[proc_macro_derive(ServerboundConfigurationPacket, attributes(var))]
|
||||
pub fn derive_serverbound_configuration_packet(input: TokenStream) -> TokenStream {
|
||||
#[proc_macro_derive(ServerboundConfigPacket, attributes(var))]
|
||||
pub fn derive_s_config_packet(input: TokenStream) -> TokenStream {
|
||||
as_packet_derive(
|
||||
input,
|
||||
quote! {crate::packets::configuration::ServerboundConfigurationPacket},
|
||||
quote! {crate::packets::config::ServerboundConfigPacket},
|
||||
)
|
||||
}
|
||||
|
||||
#[proc_macro_derive(ClientboundGamePacket, attributes(var))]
|
||||
pub fn derive_clientbound_game_packet(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_c_game_packet(input: TokenStream) -> TokenStream {
|
||||
as_packet_derive(input, quote! {crate::packets::game::ClientboundGamePacket})
|
||||
}
|
||||
#[proc_macro_derive(ClientboundHandshakePacket, attributes(var))]
|
||||
pub fn derive_clientbound_handshake_packet(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_c_handshake_packet(input: TokenStream) -> TokenStream {
|
||||
as_packet_derive(
|
||||
input,
|
||||
quote! {crate::packets::handshaking::ClientboundHandshakePacket},
|
||||
quote! {crate::packets::handshake::ClientboundHandshakePacket},
|
||||
)
|
||||
}
|
||||
#[proc_macro_derive(ClientboundLoginPacket, attributes(var))]
|
||||
pub fn derive_clientbound_login_packet(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_c_login_packet(input: TokenStream) -> TokenStream {
|
||||
as_packet_derive(
|
||||
input,
|
||||
quote! {crate::packets::login::ClientboundLoginPacket},
|
||||
)
|
||||
}
|
||||
#[proc_macro_derive(ClientboundStatusPacket, attributes(var))]
|
||||
pub fn derive_clientbound_status_packet(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_c_status_packet(input: TokenStream) -> TokenStream {
|
||||
as_packet_derive(
|
||||
input,
|
||||
quote! {crate::packets::status::ClientboundStatusPacket},
|
||||
)
|
||||
}
|
||||
#[proc_macro_derive(ClientboundConfigurationPacket, attributes(var))]
|
||||
pub fn derive_clientbound_configuration_packet(input: TokenStream) -> TokenStream {
|
||||
#[proc_macro_derive(ClientboundConfigPacket, attributes(var))]
|
||||
pub fn derive_c_config_packet(input: TokenStream) -> TokenStream {
|
||||
as_packet_derive(
|
||||
input,
|
||||
quote! {crate::packets::configuration::ClientboundConfigurationPacket},
|
||||
quote! {crate::packets::config::ClientboundConfigPacket},
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -122,14 +122,14 @@ impl Parse for PacketIdMap {
|
|||
let mut packets = vec![];
|
||||
|
||||
// example:
|
||||
// 0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket,
|
||||
// 0x0e: c_change_difficulty::ClientboundChangeDifficultyPacket,
|
||||
|
||||
// 0x0e
|
||||
while let Ok(packet_id) = input.parse::<LitInt>() {
|
||||
let packet_id = packet_id.base10_parse::<u32>()?;
|
||||
// :
|
||||
input.parse::<Token![:]>()?;
|
||||
// clientbound_change_difficulty_packet
|
||||
// c_change_difficulty_packet
|
||||
let module: Ident = input.parse()?;
|
||||
// ::
|
||||
input.parse::<Token![::]>()?;
|
||||
|
@ -163,12 +163,9 @@ impl Parse for DeclareStatePackets {
|
|||
let name = input.parse()?;
|
||||
input.parse::<Token![,]>()?;
|
||||
|
||||
let serverbound_token: Ident = input.parse()?;
|
||||
if serverbound_token != "Serverbound" {
|
||||
return Err(syn::Error::new(
|
||||
serverbound_token.span(),
|
||||
"Expected `Serverbound`",
|
||||
));
|
||||
let s_token: Ident = input.parse()?;
|
||||
if s_token != "Serverbound" {
|
||||
return Err(syn::Error::new(s_token.span(), "Expected `Serverbound`"));
|
||||
}
|
||||
input.parse::<Token![=>]>()?;
|
||||
let content;
|
||||
|
@ -177,12 +174,9 @@ impl Parse for DeclareStatePackets {
|
|||
|
||||
input.parse::<Token![,]>()?;
|
||||
|
||||
let clientbound_token: Ident = input.parse()?;
|
||||
if clientbound_token != "Clientbound" {
|
||||
return Err(syn::Error::new(
|
||||
clientbound_token.span(),
|
||||
"Expected `Clientbound`",
|
||||
));
|
||||
let c_token: Ident = input.parse()?;
|
||||
if c_token != "Clientbound" {
|
||||
return Err(syn::Error::new(c_token.span(), "Expected `Clientbound`"));
|
||||
}
|
||||
input.parse::<Token![=>]>()?;
|
||||
let content;
|
||||
|
@ -200,39 +194,37 @@ impl Parse for DeclareStatePackets {
|
|||
pub fn declare_state_packets(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeclareStatePackets);
|
||||
|
||||
let serverbound_state_name =
|
||||
Ident::new(&format!("Serverbound{}", input.name), input.name.span());
|
||||
let clientbound_state_name =
|
||||
Ident::new(&format!("Clientbound{}", input.name), input.name.span());
|
||||
let s_state_name = Ident::new(&format!("Serverbound{}", input.name), input.name.span());
|
||||
let c_state_name = Ident::new(&format!("Clientbound{}", input.name), input.name.span());
|
||||
|
||||
let state_name_litstr = syn::LitStr::new(&input.name.to_string(), input.name.span());
|
||||
|
||||
let has_serverbound_packets = !input.serverbound.packets.is_empty();
|
||||
let has_clientbound_packets = !input.clientbound.packets.is_empty();
|
||||
let has_s_packets = !input.serverbound.packets.is_empty();
|
||||
let has_c_packets = !input.clientbound.packets.is_empty();
|
||||
|
||||
let mut serverbound_enum_contents = quote!();
|
||||
let mut clientbound_enum_contents = quote!();
|
||||
let mut serverbound_id_match_contents = quote!();
|
||||
let mut clientbound_id_match_contents = quote!();
|
||||
let mut serverbound_write_match_contents = quote!();
|
||||
let mut clientbound_write_match_contents = quote!();
|
||||
let mut serverbound_read_match_contents = quote!();
|
||||
let mut clientbound_read_match_contents = quote!();
|
||||
let mut s_enum_contents = quote!();
|
||||
let mut c_enum_contents = quote!();
|
||||
let mut s_id_match_contents = quote!();
|
||||
let mut c_id_match_contents = quote!();
|
||||
let mut s_write_match_contents = quote!();
|
||||
let mut c_write_match_contents = quote!();
|
||||
let mut s_read_match_contents = quote!();
|
||||
let mut c_read_match_contents = quote!();
|
||||
|
||||
for PacketIdPair { id, module, name } in input.serverbound.packets {
|
||||
let variant_name = variant_name_from(&name);
|
||||
|
||||
let name_litstr = syn::LitStr::new(&name.to_string(), name.span());
|
||||
serverbound_enum_contents.extend(quote! {
|
||||
s_enum_contents.extend(quote! {
|
||||
#variant_name(#module::#name),
|
||||
});
|
||||
serverbound_id_match_contents.extend(quote! {
|
||||
#serverbound_state_name::#variant_name(_packet) => #id,
|
||||
s_id_match_contents.extend(quote! {
|
||||
#s_state_name::#variant_name(_packet) => #id,
|
||||
});
|
||||
serverbound_write_match_contents.extend(quote! {
|
||||
#serverbound_state_name::#variant_name(packet) => packet.write(buf),
|
||||
s_write_match_contents.extend(quote! {
|
||||
#s_state_name::#variant_name(packet) => packet.write(buf),
|
||||
});
|
||||
serverbound_read_match_contents.extend(quote! {
|
||||
s_read_match_contents.extend(quote! {
|
||||
#id => {
|
||||
let data = #module::#name::read(buf).map_err(|e| crate::read::ReadPacketError::Parse {
|
||||
source: e,
|
||||
|
@ -256,16 +248,16 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
|
|||
let name_litstr = syn::LitStr::new(&name.to_string(), name.span());
|
||||
let variant_name = variant_name_from(&name);
|
||||
|
||||
clientbound_enum_contents.extend(quote! {
|
||||
c_enum_contents.extend(quote! {
|
||||
#variant_name(#module::#name),
|
||||
});
|
||||
clientbound_id_match_contents.extend(quote! {
|
||||
#clientbound_state_name::#variant_name(_packet) => #id,
|
||||
c_id_match_contents.extend(quote! {
|
||||
#c_state_name::#variant_name(_packet) => #id,
|
||||
});
|
||||
clientbound_write_match_contents.extend(quote! {
|
||||
#clientbound_state_name::#variant_name(packet) => packet.write(buf),
|
||||
c_write_match_contents.extend(quote! {
|
||||
#c_state_name::#variant_name(packet) => packet.write(buf),
|
||||
});
|
||||
clientbound_read_match_contents.extend(quote! {
|
||||
c_read_match_contents.extend(quote! {
|
||||
#id => {
|
||||
let data = #module::#name::read(buf).map_err(|e| crate::read::ReadPacketError::Parse {
|
||||
source: e,
|
||||
|
@ -293,52 +285,52 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
|
|||
});
|
||||
}
|
||||
|
||||
if !has_serverbound_packets {
|
||||
serverbound_id_match_contents.extend(quote! {
|
||||
if !has_s_packets {
|
||||
s_id_match_contents.extend(quote! {
|
||||
_ => unreachable!("This enum is empty and can't exist.")
|
||||
});
|
||||
serverbound_write_match_contents.extend(quote! {
|
||||
s_write_match_contents.extend(quote! {
|
||||
_ => unreachable!("This enum is empty and can't exist.")
|
||||
});
|
||||
}
|
||||
if !has_clientbound_packets {
|
||||
clientbound_id_match_contents.extend(quote! {
|
||||
if !has_c_packets {
|
||||
c_id_match_contents.extend(quote! {
|
||||
_ => unreachable!("This enum is empty and can't exist.")
|
||||
});
|
||||
clientbound_write_match_contents.extend(quote! {
|
||||
c_write_match_contents.extend(quote! {
|
||||
_ => unreachable!("This enum is empty and can't exist.")
|
||||
});
|
||||
}
|
||||
|
||||
let mut contents = quote! {
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum #serverbound_state_name
|
||||
pub enum #s_state_name
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
#serverbound_enum_contents
|
||||
#s_enum_contents
|
||||
}
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum #clientbound_state_name
|
||||
pub enum #c_state_name
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
#clientbound_enum_contents
|
||||
#c_enum_contents
|
||||
}
|
||||
};
|
||||
|
||||
contents.extend(quote! {
|
||||
#[allow(unreachable_code)]
|
||||
impl crate::packets::ProtocolPacket for #serverbound_state_name {
|
||||
impl crate::packets::ProtocolPacket for #s_state_name {
|
||||
fn id(&self) -> u32 {
|
||||
match self {
|
||||
#serverbound_id_match_contents
|
||||
#s_id_match_contents
|
||||
}
|
||||
}
|
||||
|
||||
fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
|
||||
match self {
|
||||
#serverbound_write_match_contents
|
||||
#s_write_match_contents
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -346,12 +338,12 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
|
|||
fn read(
|
||||
id: u32,
|
||||
buf: &mut std::io::Cursor<&[u8]>,
|
||||
) -> Result<#serverbound_state_name, Box<crate::read::ReadPacketError>>
|
||||
) -> Result<#s_state_name, Box<crate::read::ReadPacketError>>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
Ok(match id {
|
||||
#serverbound_read_match_contents
|
||||
#s_read_match_contents
|
||||
_ => return Err(Box::new(crate::read::ReadPacketError::UnknownPacketId { state_name: #state_name_litstr.to_string(), id })),
|
||||
})
|
||||
}
|
||||
|
@ -360,16 +352,16 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
|
|||
|
||||
contents.extend(quote! {
|
||||
#[allow(unreachable_code)]
|
||||
impl crate::packets::ProtocolPacket for #clientbound_state_name {
|
||||
impl crate::packets::ProtocolPacket for #c_state_name {
|
||||
fn id(&self) -> u32 {
|
||||
match self {
|
||||
#clientbound_id_match_contents
|
||||
#c_id_match_contents
|
||||
}
|
||||
}
|
||||
|
||||
fn write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> {
|
||||
match self {
|
||||
#clientbound_write_match_contents
|
||||
#c_write_match_contents
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,12 +369,12 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
|
|||
fn read(
|
||||
id: u32,
|
||||
buf: &mut std::io::Cursor<&[u8]>,
|
||||
) -> Result<#clientbound_state_name, Box<crate::read::ReadPacketError>>
|
||||
) -> Result<#c_state_name, Box<crate::read::ReadPacketError>>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
Ok(match id {
|
||||
#clientbound_read_match_contents
|
||||
#c_read_match_contents
|
||||
_ => return Err(Box::new(crate::read::ReadPacketError::UnknownPacketId { state_name: #state_name_litstr.to_string(), id })),
|
||||
})
|
||||
}
|
||||
|
@ -400,8 +392,5 @@ fn variant_name_from(name: &syn::Ident) -> syn::Ident {
|
|||
} else if variant_name.starts_with("Serverbound") {
|
||||
variant_name = variant_name["Serverbound".len()..].to_string();
|
||||
}
|
||||
if variant_name.ends_with("Packet") {
|
||||
variant_name = variant_name[..variant_name.len() - "Packet".len()].to_string();
|
||||
}
|
||||
syn::Ident::new(&variant_name, name.span())
|
||||
}
|
||||
|
|
|
@ -6,16 +6,14 @@ use std::error::Error;
|
|||
use azalea_protocol::{
|
||||
connect::Connection,
|
||||
packets::{
|
||||
handshaking::{
|
||||
client_intention_packet::ClientIntentionPacket, ClientboundHandshakePacket,
|
||||
handshake::{
|
||||
client_intention::ClientIntention, ClientboundHandshakePacket,
|
||||
ServerboundHandshakePacket,
|
||||
},
|
||||
login::{serverbound_hello_packet::ServerboundHelloPacket, ServerboundLoginPacket},
|
||||
login::{s_hello::ServerboundHello, ServerboundLoginPacket},
|
||||
status::{
|
||||
clientbound_pong_response_packet::ClientboundPongResponsePacket,
|
||||
clientbound_status_response_packet::{
|
||||
ClientboundStatusResponsePacket, Players, Version,
|
||||
},
|
||||
c_pong_response::ClientboundPongResponse,
|
||||
c_status_response::{ClientboundStatusResponse, Players, Version},
|
||||
ServerboundStatusPacket,
|
||||
},
|
||||
ClientIntention, PROTOCOL_VERSION,
|
||||
|
@ -103,7 +101,7 @@ async fn handle_connection(stream: TcpStream) -> anyhow::Result<()> {
|
|||
Ok(p) => match p {
|
||||
ServerboundStatusPacket::StatusRequest(_) => {
|
||||
conn.write(
|
||||
ClientboundStatusResponsePacket {
|
||||
ClientboundStatusResponse {
|
||||
description: PROXY_DESC.into(),
|
||||
favicon: PROXY_FAVICON.clone(),
|
||||
players: PROXY_PLAYERS.clone(),
|
||||
|
@ -115,7 +113,7 @@ async fn handle_connection(stream: TcpStream) -> anyhow::Result<()> {
|
|||
.await?;
|
||||
}
|
||||
ServerboundStatusPacket::PingRequest(p) => {
|
||||
conn.write(ClientboundPongResponsePacket { time: p.time }.get())
|
||||
conn.write(ClientboundPongResponse { time: p.time }.get())
|
||||
.await?;
|
||||
break;
|
||||
}
|
||||
|
@ -180,8 +178,8 @@ async fn handle_connection(stream: TcpStream) -> anyhow::Result<()> {
|
|||
|
||||
async fn transfer(
|
||||
mut inbound: TcpStream,
|
||||
intent: ClientIntentionPacket,
|
||||
hello: ServerboundHelloPacket,
|
||||
intent: ClientIntention,
|
||||
hello: ServerboundHello,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
let outbound = TcpStream::connect(PROXY_ADDR).await?;
|
||||
let name = hello.name.clone();
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
//! Some serializable data types that are used by several packets.
|
||||
|
||||
use azalea_buf::{McBuf, McBufReadable, McBufWritable};
|
||||
use azalea_core::bitset::FixedBitSet;
|
||||
use azalea_protocol_macros::ServerboundConfigurationPacket;
|
||||
use bevy_ecs::component::Component;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigurationPacket, PartialEq, Eq)]
|
||||
pub struct ServerboundClientInformationPacket {
|
||||
pub information: ClientInformation,
|
||||
}
|
||||
|
||||
/// A component that contains some of the "settings" for this client that are
|
||||
/// sent to the server, such as render distance. This is only present on local
|
||||
/// players.
|
||||
|
@ -143,51 +139,3 @@ impl McBufWritable for ModelCustomization {
|
|||
set.write_into(buf)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::io::Cursor;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,12 +16,10 @@ use tokio::net::TcpStream;
|
|||
use tracing::{error, info};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::packets::configuration::{
|
||||
ClientboundConfigurationPacket, ServerboundConfigurationPacket,
|
||||
};
|
||||
use crate::packets::config::{ClientboundConfigPacket, ServerboundConfigPacket};
|
||||
use crate::packets::game::{ClientboundGamePacket, ServerboundGamePacket};
|
||||
use crate::packets::handshaking::{ClientboundHandshakePacket, ServerboundHandshakePacket};
|
||||
use crate::packets::login::clientbound_hello_packet::ClientboundHelloPacket;
|
||||
use crate::packets::handshake::{ClientboundHandshakePacket, ServerboundHandshakePacket};
|
||||
use crate::packets::login::c_hello::ClientboundHello;
|
||||
use crate::packets::login::{ClientboundLoginPacket, ServerboundLoginPacket};
|
||||
use crate::packets::status::{ClientboundStatusPacket, ServerboundStatusPacket};
|
||||
use crate::packets::ProtocolPacket;
|
||||
|
@ -66,10 +64,10 @@ pub struct WriteConnection<W: ProtocolPacket> {
|
|||
/// ClientIntention, PROTOCOL_VERSION,
|
||||
/// login::{
|
||||
/// ClientboundLoginPacket,
|
||||
/// serverbound_hello_packet::ServerboundHelloPacket,
|
||||
/// serverbound_key_packet::ServerboundKeyPacket
|
||||
/// s_hello::ServerboundHello,
|
||||
/// s_key::ServerboundKeyPacket
|
||||
/// },
|
||||
/// handshaking::client_intention_packet::ClientIntentionPacket
|
||||
/// handshaking::client_intention::ClientIntention
|
||||
/// }
|
||||
/// };
|
||||
///
|
||||
|
@ -80,7 +78,7 @@ pub struct WriteConnection<W: ProtocolPacket> {
|
|||
///
|
||||
/// // handshake
|
||||
/// conn.write(
|
||||
/// ClientIntentionPacket {
|
||||
/// ClientIntention {
|
||||
/// protocol_version: PROTOCOL_VERSION,
|
||||
/// hostname: resolved_address.ip().to_string(),
|
||||
/// port: resolved_address.port(),
|
||||
|
@ -94,7 +92,7 @@ pub struct WriteConnection<W: ProtocolPacket> {
|
|||
///
|
||||
/// // login
|
||||
/// conn.write(
|
||||
/// ServerboundHelloPacket {
|
||||
/// ServerboundHello {
|
||||
/// name: "bot".to_string(),
|
||||
/// profile_id: uuid::Uuid::nil(),
|
||||
/// }
|
||||
|
@ -368,9 +366,7 @@ impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> {
|
|||
/// Change our state from login to configuration. This is the state where
|
||||
/// the server sends us the registries and resource pack and stuff.
|
||||
#[must_use]
|
||||
pub fn configuration(
|
||||
self,
|
||||
) -> Connection<ClientboundConfigurationPacket, ServerboundConfigurationPacket> {
|
||||
pub fn configuration(self) -> Connection<ClientboundConfigPacket, ServerboundConfigPacket> {
|
||||
Connection::from(self)
|
||||
}
|
||||
|
||||
|
@ -385,7 +381,7 @@ impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> {
|
|||
/// use azalea_protocol::connect::Connection;
|
||||
/// use azalea_protocol::packets::login::{
|
||||
/// ClientboundLoginPacket,
|
||||
/// serverbound_key_packet::ServerboundKeyPacket
|
||||
/// s_key::ServerboundKeyPacket
|
||||
/// };
|
||||
/// use uuid::Uuid;
|
||||
/// # use azalea_protocol::ServerAddress;
|
||||
|
@ -432,7 +428,7 @@ impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> {
|
|||
access_token: &str,
|
||||
uuid: &Uuid,
|
||||
private_key: [u8; 16],
|
||||
packet: &ClientboundHelloPacket,
|
||||
packet: &ClientboundHello,
|
||||
) -> Result<(), ClientSessionServerError> {
|
||||
azalea_auth::sessionserver::join(
|
||||
access_token,
|
||||
|
@ -506,14 +502,12 @@ impl Connection<ServerboundLoginPacket, ClientboundLoginPacket> {
|
|||
|
||||
/// Change our state back to configuration.
|
||||
#[must_use]
|
||||
pub fn configuration(
|
||||
self,
|
||||
) -> Connection<ServerboundConfigurationPacket, ClientboundConfigurationPacket> {
|
||||
pub fn configuration(self) -> Connection<ServerboundConfigPacket, ClientboundConfigPacket> {
|
||||
Connection::from(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Connection<ServerboundConfigurationPacket, ClientboundConfigurationPacket> {
|
||||
impl Connection<ServerboundConfigPacket, ClientboundConfigPacket> {
|
||||
/// Change our state from configuration to game. This is the state that's
|
||||
/// used when the client is actually in the world.
|
||||
#[must_use]
|
||||
|
@ -522,7 +516,7 @@ impl Connection<ServerboundConfigurationPacket, ClientboundConfigurationPacket>
|
|||
}
|
||||
}
|
||||
|
||||
impl Connection<ClientboundConfigurationPacket, ServerboundConfigurationPacket> {
|
||||
impl Connection<ClientboundConfigPacket, ServerboundConfigPacket> {
|
||||
/// Change our state from configuration to game. This is the state that's
|
||||
/// used when the client is actually in the world.
|
||||
#[must_use]
|
||||
|
@ -534,9 +528,7 @@ impl Connection<ClientboundConfigurationPacket, ServerboundConfigurationPacket>
|
|||
impl Connection<ClientboundGamePacket, ServerboundGamePacket> {
|
||||
/// Change our state back to configuration.
|
||||
#[must_use]
|
||||
pub fn configuration(
|
||||
self,
|
||||
) -> Connection<ClientboundConfigurationPacket, ServerboundConfigurationPacket> {
|
||||
pub fn configuration(self) -> Connection<ClientboundConfigPacket, ServerboundConfigPacket> {
|
||||
Connection::from(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
use std::{fmt::Display, net::SocketAddr, str::FromStr};
|
||||
|
||||
pub mod common;
|
||||
#[cfg(feature = "connecting")]
|
||||
pub mod connect;
|
||||
#[cfg(feature = "packets")]
|
||||
|
@ -108,8 +109,8 @@ mod tests {
|
|||
|
||||
use crate::{
|
||||
packets::{
|
||||
game::serverbound_chat_packet::{LastSeenMessagesUpdate, ServerboundChatPacket},
|
||||
login::{serverbound_hello_packet::ServerboundHelloPacket, ServerboundLoginPacket},
|
||||
game::s_chat::{LastSeenMessagesUpdate, ServerboundChat},
|
||||
login::{s_hello::ServerboundHello, ServerboundLoginPacket},
|
||||
},
|
||||
read::{compression_decoder, read_packet},
|
||||
write::{compression_encoder, serialize_packet, write_packet},
|
||||
|
@ -117,7 +118,7 @@ mod tests {
|
|||
|
||||
#[tokio::test]
|
||||
async fn test_hello_packet() {
|
||||
let packet = ServerboundHelloPacket {
|
||||
let packet = ServerboundHello {
|
||||
name: "test".to_string(),
|
||||
profile_id: Uuid::nil(),
|
||||
}
|
||||
|
@ -129,19 +130,15 @@ mod tests {
|
|||
|
||||
let mut stream = Cursor::new(stream);
|
||||
|
||||
let _ = read_packet::<ServerboundLoginPacket, _>(
|
||||
&mut stream,
|
||||
&mut BytesMut::new(),
|
||||
None,
|
||||
&mut None,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let _ =
|
||||
read::<ServerboundLoginPacket, _>(&mut stream, &mut BytesMut::new(), None, &mut None)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_double_hello_packet() {
|
||||
let packet = ServerboundHelloPacket {
|
||||
let packet = ServerboundHello {
|
||||
name: "test".to_string(),
|
||||
profile_id: Uuid::nil(),
|
||||
}
|
||||
|
@ -157,10 +154,10 @@ mod tests {
|
|||
|
||||
let mut buffer = BytesMut::new();
|
||||
|
||||
let _ = read_packet::<ServerboundLoginPacket, _>(&mut stream, &mut buffer, None, &mut None)
|
||||
let _ = read::<ServerboundLoginPacket, _>(&mut stream, &mut buffer, None, &mut None)
|
||||
.await
|
||||
.unwrap();
|
||||
let _ = read_packet::<ServerboundLoginPacket, _>(&mut stream, &mut buffer, None, &mut None)
|
||||
let _ = read::<ServerboundLoginPacket, _>(&mut stream, &mut buffer, None, &mut None)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -170,7 +167,7 @@ mod tests {
|
|||
let compression_threshold = 256;
|
||||
|
||||
let buf = serialize_packet(
|
||||
&ServerboundChatPacket {
|
||||
&ServerboundChat {
|
||||
message: "a".repeat(256),
|
||||
timestamp: 0,
|
||||
salt: 0,
|
||||
|
|
8
azalea-protocol/src/packets/config/c_cookie_request.rs
Normal file
8
azalea-protocol/src/packets/config/c_cookie_request.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundCookieRequest {
|
||||
pub key: ResourceLocation,
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_buf::UnsizedByteArray;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ServerboundConfigurationPacket;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigurationPacket)]
|
||||
pub struct ServerboundCustomPayloadPacket {
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundCustomPayload {
|
||||
pub identifier: ResourceLocation,
|
||||
pub data: UnsizedByteArray,
|
||||
}
|
8
azalea-protocol/src/packets/config/c_disconnect.rs
Normal file
8
azalea-protocol/src/packets/config/c_disconnect.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::FormattedText;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundDisconnect {
|
||||
pub reason: FormattedText,
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundFinishConfiguration {}
|
7
azalea-protocol/src/packets/config/c_keep_alive.rs
Normal file
7
azalea-protocol/src/packets/config/c_keep_alive.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundKeepAlive {
|
||||
pub id: u64,
|
||||
}
|
7
azalea-protocol/src/packets/config/c_ping.rs
Normal file
7
azalea-protocol/src/packets/config/c_ping.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundPing {
|
||||
pub id: u32,
|
||||
}
|
|
@ -2,11 +2,11 @@ use std::collections::HashMap;
|
|||
|
||||
use azalea_buf::McBuf;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
use simdnbt::owned::NbtCompound;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundRegistryDataPacket {
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundRegistryData {
|
||||
pub registry_id: ResourceLocation,
|
||||
pub entries: HashMap<ResourceLocation, Option<NbtCompound>>,
|
||||
}
|
5
azalea-protocol/src/packets/config/c_reset_chat.rs
Normal file
5
azalea-protocol/src/packets/config/c_reset_chat.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundResetChat;
|
11
azalea-protocol/src/packets/config/c_resource_pack.rs
Normal file
11
azalea-protocol/src/packets/config/c_resource_pack.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::FormattedText;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundResourcePack {
|
||||
pub url: String,
|
||||
pub hash: String,
|
||||
pub required: bool,
|
||||
pub prompt: Option<FormattedText>,
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundResourcePackPop {
|
||||
pub id: Option<Uuid>,
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::FormattedText;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundResourcePackPushPacket {
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundResourcePackPush {
|
||||
pub id: Uuid,
|
||||
pub url: String,
|
||||
pub hash: String,
|
|
@ -0,0 +1,9 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
use super::s_select_known_packs::KnownPack;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundSelectKnownPacks {
|
||||
pub known_packs: Vec<KnownPack>,
|
||||
}
|
9
azalea-protocol/src/packets/config/c_store_cookie.rs
Normal file
9
azalea-protocol/src/packets/config/c_store_cookie.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundStoreCookie {
|
||||
pub key: ResourceLocation,
|
||||
pub payload: Vec<u8>,
|
||||
}
|
9
azalea-protocol/src/packets/config/c_transfer.rs
Normal file
9
azalea-protocol/src/packets/config/c_transfer.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundTransfer {
|
||||
pub host: String,
|
||||
#[var]
|
||||
pub port: u32,
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundUpdateEnabledFeatures {
|
||||
pub features: Vec<ResourceLocation>,
|
||||
}
|
|
@ -5,10 +5,10 @@ use std::{collections::HashMap, io::Write};
|
|||
use azalea_buf::{BufReadError, McBuf, McBufVarReadable, McBufVarWritable};
|
||||
use azalea_buf::{McBufReadable, McBufWritable};
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
use azalea_protocol_macros::ClientboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundUpdateTagsPacket {
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigPacket)]
|
||||
pub struct ClientboundUpdateTags {
|
||||
pub tags: TagMap,
|
||||
}
|
||||
|
56
azalea-protocol/src/packets/config/mod.rs
Executable file
56
azalea-protocol/src/packets/config/mod.rs
Executable file
|
@ -0,0 +1,56 @@
|
|||
pub mod c_cookie_request;
|
||||
pub mod c_custom_payload;
|
||||
pub mod c_disconnect;
|
||||
pub mod c_finish_configuration;
|
||||
pub mod c_keep_alive;
|
||||
pub mod c_ping;
|
||||
pub mod c_registry_data;
|
||||
pub mod c_reset_chat;
|
||||
pub mod c_resource_pack_pop;
|
||||
pub mod c_resource_pack_push;
|
||||
pub mod c_select_known_packs;
|
||||
pub mod c_store_cookie;
|
||||
pub mod c_transfer;
|
||||
pub mod c_update_enabled_features;
|
||||
pub mod c_update_tags;
|
||||
pub mod s_client_information;
|
||||
pub mod s_cookie_response;
|
||||
pub mod s_custom_payload;
|
||||
pub mod s_finish_configuration;
|
||||
pub mod s_keep_alive;
|
||||
pub mod s_pong;
|
||||
pub mod s_resource_pack;
|
||||
pub mod s_select_known_packs;
|
||||
|
||||
use azalea_protocol_macros::declare_state_packets;
|
||||
|
||||
declare_state_packets!(
|
||||
ConfigPacket,
|
||||
Serverbound => {
|
||||
0x00: s_client_information::ServerboundClientInformation,
|
||||
0x01: s_cookie_response::ServerboundCookieResponse,
|
||||
0x02: s_custom_payload::ServerboundCustomPayload,
|
||||
0x03: s_finish_configuration::ServerboundFinishConfiguration,
|
||||
0x04: s_keep_alive::ServerboundKeepAlive,
|
||||
0x05: s_pong::ServerboundPong,
|
||||
0x06: s_resource_pack::ServerboundResourcePack,
|
||||
0x07: s_select_known_packs::ServerboundSelectKnownPacks,
|
||||
},
|
||||
Clientbound => {
|
||||
0x00: c_cookie_request::ClientboundCookieRequest,
|
||||
0x01: c_custom_payload::ClientboundCustomPayload,
|
||||
0x02: c_disconnect::ClientboundDisconnect,
|
||||
0x03: c_finish_configuration::ClientboundFinishConfiguration,
|
||||
0x04: c_keep_alive::ClientboundKeepAlive,
|
||||
0x05: c_ping::ClientboundPing,
|
||||
0x06: c_reset_chat::ClientboundResetChat,
|
||||
0x07: c_registry_data::ClientboundRegistryData,
|
||||
0x08: c_resource_pack_pop::ClientboundResourcePackPop,
|
||||
0x09: c_resource_pack_push::ClientboundResourcePackPush,
|
||||
0x0a: c_store_cookie::ClientboundStoreCookie,
|
||||
0x0b: c_transfer::ClientboundTransfer,
|
||||
0x0c: c_update_enabled_features::ClientboundUpdateEnabledFeatures,
|
||||
0x0d: c_update_tags::ClientboundUpdateTags,
|
||||
0x0e: c_select_known_packs::ClientboundSelectKnownPacks,
|
||||
}
|
||||
);
|
59
azalea-protocol/src/packets/config/s_client_information.rs
Normal file
59
azalea-protocol/src/packets/config/s_client_information.rs
Normal file
|
@ -0,0 +1,59 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ServerboundConfigPacket;
|
||||
|
||||
use crate::common::ClientInformation;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigPacket, PartialEq, Eq)]
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
9
azalea-protocol/src/packets/config/s_cookie_response.rs
Normal file
9
azalea-protocol/src/packets/config/s_cookie_response.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ServerboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigPacket)]
|
||||
pub struct ServerboundCookieResponse {
|
||||
pub key: ResourceLocation,
|
||||
pub payload: Option<Vec<u8>>,
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_buf::UnsizedByteArray;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
use azalea_protocol_macros::ServerboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundCustomPayloadPacket {
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigPacket)]
|
||||
pub struct ServerboundCustomPayload {
|
||||
pub identifier: ResourceLocation,
|
||||
pub data: UnsizedByteArray,
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ServerboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigPacket)]
|
||||
pub struct ServerboundFinishConfiguration {}
|
7
azalea-protocol/src/packets/config/s_keep_alive.rs
Normal file
7
azalea-protocol/src/packets/config/s_keep_alive.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ServerboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigPacket)]
|
||||
pub struct ServerboundKeepAlive {
|
||||
pub id: u64,
|
||||
}
|
7
azalea-protocol/src/packets/config/s_pong.rs
Normal file
7
azalea-protocol/src/packets/config/s_pong.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ServerboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigPacket)]
|
||||
pub struct ServerboundPong {
|
||||
pub id: u32,
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ServerboundConfigurationPacket;
|
||||
use azalea_protocol_macros::ServerboundConfigPacket;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigurationPacket)]
|
||||
pub struct ServerboundResourcePackPacket {
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigPacket)]
|
||||
pub struct ServerboundResourcePack {
|
||||
pub id: Uuid,
|
||||
pub action: Action,
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ServerboundConfigurationPacket;
|
||||
use azalea_protocol_macros::ServerboundConfigPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigurationPacket)]
|
||||
pub struct ServerboundSelectKnownPacksPacket {
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigPacket)]
|
||||
pub struct ServerboundSelectKnownPacks {
|
||||
pub known_packs: Vec<KnownPack>,
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundCookieRequestPacket {
|
||||
pub key: ResourceLocation,
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::FormattedText;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundDisconnectPacket {
|
||||
pub reason: FormattedText,
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundFinishConfigurationPacket {}
|
|
@ -1,7 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundKeepAlivePacket {
|
||||
pub id: u64,
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundPingPacket {
|
||||
pub id: u32,
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundResetChatPacket;
|
|
@ -1,11 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_chat::FormattedText;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundResourcePackPacket {
|
||||
pub url: String,
|
||||
pub hash: String,
|
||||
pub required: bool,
|
||||
pub prompt: Option<FormattedText>,
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundResourcePackPopPacket {
|
||||
pub id: Option<Uuid>,
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
|
||||
use super::serverbound_select_known_packs_packet::KnownPack;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundSelectKnownPacksPacket {
|
||||
pub known_packs: Vec<KnownPack>,
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundStoreCookiePacket {
|
||||
pub key: ResourceLocation,
|
||||
pub payload: Vec<u8>,
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundTransferPacket {
|
||||
pub host: String,
|
||||
#[var]
|
||||
pub port: u32,
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ClientboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundConfigurationPacket)]
|
||||
pub struct ClientboundUpdateEnabledFeaturesPacket {
|
||||
pub features: Vec<ResourceLocation>,
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
pub mod clientbound_cookie_request_packet;
|
||||
pub mod clientbound_custom_payload_packet;
|
||||
pub mod clientbound_disconnect_packet;
|
||||
pub mod clientbound_finish_configuration_packet;
|
||||
pub mod clientbound_keep_alive_packet;
|
||||
pub mod clientbound_ping_packet;
|
||||
pub mod clientbound_registry_data_packet;
|
||||
pub mod clientbound_reset_chat_packet;
|
||||
pub mod clientbound_resource_pack_pop_packet;
|
||||
pub mod clientbound_resource_pack_push_packet;
|
||||
pub mod clientbound_select_known_packs_packet;
|
||||
pub mod clientbound_store_cookie_packet;
|
||||
pub mod clientbound_transfer_packet;
|
||||
pub mod clientbound_update_enabled_features_packet;
|
||||
pub mod clientbound_update_tags_packet;
|
||||
pub mod serverbound_client_information_packet;
|
||||
pub mod serverbound_cookie_response_packet;
|
||||
pub mod serverbound_custom_payload_packet;
|
||||
pub mod serverbound_finish_configuration_packet;
|
||||
pub mod serverbound_keep_alive_packet;
|
||||
pub mod serverbound_pong_packet;
|
||||
pub mod serverbound_resource_pack_packet;
|
||||
pub mod serverbound_select_known_packs_packet;
|
||||
|
||||
use azalea_protocol_macros::declare_state_packets;
|
||||
|
||||
declare_state_packets!(
|
||||
ConfigurationPacket,
|
||||
Serverbound => {
|
||||
0x00: serverbound_client_information_packet::ServerboundClientInformationPacket,
|
||||
0x01: serverbound_cookie_response_packet::ServerboundCookieResponsePacket,
|
||||
0x02: serverbound_custom_payload_packet::ServerboundCustomPayloadPacket,
|
||||
0x03: serverbound_finish_configuration_packet::ServerboundFinishConfigurationPacket,
|
||||
0x04: serverbound_keep_alive_packet::ServerboundKeepAlivePacket,
|
||||
0x05: serverbound_pong_packet::ServerboundPongPacket,
|
||||
0x06: serverbound_resource_pack_packet::ServerboundResourcePackPacket,
|
||||
0x07: serverbound_select_known_packs_packet::ServerboundSelectKnownPacksPacket,
|
||||
},
|
||||
Clientbound => {
|
||||
0x00: clientbound_cookie_request_packet::ClientboundCookieRequestPacket,
|
||||
0x01: clientbound_custom_payload_packet::ClientboundCustomPayloadPacket,
|
||||
0x02: clientbound_disconnect_packet::ClientboundDisconnectPacket,
|
||||
0x03: clientbound_finish_configuration_packet::ClientboundFinishConfigurationPacket,
|
||||
0x04: clientbound_keep_alive_packet::ClientboundKeepAlivePacket,
|
||||
0x05: clientbound_ping_packet::ClientboundPingPacket,
|
||||
0x06: clientbound_reset_chat_packet::ClientboundResetChatPacket,
|
||||
0x07: clientbound_registry_data_packet::ClientboundRegistryDataPacket,
|
||||
0x08: clientbound_resource_pack_pop_packet::ClientboundResourcePackPopPacket,
|
||||
0x09: clientbound_resource_pack_push_packet::ClientboundResourcePackPushPacket,
|
||||
0x0a: clientbound_store_cookie_packet::ClientboundStoreCookiePacket,
|
||||
0x0b: clientbound_transfer_packet::ClientboundTransferPacket,
|
||||
0x0c: clientbound_update_enabled_features_packet::ClientboundUpdateEnabledFeaturesPacket,
|
||||
0x0d: clientbound_update_tags_packet::ClientboundUpdateTagsPacket,
|
||||
0x0e: clientbound_select_known_packs_packet::ClientboundSelectKnownPacksPacket,
|
||||
}
|
||||
);
|
|
@ -1,9 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_core::resource_location::ResourceLocation;
|
||||
use azalea_protocol_macros::ServerboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigurationPacket)]
|
||||
pub struct ServerboundCookieResponsePacket {
|
||||
pub key: ResourceLocation,
|
||||
pub payload: Option<Vec<u8>>,
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ServerboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigurationPacket)]
|
||||
pub struct ServerboundFinishConfigurationPacket {}
|
|
@ -1,7 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ServerboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigurationPacket)]
|
||||
pub struct ServerboundKeepAlivePacket {
|
||||
pub id: u64,
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ServerboundConfigurationPacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ServerboundConfigurationPacket)]
|
||||
pub struct ServerboundPongPacket {
|
||||
pub id: u32,
|
||||
}
|
|
@ -5,7 +5,7 @@ use azalea_protocol_macros::ClientboundGamePacket;
|
|||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundAddEntityPacket {
|
||||
pub struct ClientboundAddEntity {
|
||||
/// The id of the entity.
|
||||
#[var]
|
||||
pub id: u32,
|
||||
|
@ -22,7 +22,7 @@ pub struct ClientboundAddEntityPacket {
|
|||
pub z_vel: i16,
|
||||
}
|
||||
|
||||
impl ClientboundAddEntityPacket {
|
||||
impl ClientboundAddEntity {
|
||||
/// Make the entity into a bundle that can be inserted into the ECS. You
|
||||
/// must apply the metadata after inserting the bundle with
|
||||
/// [`Self::apply_metadata`].
|
|
@ -2,7 +2,7 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundAddExperienceOrbPacket {
|
||||
pub struct ClientboundAddExperienceOrb {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub x: f64,
|
|
@ -8,7 +8,7 @@ use uuid::Uuid;
|
|||
/// This packet is sent by the server when a player comes into visible range,
|
||||
/// not when a player joins.
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundAddPlayerPacket {
|
||||
pub struct ClientboundAddPlayer {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub uuid: Uuid,
|
||||
|
@ -17,7 +17,7 @@ pub struct ClientboundAddPlayerPacket {
|
|||
pub y_rot: i8,
|
||||
}
|
||||
|
||||
impl ClientboundAddPlayerPacket {
|
||||
impl ClientboundAddPlayer {
|
||||
pub fn as_player_bundle(&self, world_name: ResourceLocation) -> PlayerBundle {
|
||||
PlayerBundle {
|
||||
entity: EntityBundle::new(self.uuid, self.position, EntityKind::Player, world_name),
|
|
@ -2,7 +2,7 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundAnimatePacket {
|
||||
pub struct ClientboundAnimate {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub action: AnimationAction,
|
|
@ -4,7 +4,7 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundAwardStatsPacket {
|
||||
pub struct ClientboundAwardStats {
|
||||
#[var]
|
||||
pub stats: HashMap<Stat, i32>,
|
||||
}
|
|
@ -2,7 +2,7 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundBlockChangedAckPacket {
|
||||
pub struct ClientboundBlockChangedAck {
|
||||
#[var]
|
||||
pub sequence: i32,
|
||||
}
|
|
@ -3,7 +3,7 @@ use azalea_core::position::BlockPos;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundBlockDestructionPacket {
|
||||
pub struct ClientboundBlockDestruction {
|
||||
/// The ID of the entity breaking the block.
|
||||
#[var]
|
||||
pub id: u32,
|
|
@ -4,7 +4,7 @@ use azalea_protocol_macros::ClientboundGamePacket;
|
|||
use simdnbt::owned::Nbt;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundBlockEntityDataPacket {
|
||||
pub struct ClientboundBlockEntityData {
|
||||
pub pos: BlockPos,
|
||||
pub block_entity_type: azalea_registry::BlockEntityKind,
|
||||
pub tag: Nbt,
|
|
@ -4,7 +4,7 @@ use azalea_protocol_macros::ClientboundGamePacket;
|
|||
use azalea_registry::Block;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundBlockEventPacket {
|
||||
pub struct ClientboundBlockEvent {
|
||||
pub pos: BlockPos,
|
||||
pub action_id: u8,
|
||||
pub action_parameter: u8,
|
|
@ -4,7 +4,7 @@ use azalea_core::position::BlockPos;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundBlockUpdatePacket {
|
||||
pub struct ClientboundBlockUpdate {
|
||||
pub pos: BlockPos,
|
||||
pub block_state: BlockState,
|
||||
}
|
|
@ -10,7 +10,7 @@ use azalea_protocol_macros::ClientboundGamePacket;
|
|||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundBossEventPacket {
|
||||
pub struct ClientboundBossEvent {
|
||||
pub id: Uuid,
|
||||
pub operation: Operation,
|
||||
}
|
|
@ -2,4 +2,4 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundBundlePacket {}
|
||||
pub struct ClientboundBundle {}
|
|
@ -3,7 +3,7 @@ use azalea_core::difficulty::Difficulty;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundChangeDifficultyPacket {
|
||||
pub struct ClientboundChangeDifficulty {
|
||||
pub difficulty: Difficulty,
|
||||
pub locked: bool,
|
||||
}
|
|
@ -3,7 +3,7 @@ use azalea_chat::FormattedText;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundChatPreviewPacket {
|
||||
pub struct ClientboundChatPreview {
|
||||
pub query_id: i32,
|
||||
pub preview: Option<FormattedText>,
|
||||
}
|
|
@ -2,7 +2,7 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundChunkBatchFinishedPacket {
|
||||
pub struct ClientboundChunkBatchFinished {
|
||||
#[var]
|
||||
pub batch_size: u32,
|
||||
}
|
|
@ -2,4 +2,4 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundChunkBatchStartPacket {}
|
||||
pub struct ClientboundChunkBatchStart {}
|
|
@ -3,7 +3,7 @@ use azalea_core::position::ChunkPos;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundChunksBiomesPacket {
|
||||
pub struct ClientboundChunksBiomes {
|
||||
pub chunk_biome_data: Vec<ChunkBiomeData>,
|
||||
}
|
||||
|
|
@ -2,6 +2,6 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundClearTitlesPacket {
|
||||
pub struct ClientboundClearTitles {
|
||||
pub reset_times: bool,
|
||||
}
|
|
@ -3,7 +3,7 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundCommandSuggestionsPacket {
|
||||
pub struct ClientboundCommandSuggestions {
|
||||
#[var]
|
||||
pub id: u32,
|
||||
pub suggestions: Suggestions,
|
|
@ -8,7 +8,7 @@ use azalea_protocol_macros::ClientboundGamePacket;
|
|||
use tracing::warn;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundCommandsPacket {
|
||||
pub struct ClientboundCommands {
|
||||
pub entries: Vec<BrigadierNodeStub>,
|
||||
#[var]
|
||||
pub root_index: u32,
|
|
@ -2,6 +2,6 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundContainerClosePacket {
|
||||
pub struct ClientboundContainerClose {
|
||||
pub container_id: u8,
|
||||
}
|
|
@ -3,7 +3,7 @@ use azalea_inventory::ItemSlot;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundContainerSetContentPacket {
|
||||
pub struct ClientboundContainerSetContent {
|
||||
pub container_id: i8,
|
||||
#[var]
|
||||
pub state_id: u32,
|
|
@ -2,7 +2,7 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundContainerSetDataPacket {
|
||||
pub struct ClientboundContainerSetData {
|
||||
pub container_id: i8,
|
||||
pub id: u16,
|
||||
pub value: u16,
|
|
@ -3,7 +3,7 @@ use azalea_inventory::ItemSlot;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundContainerSetSlotPacket {
|
||||
pub struct ClientboundContainerSetSlot {
|
||||
pub container_id: i8,
|
||||
#[var]
|
||||
pub state_id: u32,
|
|
@ -3,6 +3,6 @@ use azalea_core::resource_location::ResourceLocation;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundCookieRequestPacket {
|
||||
pub struct ClientboundCookieRequest {
|
||||
pub key: ResourceLocation,
|
||||
}
|
|
@ -2,7 +2,7 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundCooldownPacket {
|
||||
pub struct ClientboundCooldown {
|
||||
pub item: azalea_registry::Item,
|
||||
#[var]
|
||||
pub duration: u32,
|
|
@ -2,7 +2,7 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundCustomChatCompletionsPacket {
|
||||
pub struct ClientboundCustomChatCompletions {
|
||||
pub action: Action,
|
||||
pub entries: Vec<String>,
|
||||
}
|
|
@ -4,7 +4,7 @@ use azalea_core::resource_location::ResourceLocation;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundCustomPayloadPacket {
|
||||
pub struct ClientboundCustomPayload {
|
||||
pub identifier: ResourceLocation,
|
||||
pub data: UnsizedByteArray,
|
||||
}
|
|
@ -4,7 +4,7 @@ use azalea_buf::McBuf;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundCustomReportDetailsPacket {
|
||||
pub struct ClientboundCustomReportDetails {
|
||||
// azalea doesn't implement max lengths yet
|
||||
|
||||
// max length = 32
|
|
@ -3,7 +3,7 @@ use azalea_core::resource_location::ResourceLocation;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundCustomSoundPacket {
|
||||
pub struct ClientboundCustomSound {
|
||||
pub name: ResourceLocation,
|
||||
pub source: SoundSource,
|
||||
pub x: i32,
|
|
@ -5,7 +5,7 @@ use azalea_core::position::Vec3;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundDamageEventPacket {
|
||||
pub struct ClientboundDamageEvent {
|
||||
#[var]
|
||||
pub entity_id: u32,
|
||||
#[var]
|
|
@ -1,10 +1,10 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
use super::serverbound_debug_sample_subscription::RemoteDebugSampleType;
|
||||
use super::s_debug_sample_subscription::RemoteDebugSampleType;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundDebugSamplePacket {
|
||||
pub struct ClientboundDebugSample {
|
||||
pub sample: Vec<u64>,
|
||||
pub debug_sample_type: RemoteDebugSampleType,
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
use azalea_buf::McBuf;
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
use super::clientbound_player_chat_packet::PackedMessageSignature;
|
||||
use super::c_player_chat::PackedMessageSignature;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundDeleteChatPacket {
|
||||
pub struct ClientboundDeleteChat {
|
||||
pub signature: PackedMessageSignature,
|
||||
}
|
|
@ -3,6 +3,6 @@ use azalea_chat::FormattedText;
|
|||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
|
||||
pub struct ClientboundDisconnectPacket {
|
||||
pub struct ClientboundDisconnect {
|
||||
pub reason: FormattedText,
|
||||
}
|
|
@ -5,19 +5,19 @@ use azalea_chat::{
|
|||
};
|
||||
use azalea_protocol_macros::ClientboundGamePacket;
|
||||
|
||||
use super::clientbound_player_chat_packet::ChatTypeBound;
|
||||
use super::c_player_chat::ChatTypeBound;
|
||||
|
||||
// A disguised chat packet is basically the same as a normal
|
||||
// [`ClientboundPlayerChatPacket`], except that it doesn't have any of the chat
|
||||
// [`ClientboundPlayerChat`], except that it doesn't have any of the chat
|
||||
// signing things. Vanilla servers use this when messages are sent from the
|
||||
// console.
|
||||
#[derive(Clone, Debug, McBuf, ClientboundGamePacket, PartialEq)]
|
||||
pub struct ClientboundDisguisedChatPacket {
|
||||
pub struct ClientboundDisguisedChat {
|
||||
pub message: FormattedText,
|
||||
pub chat_type: ChatTypeBound,
|
||||
}
|
||||
|
||||
impl ClientboundDisguisedChatPacket {
|
||||
impl ClientboundDisguisedChat {
|
||||
/// Get the full message, including the sender part.
|
||||
#[must_use]
|
||||
pub fn message(&self) -> FormattedText {
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue