aboutsummaryrefslogtreecommitdiff
path: root/azalea-client
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-05-24 02:52:21 -0500
committermat <git@matdoes.dev>2023-05-24 02:52:21 -0500
commit8be3921ad450958ac9bc8c1911ecd65760ea42b6 (patch)
tree2bf05b45f2aaa23f3b1f54c1ef365888ee02f08a /azalea-client
parent630c78b3180443115b84261a63bfdb3e61c41822 (diff)
parenteb65b0ad6e03f5ffcf8f0f2328ec91bb7e26259f (diff)
downloadazalea-drasl-8be3921ad450958ac9bc8c1911ecd65760ea42b6.tar.xz
merge main
Diffstat (limited to 'azalea-client')
-rw-r--r--azalea-client/Cargo.toml22
-rwxr-xr-xazalea-client/src/chat.rs10
-rw-r--r--azalea-client/src/client.rs49
-rw-r--r--azalea-client/src/interact.rs2
-rw-r--r--azalea-client/src/inventory.rs4
-rw-r--r--azalea-client/src/lib.rs2
-rw-r--r--azalea-client/src/respawn.rs21
7 files changed, 55 insertions, 55 deletions
diff --git a/azalea-client/Cargo.toml b/azalea-client/Cargo.toml
index 2a80467a..0271d42e 100644
--- a/azalea-client/Cargo.toml
+++ b/azalea-client/Cargo.toml
@@ -4,28 +4,28 @@ edition = "2021"
license = "MIT"
name = "azalea-client"
repository = "https://github.com/mat-1/azalea/tree/main/azalea-client"
-version = "0.6.0"
+version = "0.7.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.59"
async-trait = "0.1.58"
-azalea-auth = { path = "../azalea-auth", version = "0.6.0" }
-azalea-block = { path = "../azalea-block", version = "0.6.0" }
-azalea-chat = { path = "../azalea-chat", version = "0.6.0" }
-azalea-core = { path = "../azalea-core", version = "0.6.0" }
-azalea-crypto = { path = "../azalea-crypto", version = "0.6.0" }
-azalea-physics = { path = "../azalea-physics", version = "0.6.0" }
-azalea-protocol = { path = "../azalea-protocol", version = "0.6.0" }
-azalea-registry = { path = "../azalea-registry", version = "0.6.0" }
-azalea-world = { path = "../azalea-world", version = "0.6.0" }
+azalea-auth = { path = "../azalea-auth", version = "0.7.0" }
+azalea-block = { path = "../azalea-block", version = "0.7.0" }
+azalea-chat = { path = "../azalea-chat", version = "0.7.0" }
+azalea-core = { path = "../azalea-core", version = "0.7.0" }
+azalea-crypto = { path = "../azalea-crypto", version = "0.7.0" }
+azalea-physics = { path = "../azalea-physics", version = "0.7.0" }
+azalea-protocol = { path = "../azalea-protocol", version = "0.7.0" }
+azalea-registry = { path = "../azalea-registry", version = "0.7.0" }
+azalea-world = { path = "../azalea-world", version = "0.7.0" }
bevy_app = "0.10.0"
bevy_ecs = "0.10.0"
bevy_log = "0.10.0"
bevy_tasks = "0.10.0"
bevy_time = "0.10.0"
-azalea-inventory = { path = "../azalea-inventory", version = "0.1.0" }
+azalea-inventory = { path = "../azalea-inventory", version = "0.7.0" }
derive_more = { version = "0.99.17", features = ["deref", "deref_mut"] }
futures = "0.3.25"
log = "0.4.17"
diff --git a/azalea-client/src/chat.rs b/azalea-client/src/chat.rs
index 0ae0250a..90618c80 100755
--- a/azalea-client/src/chat.rs
+++ b/azalea-client/src/chat.rs
@@ -108,6 +108,16 @@ impl ChatPacket {
overlay: false,
}))
}
+
+ /// Whether this message was sent with /msg (or aliases). It works by
+ /// checking the translation key, so it won't work on servers that use their
+ /// own whisper system.
+ pub fn is_whisper(&self) -> bool {
+ match self.message() {
+ FormattedText::Text(_) => false,
+ FormattedText::Translatable(t) => t.key == "commands.message.display.incoming",
+ }
+ }
}
impl Client {
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs
index f2e91dfa..739ec434 100644
--- a/azalea-client/src/client.rs
+++ b/azalea-client/src/client.rs
@@ -221,7 +221,10 @@ impl Client {
// An event that causes the schedule to run. This is only used internally.
let (run_schedule_sender, run_schedule_receiver) = mpsc::unbounded_channel();
- let app = init_ecs_app();
+
+ let mut app = App::new();
+ app.add_plugins(DefaultPlugins);
+
let ecs_lock = start_ecs(app, run_schedule_receiver, run_schedule_sender.clone());
Self::start_client(
@@ -583,35 +586,10 @@ impl Plugin for AzaleaPlugin {
}
}
-/// Create the [`App`]. This won't actually run anything yet.
+/// Start running the ECS loop!
///
-/// Note that you usually only need this if you're creating a client manually,
-/// otherwise use [`Client::join`].
-///
-/// Use [`start_ecs`] to actually start running the app and then
-/// [`Client::start_client`] to add a client to the ECS and make it join a
-/// server.
-#[doc(hidden)]
-pub fn init_ecs_app() -> App {
- // if you get an error right here that means you're doing something with locks
- // wrong read the error to see where the issue is
- // you might be able to just drop the lock or put it in its own scope to fix
-
- let mut app = App::new();
-
- app.edit_schedule(CoreSchedule::Main, |schedule| {
- schedule.set_build_settings(ScheduleBuildSettings {
- ambiguity_detection: LogLevel::Warn,
- ..Default::default()
- });
- });
-
- app.add_plugins(DefaultPlugins);
- app
-}
-
-/// Start running the ECS loop! You must create your `App` from [`init_ecs_app`]
-/// first.
+/// You can create your app with `App::new()`, but don't forget to add
+/// [`DefaultPlugins`].
#[doc(hidden)]
pub fn start_ecs(
mut app: App,
@@ -698,6 +676,18 @@ impl Plugin for TickBroadcastPlugin {
}
}
+pub struct AmbiguityLoggerPlugin;
+impl Plugin for AmbiguityLoggerPlugin {
+ fn build(&self, app: &mut App) {
+ app.edit_schedule(CoreSchedule::Main, |schedule| {
+ schedule.set_build_settings(ScheduleBuildSettings {
+ ambiguity_detection: LogLevel::Warn,
+ ..Default::default()
+ });
+ });
+ }
+}
+
/// This plugin group will add all the default plugins necessary for Azalea to
/// work.
pub struct DefaultPlugins;
@@ -706,6 +696,7 @@ impl PluginGroup for DefaultPlugins {
fn build(self) -> PluginGroupBuilder {
PluginGroupBuilder::start::<Self>()
.add(LogPlugin::default())
+ .add(AmbiguityLoggerPlugin)
.add(TimePlugin::default())
.add(PacketHandlerPlugin)
.add(AzaleaPlugin)
diff --git a/azalea-client/src/interact.rs b/azalea-client/src/interact.rs
index 2da80760..fa05aa49 100644
--- a/azalea-client/src/interact.rs
+++ b/azalea-client/src/interact.rs
@@ -73,7 +73,7 @@ pub struct CurrentSequenceNumber(u32);
#[derive(Component, Clone, Debug, Deref, DerefMut)]
pub struct HitResultComponent(BlockHitResult);
-fn handle_block_interact_event(
+pub fn handle_block_interact_event(
mut events: EventReader<BlockInteractEvent>,
mut query: Query<(
&LocalPlayer,
diff --git a/azalea-client/src/inventory.rs b/azalea-client/src/inventory.rs
index d6f909a7..bce629b0 100644
--- a/azalea-client/src/inventory.rs
+++ b/azalea-client/src/inventory.rs
@@ -628,7 +628,7 @@ fn handle_container_close_event(
pub struct ClientSideCloseContainerEvent {
pub entity: Entity,
}
-fn handle_client_side_close_container_event(
+pub fn handle_client_side_close_container_event(
mut events: EventReader<ClientSideCloseContainerEvent>,
mut query: Query<&mut InventoryComponent>,
) {
@@ -645,7 +645,7 @@ pub struct ContainerClickEvent {
pub window_id: u8,
pub operation: ClickOperation,
}
-fn handle_container_click_event(
+pub fn handle_container_click_event(
mut events: EventReader<ContainerClickEvent>,
mut query: Query<(&mut InventoryComponent, &LocalPlayer)>,
) {
diff --git a/azalea-client/src/lib.rs b/azalea-client/src/lib.rs
index 2c08033b..10a50e92 100644
--- a/azalea-client/src/lib.rs
+++ b/azalea-client/src/lib.rs
@@ -30,7 +30,7 @@ pub mod task_pool;
pub use account::{Account, AccountOpts};
pub use client::{
- init_ecs_app, start_ecs, Client, ClientInformation, JoinError, JoinedClientBundle, TabList,
+ start_ecs, Client, ClientInformation, DefaultPlugins, JoinError, JoinedClientBundle, TabList,
TickBroadcast,
};
pub use events::Event;
diff --git a/azalea-client/src/respawn.rs b/azalea-client/src/respawn.rs
index 4e42157c..3ac17612 100644
--- a/azalea-client/src/respawn.rs
+++ b/azalea-client/src/respawn.rs
@@ -4,7 +4,7 @@ use azalea_protocol::packets::game::serverbound_client_command_packet::{
use bevy_app::{App, Plugin};
use bevy_ecs::prelude::*;
-use crate::LocalPlayer;
+use crate::local_player::{handle_send_packet_event, SendPacketEvent};
/// Tell the server that we're respawning.
#[derive(Debug, Clone)]
@@ -17,22 +17,21 @@ pub struct RespawnPlugin;
impl Plugin for RespawnPlugin {
fn build(&self, app: &mut App) {
app.add_event::<PerformRespawnEvent>()
- .add_system(perform_respawn);
+ .add_system(perform_respawn.before(handle_send_packet_event));
}
}
pub fn perform_respawn(
mut events: EventReader<PerformRespawnEvent>,
- mut query: Query<&mut LocalPlayer>,
+ mut send_packets: EventWriter<SendPacketEvent>,
) {
for event in events.iter() {
- if let Ok(local_player) = query.get_mut(event.entity) {
- local_player.write_packet(
- ServerboundClientCommandPacket {
- action: serverbound_client_command_packet::Action::PerformRespawn,
- }
- .get(),
- );
- }
+ send_packets.send(SendPacketEvent {
+ entity: event.entity,
+ packet: ServerboundClientCommandPacket {
+ action: serverbound_client_command_packet::Action::PerformRespawn,
+ }
+ .get(),
+ });
}
}