aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2023-02-04 19:32:27 -0600
committerGitHub <noreply@github.com>2023-02-04 19:32:27 -0600
commita5672815ccef520b433363ac622dbb6d6af60c91 (patch)
treef9bb1b41876d81423ac3f188f4d368e6d362eed1 /azalea-protocol/src
parent7c7446ab1e467c29f86e9bfba260741fc469389a (diff)
downloadazalea-drasl-a5672815ccef520b433363ac622dbb6d6af60c91.tar.xz
Use an ECS (#52)
* add EntityData::kind * start making metadata use hecs * make entity codegen generate ecs stuff * fix registry codegen * get rid of worldhaver it's not even used * add bevy_ecs to deps * rename Component to FormattedText also start making the metadata use bevy_ecs but bevy_ecs doesn't let you query on Bundles so it's annoying * generate metadata.rs correctly for bevy_ecs * start switching more entity stuff to use ecs * more ecs stuff for entity storage * ok well it compiles but it definitely doesn't work * random fixes * change a bunch of entity things to use the components * some ecs stuff in az-client * packet handler uses the ecs now and other fun changes i still need to make ticking use the ecs but that's tricker, i'm considering using bevy_ecs systems for those bevy_ecs systems can't be async but the only async things in ticking is just sending packets which can just be done as a tokio task so that's not a big deal * start converting some functions in az-client into systems committing because i'm about to try something that might go horribly wrong * start splitting client i'm probably gonna change it so azalea entity ids are separate from minecraft entity ids next (so stuff like player ids can be consistent and we don't have to wait for the login packet) * separate minecraft entity ids from azalea entity ids + more ecs stuff i guess i'm using bevy_app now too huh it's necessary for plugins and it lets us control the tick rate anyways so it's fine i think i'm still not 100% sure how packet handling that interacts with the world will work, but i think if i can sneak the ecs world into there it'll be fine. Can't put packet handling in the schedule because that'd make it tick-bound, which it's not (technically it'd still work but it'd be wrong and anticheats might realize). * packet handling now it runs the schedule only when we get a tick or packet :smile: also i systemified some more functions and did other random fixes so az-world and az-physics compile making azalea-client use the ecs is almost done! all the hard parts are done now i hope, i just have to finish writing all the code so it actually works * start figuring out how functions in Client will work generally just lifetimes being annoying but i think i can get it all to work * make writing packets work synchronously* * huh az-client compiles * start fixing stuff * start fixing some packets * make packet handler work i still haven't actually tested any of this yet lol but in theory it should all work i'll probably either actually test az-client and fix all the remaining issues or update the azalea crate next ok also one thing that i'm not particularly happy with is how the packet handlers are doing ugly queries like ```rs let local_player = ecs .query::<&LocalPlayer>() .get_mut(ecs, player_entity) .unwrap(); ``` i think the right way to solve it would be by putting every packet handler in its own system but i haven't come up with a way to make that not be really annoying yet * fix warnings * ok what if i just have a bunch of queries and a single packet handler system * simple example for azalea-client * :bug: * maybe fix deadlock idk can't test it rn lmao * make physicsstate its own component * use the default plugins * azalea compiles lol * use systemstate for packet handler * fix entities basically moved some stuff from being in the world to just being components * physics (ticking) works * try to add a .entity_by function still doesn't work because i want to make the predicate magic * try to make entity_by work well it does work but i couldn't figure out how to make it look not terrible. Will hopefully change in the future * everything compiles * start converting swarm to use builder * continue switching swarm to builder and fix stuff * make swarm use builder still have to fix some stuff and make client use builder * fix death event * client builder * fix some warnings * document plugins a bit * start trying to fix tests * azalea-ecs * azalea-ecs stuff compiles * az-physics tests pass :tada: * fix all the tests * clippy on azalea-ecs-macros * remove now-unnecessary trait_upcasting feature * fix some clippy::pedantic warnings lol * why did cargo fmt not remove the trailing spaces * FIX ALL THE THINGS * when i said 'all' i meant non-swarm bugs * start adding task pool * fix entity deduplication * fix pathfinder not stopping * fix some more random bugs * fix panic that sometimes happens in swarms * make pathfinder run in task * fix some tests * fix doctests and clippy * deadlock * fix systems running in wrong order * fix non-swarm bots
Diffstat (limited to 'azalea-protocol/src')
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_add_entity_packet.rs48
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_add_player_packet.rs26
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_award_stats_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs2
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_boss_event_packet.rs8
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_command_suggestions_packet.rs6
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_commands_packet.rs2
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_disconnect_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_disguised_chat_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_open_screen_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs24
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_player_combat_kill_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs6
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_resource_pack_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_server_data_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_set_action_bar_text_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_set_objective_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_set_player_team_packet.rs8
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_set_subtitle_text_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_set_title_text_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_system_chat_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_tab_list_packet.rs6
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs5
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs10
-rwxr-xr-xazalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs3
-rwxr-xr-xazalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs4
-rwxr-xr-xazalea-protocol/src/packets/status/clientbound_status_response_packet.rs4
29 files changed, 111 insertions, 107 deletions
diff --git a/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs
index fcbd8fa5..75f3f4dc 100755
--- a/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_add_entity_packet.rs
@@ -1,7 +1,7 @@
use azalea_buf::McBuf;
-use azalea_core::Vec3;
+use azalea_core::{ResourceLocation, Vec3};
use azalea_protocol_macros::ClientboundGamePacket;
-use azalea_world::entity::{EntityData, EntityMetadata};
+use azalea_world::entity::{metadata::apply_default_metadata, EntityBundle};
use uuid::Uuid;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
@@ -10,10 +10,8 @@ pub struct ClientboundAddEntityPacket {
#[var]
pub id: u32,
pub uuid: Uuid,
- pub entity_type: azalea_registry::EntityType,
- pub x: f64,
- pub y: f64,
- pub z: f64,
+ pub entity_type: azalea_registry::EntityKind,
+ pub position: Vec3,
pub x_rot: i8,
pub y_rot: i8,
pub y_head_rot: i8,
@@ -24,17 +22,31 @@ pub struct ClientboundAddEntityPacket {
pub z_vel: i16,
}
-impl From<&ClientboundAddEntityPacket> for EntityData {
- fn from(p: &ClientboundAddEntityPacket) -> Self {
- Self::new(
- p.uuid,
- Vec3 {
- x: p.x,
- y: p.y,
- z: p.z,
- },
- // default metadata for the entity type
- EntityMetadata::from(p.entity_type),
- )
+// impl From<&ClientboundAddEntityPacket> for EntityData {
+// fn from(p: &ClientboundAddEntityPacket) -> Self {
+// Self::new(
+// p.uuid,
+// Vec3 {
+// x: p.x,
+// y: p.y,
+// z: p.z,
+// },
+// // default metadata for the entity type
+// EntityMetadata::from(p.entity_type),
+// )
+// }
+// }
+
+impl ClientboundAddEntityPacket {
+ /// 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`].
+ pub fn as_entity_bundle(&self, world_name: ResourceLocation) -> EntityBundle {
+ EntityBundle::new(self.uuid, self.position, self.entity_type, world_name)
+ }
+
+ /// Apply the default metadata for the given entity.
+ pub fn apply_metadata(&self, entity: &mut bevy_ecs::system::EntityCommands) {
+ apply_default_metadata(entity, self.entity_type);
}
}
diff --git a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs
index 58c7b0a3..4cbeb1b9 100755
--- a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs
@@ -1,7 +1,8 @@
use azalea_buf::McBuf;
-use azalea_core::Vec3;
+use azalea_core::{ResourceLocation, Vec3};
use azalea_protocol_macros::ClientboundGamePacket;
-use azalea_world::entity::{metadata, EntityData, EntityMetadata};
+use azalea_registry::EntityKind;
+use azalea_world::entity::{metadata::PlayerMetadataBundle, EntityBundle, PlayerBundle};
use uuid::Uuid;
/// This packet is sent by the server when a player comes into visible range,
@@ -11,23 +12,16 @@ pub struct ClientboundAddPlayerPacket {
#[var]
pub id: u32,
pub uuid: Uuid,
- pub x: f64,
- pub y: f64,
- pub z: f64,
+ pub position: Vec3,
pub x_rot: i8,
pub y_rot: i8,
}
-impl From<&ClientboundAddPlayerPacket> for EntityData {
- fn from(p: &ClientboundAddPlayerPacket) -> Self {
- Self::new(
- p.uuid,
- Vec3 {
- x: p.x,
- y: p.y,
- z: p.z,
- },
- EntityMetadata::Player(metadata::Player::default()),
- )
+impl ClientboundAddPlayerPacket {
+ pub fn as_player_bundle(&self, world_name: ResourceLocation) -> PlayerBundle {
+ PlayerBundle {
+ entity: EntityBundle::new(self.uuid, self.position, EntityKind::Player, world_name),
+ metadata: PlayerMetadataBundle::default(),
+ }
}
}
diff --git a/azalea-protocol/src/packets/game/clientbound_award_stats_packet.rs b/azalea-protocol/src/packets/game/clientbound_award_stats_packet.rs
index 2812987d..aaec1849 100755
--- a/azalea-protocol/src/packets/game/clientbound_award_stats_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_award_stats_packet.rs
@@ -16,7 +16,7 @@ pub enum Stat {
Broken(azalea_registry::Item),
PickedUp(azalea_registry::Item),
Dropped(azalea_registry::Item),
- Killed(azalea_registry::EntityType),
- KilledBy(azalea_registry::EntityType),
+ Killed(azalea_registry::EntityKind),
+ KilledBy(azalea_registry::EntityKind),
Custom(azalea_registry::CustomStat),
}
diff --git a/azalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs
index faa3b1a9..e3c95034 100755
--- a/azalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_block_entity_data_packet.rs
@@ -5,6 +5,6 @@ use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundBlockEntityDataPacket {
pub pos: BlockPos,
- pub block_entity_type: azalea_registry::BlockEntityType,
+ pub block_entity_type: azalea_registry::BlockEntityKind,
pub tag: azalea_nbt::Tag,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs b/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs
index 3ffbaea1..e73b55ba 100755
--- a/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_boss_event_packet.rs
@@ -1,7 +1,7 @@
use azalea_buf::{
BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable,
};
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_core::FixedBitSet;
use azalea_protocol_macros::ClientboundGamePacket;
use std::io::Cursor;
@@ -19,7 +19,7 @@ pub enum Operation {
Add(AddOperation),
Remove,
UpdateProgress(f32),
- UpdateName(Component),
+ UpdateName(FormattedText),
UpdateStyle(Style),
UpdateProperties(Properties),
}
@@ -31,7 +31,7 @@ impl McBufReadable for Operation {
0 => Operation::Add(AddOperation::read_from(buf)?),
1 => Operation::Remove,
2 => Operation::UpdateProgress(f32::read_from(buf)?),
- 3 => Operation::UpdateName(Component::read_from(buf)?),
+ 3 => Operation::UpdateName(FormattedText::read_from(buf)?),
4 => Operation::UpdateStyle(Style::read_from(buf)?),
5 => Operation::UpdateProperties(Properties::read_from(buf)?),
_ => {
@@ -76,7 +76,7 @@ impl McBufWritable for Operation {
#[derive(Clone, Debug, McBuf)]
pub struct AddOperation {
- name: Component,
+ name: FormattedText,
progress: f32,
style: Style,
properties: Properties,
diff --git a/azalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs b/azalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs
index 5a72ae33..40f28259 100755
--- a/azalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_chat_preview_packet.rs
@@ -1,9 +1,9 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundChatPreviewPacket {
pub query_id: i32,
- pub preview: Option<Component>,
+ pub preview: Option<FormattedText>,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_command_suggestions_packet.rs b/azalea-protocol/src/packets/game/clientbound_command_suggestions_packet.rs
index 652ce78a..88c6f29e 100755
--- a/azalea-protocol/src/packets/game/clientbound_command_suggestions_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_command_suggestions_packet.rs
@@ -1,13 +1,13 @@
use azalea_brigadier::suggestion::Suggestions;
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundCommandSuggestionsPacket {
#[var]
pub id: u32,
- pub suggestions: Suggestions<Component>,
+ pub suggestions: Suggestions<FormattedText>,
}
#[cfg(test)]
@@ -24,7 +24,7 @@ mod tests {
suggestions: vec![Suggestion {
text: "foo".to_string(),
range: StringRange::new(1, 4),
- tooltip: Some(Component::from("bar".to_string())),
+ tooltip: Some(FormattedText::from("bar".to_string())),
}],
};
let mut buf = Vec::new();
diff --git a/azalea-protocol/src/packets/game/clientbound_commands_packet.rs b/azalea-protocol/src/packets/game/clientbound_commands_packet.rs
index fa11a355..73dcbce7 100755
--- a/azalea-protocol/src/packets/game/clientbound_commands_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_commands_packet.rs
@@ -114,7 +114,7 @@ pub enum BrigadierParser {
ItemStack,
ItemPredicate,
Color,
- Component,
+ FormattedText,
Message,
NbtCompoundTag,
NbtTag,
diff --git a/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs b/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs
index ecff0278..f8771c37 100755
--- a/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_disconnect_packet.rs
@@ -1,8 +1,8 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundDisconnectPacket {
- pub reason: Component,
+ pub reason: FormattedText,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_disguised_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_disguised_chat_packet.rs
index 701284a0..9aa9fd6f 100644
--- a/azalea-protocol/src/packets/game/clientbound_disguised_chat_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_disguised_chat_packet.rs
@@ -1,10 +1,10 @@
use super::clientbound_player_chat_packet::ChatTypeBound;
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundDisguisedChatPacket {
- pub message: Component,
+ pub message: FormattedText,
pub chat_type: ChatTypeBound,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs
index 38d92135..0f858181 100755
--- a/azalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs
@@ -1,5 +1,5 @@
use azalea_buf::{McBuf, McBufReadable, McBufWritable};
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, ClientboundGamePacket, McBuf)]
@@ -20,7 +20,7 @@ pub struct MapDecoration {
/// Minecraft does & 15 on this value, azalea-protocol doesn't. I don't
/// think it matters.
pub rot: i8,
- pub name: Option<Component>,
+ pub name: Option<FormattedText>,
}
#[derive(Debug, Clone)]
diff --git a/azalea-protocol/src/packets/game/clientbound_open_screen_packet.rs b/azalea-protocol/src/packets/game/clientbound_open_screen_packet.rs
index f127f587..9b8b02a1 100755
--- a/azalea-protocol/src/packets/game/clientbound_open_screen_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_open_screen_packet.rs
@@ -1,5 +1,5 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
@@ -7,5 +7,5 @@ pub struct ClientboundOpenScreenPacket {
#[var]
pub container_id: u32,
pub menu_type: azalea_registry::Menu,
- pub title: Component,
+ pub title: FormattedText,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs
index 098ffa03..fb805dea 100644
--- a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs
@@ -3,7 +3,7 @@ use azalea_buf::{
};
use azalea_chat::{
translatable_component::{StringOrComponent, TranslatableComponent},
- Component,
+ FormattedText,
};
use azalea_core::BitSet;
use azalea_crypto::MessageSignature;
@@ -18,7 +18,7 @@ pub struct ClientboundPlayerChatPacket {
pub index: u32,
pub signature: Option<MessageSignature>,
pub body: PackedSignedMessageBody,
- pub unsigned_content: Option<Component>,
+ pub unsigned_content: Option<FormattedText>,
pub filter_mask: FilterMask,
pub chat_type: ChatTypeBound,
}
@@ -66,8 +66,8 @@ pub enum ChatType {
#[derive(Clone, Debug, McBuf, PartialEq)]
pub struct ChatTypeBound {
pub chat_type: ChatType,
- pub name: Component,
- pub target_name: Option<Component>,
+ pub name: FormattedText,
+ pub target_name: Option<FormattedText>,
}
// must be in Client
@@ -87,19 +87,19 @@ pub struct MessageSignatureCache {
// {} }
impl ClientboundPlayerChatPacket {
- /// Returns the content of the message. If you want to get the Component
+ /// Returns the content of the message. If you want to get the FormattedText
/// for the whole message including the sender part, use
/// [`ClientboundPlayerChatPacket::message`].
#[must_use]
- pub fn content(&self) -> Component {
+ pub fn content(&self) -> FormattedText {
self.unsigned_content
.clone()
- .unwrap_or_else(|| Component::from(self.body.content.clone()))
+ .unwrap_or_else(|| FormattedText::from(self.body.content.clone()))
}
/// Get the full message, including the sender part.
#[must_use]
- pub fn message(&self) -> Component {
+ pub fn message(&self) -> FormattedText {
let sender = self.chat_type.name.clone();
let content = self.content();
let target = self.chat_type.target_name.clone();
@@ -107,16 +107,16 @@ impl ClientboundPlayerChatPacket {
let translation_key = self.chat_type.chat_type.chat_translation_key();
let mut args = vec![
- StringOrComponent::Component(sender),
- StringOrComponent::Component(content),
+ StringOrComponent::FormattedText(sender),
+ StringOrComponent::FormattedText(content),
];
if let Some(target) = target {
- args.push(StringOrComponent::Component(target));
+ args.push(StringOrComponent::FormattedText(target));
}
let component = TranslatableComponent::new(translation_key.to_string(), args);
- Component::Translatable(component)
+ FormattedText::Translatable(component)
}
}
diff --git a/azalea-protocol/src/packets/game/clientbound_player_combat_kill_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_combat_kill_packet.rs
index fa547af1..eae96f65 100755
--- a/azalea-protocol/src/packets/game/clientbound_player_combat_kill_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_combat_kill_packet.rs
@@ -1,5 +1,5 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
/// Used to send a respawn screen.
@@ -8,5 +8,5 @@ pub struct ClientboundPlayerCombatKillPacket {
#[var]
pub player_id: u32,
pub killer_id: u32,
- pub message: Component,
+ pub message: FormattedText,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs
index 4fa16209..dc518c9c 100644
--- a/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_info_update_packet.rs
@@ -2,7 +2,7 @@ use azalea_auth::game_profile::{GameProfile, ProfilePropertyValue};
use azalea_buf::{
BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable,
};
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_core::{FixedBitSet, GameType};
use azalea_protocol_macros::ClientboundGamePacket;
use std::{
@@ -25,7 +25,7 @@ pub struct PlayerInfoEntry {
pub listed: bool,
pub latency: i32,
pub game_mode: GameType,
- pub display_name: Option<Component>,
+ pub display_name: Option<FormattedText>,
pub chat_session: Option<RemoteChatSessionData>,
}
@@ -53,7 +53,7 @@ pub struct UpdateLatencyAction {
}
#[derive(Clone, Debug, McBuf)]
pub struct UpdateDisplayNameAction {
- pub display_name: Option<Component>,
+ pub display_name: Option<FormattedText>,
}
impl McBufReadable for ClientboundPlayerInfoUpdatePacket {
diff --git a/azalea-protocol/src/packets/game/clientbound_resource_pack_packet.rs b/azalea-protocol/src/packets/game/clientbound_resource_pack_packet.rs
index 73ade728..a545ff31 100755
--- a/azalea-protocol/src/packets/game/clientbound_resource_pack_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_resource_pack_packet.rs
@@ -1,5 +1,5 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
@@ -7,5 +7,5 @@ pub struct ClientboundResourcePackPacket {
pub url: String,
pub hash: String,
pub required: bool,
- pub prompt: Option<Component>,
+ pub prompt: Option<FormattedText>,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs
index 16841e3a..4b2bf055 100755
--- a/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_server_data_packet.rs
@@ -1,10 +1,10 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundServerDataPacket {
- pub motd: Option<Component>,
+ pub motd: Option<FormattedText>,
pub icon_base64: Option<String>,
pub enforces_secure_chat: bool,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_set_action_bar_text_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_action_bar_text_packet.rs
index e279e33c..60b80fe9 100755
--- a/azalea-protocol/src/packets/game/clientbound_set_action_bar_text_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_action_bar_text_packet.rs
@@ -1,8 +1,8 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundSetActionBarTextPacket {
- pub text: Component,
+ pub text: FormattedText,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_set_objective_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_objective_packet.rs
index 9e2da325..3809b5b6 100755
--- a/azalea-protocol/src/packets/game/clientbound_set_objective_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_objective_packet.rs
@@ -1,5 +1,5 @@
use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable};
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
use std::io::{Cursor, Write};
@@ -48,7 +48,7 @@ impl McBufWritable for Method {
#[derive(McBuf, Clone, Debug)]
pub struct DisplayInfo {
- pub display_name: Component,
+ pub display_name: FormattedText,
pub render_type: RenderType,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_set_player_team_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_player_team_packet.rs
index 0b3c1e24..1a09aeb5 100755
--- a/azalea-protocol/src/packets/game/clientbound_set_player_team_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_player_team_packet.rs
@@ -1,5 +1,5 @@
use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable};
-use azalea_chat::{style::ChatFormatting, Component};
+use azalea_chat::{style::ChatFormatting, FormattedText};
use azalea_protocol_macros::ClientboundGamePacket;
use std::io::{Cursor, Write};
@@ -61,13 +61,13 @@ impl McBufWritable for Method {
#[derive(McBuf, Clone, Debug)]
pub struct Parameters {
- pub display_name: Component,
+ pub display_name: FormattedText,
pub options: u8,
pub nametag_visibility: String,
pub collision_rule: String,
pub color: ChatFormatting,
- pub player_prefix: Component,
- pub player_suffix: Component,
+ pub player_prefix: FormattedText,
+ pub player_suffix: FormattedText,
}
type PlayerList = Vec<String>;
diff --git a/azalea-protocol/src/packets/game/clientbound_set_subtitle_text_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_subtitle_text_packet.rs
index b7d1e7a4..9b25ac05 100755
--- a/azalea-protocol/src/packets/game/clientbound_set_subtitle_text_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_subtitle_text_packet.rs
@@ -1,8 +1,8 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundSetSubtitleTextPacket {
- pub text: Component,
+ pub text: FormattedText,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_set_title_text_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_title_text_packet.rs
index a9185e1a..fb00a4e5 100755
--- a/azalea-protocol/src/packets/game/clientbound_set_title_text_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_title_text_packet.rs
@@ -1,8 +1,8 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundSetTitleTextPacket {
- pub text: Component,
+ pub text: FormattedText,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_system_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_system_chat_packet.rs
index 9fe03fb2..8a5823a0 100755
--- a/azalea-protocol/src/packets/game/clientbound_system_chat_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_system_chat_packet.rs
@@ -1,9 +1,9 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket, PartialEq)]
pub struct ClientboundSystemChatPacket {
- pub content: Component,
+ pub content: FormattedText,
pub overlay: bool,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_tab_list_packet.rs b/azalea-protocol/src/packets/game/clientbound_tab_list_packet.rs
index 94f23241..47dd1ab2 100755
--- a/azalea-protocol/src/packets/game/clientbound_tab_list_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_tab_list_packet.rs
@@ -1,9 +1,9 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundTabListPacket {
- pub header: Component,
- pub footer: Component,
+ pub header: FormattedText,
+ pub footer: FormattedText,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs b/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs
index 05a912ba..eceaa3aa 100755
--- a/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_teleport_entity_packet.rs
@@ -1,13 +1,12 @@
use azalea_buf::McBuf;
+use azalea_core::Vec3;
use azalea_protocol_macros::ClientboundGamePacket;
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundTeleportEntityPacket {
#[var]
pub id: u32,
- pub x: f64,
- pub y: f64,
- pub z: f64,
+ pub position: Vec3,
pub y_rot: i8,
pub x_rot: i8,
pub on_ground: bool,
diff --git a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
index e2a46d38..038cdcf2 100755
--- a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
@@ -1,5 +1,5 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_core::{ResourceLocation, Slot};
use azalea_protocol_macros::ClientboundGamePacket;
use std::collections::HashMap;
@@ -23,8 +23,8 @@ pub struct Advancement {
#[derive(Clone, Debug)]
pub struct DisplayInfo {
- pub title: Component,
- pub description: Component,
+ pub title: FormattedText,
+ pub description: FormattedText,
pub icon: Slot,
pub frame: FrameType,
pub show_toast: bool,
@@ -128,8 +128,8 @@ mod tests {
Advancement {
parent_id: None,
display: Some(DisplayInfo {
- title: Component::from("title".to_string()),
- description: Component::from("description".to_string()),
+ title: FormattedText::from("title".to_string()),
+ description: FormattedText::from("description".to_string()),
icon: Slot::Empty,
frame: FrameType::Task,
show_toast: true,
diff --git a/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs b/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs
index 989009f4..dbc08b16 100755
--- a/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs
+++ b/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs
@@ -15,8 +15,7 @@ pub struct ServerboundSetJigsawBlockPacket {
pub target: ResourceLocation,
pub pool: ResourceLocation,
pub final_state: String,
- pub joint: String, /* TODO: Does JigsawBlockEntity$JointType::getSerializedName, may not be
- * implemented */
+ pub joint: String,
}
pub enum JointType {
diff --git a/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs
index 983dc31b..31cd370d 100755
--- a/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_login_disconnect_packet.rs
@@ -1,8 +1,8 @@
use azalea_buf::McBuf;
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundLoginPacket;
#[derive(Clone, Debug, McBuf, ClientboundLoginPacket)]
pub struct ClientboundLoginDisconnectPacket {
- pub reason: Component,
+ pub reason: FormattedText,
}
diff --git a/azalea-protocol/src/packets/status/clientbound_status_response_packet.rs b/azalea-protocol/src/packets/status/clientbound_status_response_packet.rs
index efa6080c..40452c87 100755
--- a/azalea-protocol/src/packets/status/clientbound_status_response_packet.rs
+++ b/azalea-protocol/src/packets/status/clientbound_status_response_packet.rs
@@ -1,5 +1,5 @@
use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
-use azalea_chat::Component;
+use azalea_chat::FormattedText;
use azalea_protocol_macros::ClientboundStatusPacket;
use serde::{Deserialize, Serialize};
use serde_json::{value::Serializer, Value};
@@ -28,7 +28,7 @@ pub struct Players {
// the entire packet is just json, which is why it has deserialize
#[derive(Clone, Debug, Serialize, Deserialize, ClientboundStatusPacket)]
pub struct ClientboundStatusResponsePacket {
- pub description: Component,
+ pub description: FormattedText,
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub favicon: Option<String>,