Update to Bevy 0.11 (#94)

* update to bevy 0.11

* clippy

---------

Co-authored-by: mat <git@matdoes.dev>
This commit is contained in:
mat 2023-07-09 19:11:29 -05:00 committed by GitHub
parent ea8a8fccb6
commit d1afd02aa8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 588 additions and 545 deletions

507
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -11,23 +11,23 @@ version = "0.7.0"
[dependencies]
azalea-buf = { path = "../azalea-buf", version = "^0.7.0" }
azalea-crypto = { path = "../azalea-crypto", version = "^0.7.0" }
base64 = "0.21.0"
chrono = { version = "0.4.24", default-features = false, features = ["serde"] }
log = "0.4.17"
base64 = "0.21.2"
chrono = { version = "0.4.26", default-features = false, features = ["serde"] }
log = "0.4.19"
num-bigint = "0.4.3"
once_cell = "1.17.1"
once_cell = "1.18.0"
parking_lot = "0.12.1"
reqwest = { version = "0.11.16", default-features = false, features = [
reqwest = { version = "0.11.18", default-features = false, features = [
"json",
"rustls-tls",
] }
rsa = "0.9.2"
serde = { version = "1.0.159", features = ["derive"] }
serde_json = "1.0.95"
thiserror = "1.0.40"
tokio = { version = "1.27.0", features = ["fs"] }
uuid = { version = "1.3.0", features = ["serde"] }
serde = { version = "1.0.170", features = ["derive"] }
serde_json = "1.0.100"
thiserror = "1.0.43"
tokio = { version = "1.29.1", features = ["fs"] }
uuid = { version = "1.4.0", features = ["serde"] }
[dev-dependencies]
env_logger = "0.10.0"
tokio = { version = "1.27.0", features = ["full"] }
tokio = { version = "1.29.1", features = ["full"] }

View file

@ -12,6 +12,6 @@ proc-macro = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
proc-macro2 = "1.0.39"
quote = "1.0.18"
syn = "1.0.95"
proc-macro2 = "1.0.64"
quote = "1.0.29"
syn = "2.0.25"

View file

@ -109,7 +109,7 @@ impl Parse for PropertyType {
} else {
let content;
braced!(content in input);
let variants = content.parse_terminated(Ident::parse)?;
let variants = content.parse_terminated(Ident::parse, Token![,])?;
Ok(Self::Enum {
type_name: keyword,
variants,
@ -172,8 +172,8 @@ impl Parse for BlockDefinition {
let mut properties_and_defaults = Vec::new();
// read the things comma-separated
let property_and_default_punctuated: Punctuated<PropertyWithNameAndDefault, Token![,]> =
content.parse_terminated(PropertyWithNameAndDefault::parse)?;
let property_and_default_punctuated =
content.parse_terminated(PropertyWithNameAndDefault::parse, Token![,])?;
for property_and_default in property_and_default_punctuated {
properties_and_defaults.push(property_and_default);
@ -191,8 +191,8 @@ impl Parse for BlockDefinitions {
fn parse(input: ParseStream) -> Result<Self> {
let mut blocks = Vec::new();
let block_definitions_punctuated: Punctuated<BlockDefinition, Token![,]> =
input.parse_terminated(BlockDefinition::parse)?;
let block_definitions_punctuated =
input.parse_terminated(BlockDefinition::parse, Token![,])?;
for block_definition in block_definitions_punctuated {
blocks.push(block_definition);
}

View file

@ -105,7 +105,7 @@ impl<S> CommandDispatcher<S> {
let parse = self
.parse_nodes(redirect, &reader, child_context)
.expect("Parsing nodes failed");
context.with_child(Arc::new(parse.context));
context.with_child(Rc::new(parse.context));
return Ok(ParseResults {
context,
reader: parse.reader,

View file

@ -16,7 +16,7 @@ pub struct CommandContext<S> {
pub root_node: Arc<RwLock<CommandNode<S>>>,
pub nodes: Vec<ParsedCommandNode<S>>,
pub range: StringRange,
pub child: Option<Arc<CommandContext<S>>>,
pub child: Option<Rc<CommandContext<S>>>,
pub modifier: Option<Arc<RedirectModifier<S>>>,
pub forks: bool,
}

View file

@ -9,7 +9,7 @@ use crate::{
modifier::RedirectModifier,
tree::{Command, CommandNode},
};
use std::{collections::HashMap, fmt::Debug, sync::Arc};
use std::{collections::HashMap, fmt::Debug, rc::Rc, sync::Arc};
pub struct CommandContextBuilder<'a, S> {
pub arguments: HashMap<String, ParsedArgument>,
@ -18,7 +18,7 @@ pub struct CommandContextBuilder<'a, S> {
pub dispatcher: &'a CommandDispatcher<S>,
pub source: Arc<S>,
pub command: Command<S>,
pub child: Option<Arc<CommandContextBuilder<'a, S>>>,
pub child: Option<Rc<CommandContextBuilder<'a, S>>>,
pub range: StringRange,
pub modifier: Option<Arc<RedirectModifier<S>>>,
pub forks: bool,
@ -66,7 +66,7 @@ impl<'a, S> CommandContextBuilder<'a, S> {
self.command = command.clone();
self
}
pub fn with_child(&mut self, child: Arc<CommandContextBuilder<'a, S>>) -> &Self {
pub fn with_child(&mut self, child: Rc<CommandContextBuilder<'a, S>>) -> &Self {
self.child = Some(child);
self
}
@ -92,7 +92,7 @@ impl<'a, S> CommandContextBuilder<'a, S> {
nodes: self.nodes.clone(),
source: self.source.clone(),
command: self.command.clone(),
child: self.child.clone().map(|c| Arc::new(c.build(input))),
child: self.child.clone().map(|c| Rc::new(c.build(input))),
range: self.range.clone(),
forks: self.forks,
modifier: self.modifier.clone(),

View file

@ -11,10 +11,10 @@ version = "0.7.0"
[dependencies]
azalea-buf-macros = { path = "./azalea-buf-macros", version = "^0.7.0" }
byteorder = "^1.4.3"
log = "0.4.17"
log = "0.4.19"
serde_json = { version = "^1.0", optional = true }
thiserror = "1.0.37"
uuid = "^1.1.2"
thiserror = "1.0.43"
uuid = "^1.4.0"
[features]
serde_json = ["dep:serde_json"]

View file

@ -11,6 +11,6 @@ proc-macro = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
proc-macro2 = "^1.0.36"
quote = "^1.0.10"
syn = { version = "^1.0.82", features = ["extra-traits"] }
proc-macro2 = "^1.0.64"
quote = "^1.0.29"
syn = { version = "^2.0.25", features = ["extra-traits"] }

View file

@ -13,7 +13,7 @@ fn read_named_fields(
// if it's a string, use buf.write_string
match field_type {
syn::Type::Path(_) | syn::Type::Array(_) => {
if f.attrs.iter().any(|a| a.path.is_ident("var")) {
if f.attrs.iter().any(|a| a.path().is_ident("var")) {
quote! {
let #field_name = azalea_buf::McBufVarReadable::var_read_from(buf)?;
}
@ -98,7 +98,7 @@ pub fn create_impl_mcbufreadable(ident: &Ident, data: &Data) -> proc_macro2::Tok
syn::Fields::Unnamed(fields) => {
let mut reader_code = quote! {};
for f in &fields.unnamed {
if f.attrs.iter().any(|attr| attr.path.is_ident("var")) {
if f.attrs.iter().any(|attr| attr.path().is_ident("var")) {
reader_code.extend(quote! {
Self::#variant_name(azalea_buf::McBufVarReadable::var_read_from(buf)?),
});

View file

@ -17,7 +17,7 @@ fn write_named_fields(
// if it's a string, use buf.write_string
match field_type {
syn::Type::Path(_) | syn::Type::Array(_) => {
if f.attrs.iter().any(|attr| attr.path.is_ident("var")) {
if f.attrs.iter().any(|attr| attr.path().is_ident("var")) {
quote! {
azalea_buf::McBufVarWritable::var_write_into(#ident_dot_field, buf)?;
}
@ -133,7 +133,7 @@ pub fn create_impl_mcbufwritable(ident: &Ident, data: &Data) -> proc_macro2::Tok
for (i, f) in fields.unnamed.iter().enumerate() {
let param_ident = Ident::new(&format!("data{i}"), Span::call_site());
params_code.extend(quote! { #param_ident, });
if f.attrs.iter().any(|attr| attr.path.is_ident("var")) {
if f.attrs.iter().any(|attr| attr.path().is_ident("var")) {
writers_code.extend(quote! {
azalea_buf::McBufVarWritable::var_write_into(#param_ident, buf)?;
});

View file

@ -16,7 +16,7 @@ azalea-buf = { path = "../azalea-buf", features = [
"serde_json",
], version = "^0.7.0", optional = true }
azalea-language = { path = "../azalea-language", version = "^0.7.0" }
log = "0.4.17"
once_cell = "1.16.0"
log = "0.4.19"
once_cell = "1.18.0"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0.93"
serde_json = "^1.0.100"

View file

@ -128,7 +128,7 @@ impl IntoIterator for FormattedText {
let mut v: Vec<FormattedText> = Vec::with_capacity(siblings.len() + 1);
v.push(self);
for sibling in siblings {
v.extend(sibling.into_iter());
v.extend(sibling);
}
v.into_iter()

View file

@ -9,9 +9,9 @@ version = "0.7.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
reqwest = { version = "0.11.12", default-features = false }
anyhow = "1.0.59"
async-trait = "0.1.58"
reqwest = { version = "0.11.18", default-features = false }
anyhow = "1.0.71"
async-trait = "0.1.71"
azalea-auth = { path = "../azalea-auth", version = "0.7.0" }
azalea-block = { path = "../azalea-block", version = "0.7.0" }
azalea-nbt = { path = "../azalea-nbt", version = "0.7.0" }
@ -22,22 +22,22 @@ 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"
bevy_app = "0.11.0"
bevy_ecs = "0.11.0"
bevy_log = "0.11.0"
bevy_tasks = "0.11.0"
bevy_time = "0.11.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"
futures = "0.3.28"
log = "0.4.19"
nohash-hasher = "0.2.0"
once_cell = "1.16.0"
once_cell = "1.18.0"
parking_lot = { version = "^0.12.1", features = ["deadlock_detection"] }
regex = "1.7.0"
thiserror = "^1.0.34"
tokio = { version = "^1.24.2", features = ["sync"] }
uuid = "^1.1.2"
regex = "1.9.1"
thiserror = "^1.0.43"
tokio = { version = "^1.29.1", features = ["sync"] }
uuid = "^1.4.0"
[features]
default = ["log"]

View file

@ -7,11 +7,12 @@ use azalea_protocol::packets::game::{
serverbound_chat_command_packet::ServerboundChatCommandPacket,
serverbound_chat_packet::{LastSeenMessagesUpdate, ServerboundChatPacket},
};
use bevy_app::{App, Plugin};
use bevy_app::{App, Plugin, Update};
use bevy_ecs::{
entity::Entity,
event::{EventReader, EventWriter},
schedule::{IntoSystemConfig, IntoSystemConfigs},
prelude::Event,
schedule::IntoSystemConfigs,
};
use std::{
sync::Arc,
@ -170,6 +171,7 @@ impl Plugin for ChatPlugin {
.add_event::<SendChatKindEvent>()
.add_event::<ChatReceivedEvent>()
.add_systems(
Update,
(
handle_send_chat_event,
handle_send_chat_kind_event.after(handle_send_packet_event),
@ -180,13 +182,14 @@ impl Plugin for ChatPlugin {
}
/// A client received a chat message packet.
#[derive(Debug, Clone)]
#[derive(Event, Debug, Clone)]
pub struct ChatReceivedEvent {
pub entity: Entity,
pub packet: ChatPacket,
}
/// Send a chat message (or command, if it starts with a slash) to the server.
#[derive(Event)]
pub struct SendChatEvent {
pub entity: Entity,
pub content: String,
@ -222,6 +225,7 @@ fn handle_send_chat_event(
///
/// If you're wondering why this isn't two separate events, it's so ordering is
/// preserved if multiple chat messages and commands are sent at the same time.
#[derive(Event)]
pub struct SendChatKindEvent {
pub entity: Entity,
pub content: String,

View file

@ -45,13 +45,12 @@ use azalea_world::{
entity::{EntityPlugin, EntityUpdateSet, Local, Position, WorldName},
Instance, InstanceContainer, PartialInstance,
};
use bevy_app::{App, CoreSchedule, IntoSystemAppConfig, Plugin, PluginGroup, PluginGroupBuilder};
use bevy_app::{App, FixedUpdate, Main, Plugin, PluginGroup, PluginGroupBuilder, Update};
use bevy_ecs::{
bundle::Bundle,
component::Component,
entity::Entity,
schedule::IntoSystemConfig,
schedule::{LogLevel, ScheduleBuildSettings, ScheduleLabel},
schedule::{IntoSystemConfigs, LogLevel, ScheduleBuildSettings, ScheduleLabel},
system::{ResMut, Resource},
world::World,
};
@ -568,20 +567,20 @@ pub struct AzaleaPlugin;
impl Plugin for AzaleaPlugin {
fn build(&self, app: &mut App) {
// Minecraft ticks happen every 50ms
app.insert_resource(FixedTime::new(Duration::from_millis(50)));
app.add_system(update_in_loaded_chunk.after(PhysicsSet));
// fire the Death event when the player dies.
app.add_system(death_event);
// add GameProfileComponent when we get an AddPlayerEvent
app.add_system(retroactively_add_game_profile_component.after(EntityUpdateSet::Index));
app.add_event::<SendPacketEvent>()
.add_system(handle_send_packet_event);
app.init_resource::<InstanceContainer>();
app.insert_resource(FixedTime::new(Duration::from_millis(50)))
.add_systems(
Update,
(
update_in_loaded_chunk.after(PhysicsSet),
// fire the Death event when the player dies.
death_event,
// add GameProfileComponent when we get an AddPlayerEvent
retroactively_add_game_profile_component.after(EntityUpdateSet::Index),
handle_send_packet_event,
),
)
.add_event::<SendPacketEvent>()
.init_resource::<InstanceContainer>();
}
}
@ -591,19 +590,17 @@ impl Plugin for AzaleaPlugin {
/// [`DefaultPlugins`].
#[doc(hidden)]
pub fn start_ecs(
mut app: App,
app: App,
run_schedule_receiver: mpsc::UnboundedReceiver<()>,
run_schedule_sender: mpsc::UnboundedSender<()>,
) -> Arc<Mutex<World>> {
app.setup();
// all resources should have been added by now so we can take the ecs from the
// app
let ecs = Arc::new(Mutex::new(app.world));
tokio::spawn(run_schedule_loop(
ecs.clone(),
app.outer_schedule_label,
app.main_schedule_label,
run_schedule_receiver,
));
tokio::spawn(tick_run_schedule_loop(run_schedule_sender));
@ -620,7 +617,7 @@ async fn run_schedule_loop(
// whenever we get an event from run_schedule_receiver, run the schedule
run_schedule_receiver.recv().await;
let mut ecs = ecs.lock();
ecs.run_schedule_ref(&*outer_schedule_label);
ecs.run_schedule(&outer_schedule_label);
ecs.clear_trackers();
}
}
@ -671,14 +668,14 @@ pub struct TickBroadcastPlugin;
impl Plugin for TickBroadcastPlugin {
fn build(&self, app: &mut App) {
app.insert_resource(TickBroadcast(broadcast::channel(1).0))
.add_system(send_tick_broadcast.in_schedule(CoreSchedule::FixedUpdate));
.add_systems(FixedUpdate, send_tick_broadcast);
}
}
pub struct AmbiguityLoggerPlugin;
impl Plugin for AmbiguityLoggerPlugin {
fn build(&self, app: &mut App) {
app.edit_schedule(CoreSchedule::Main, |schedule| {
app.edit_schedule(Main, |schedule| {
schedule.set_build_settings(ScheduleBuildSettings {
ambiguity_detection: LogLevel::Warn,
..Default::default()

View file

@ -1,10 +1,11 @@
//! Disconnect a client from the server.
use bevy_app::{App, CoreSet, Plugin};
use bevy_app::{App, Plugin, PostUpdate};
use bevy_ecs::{
component::Component,
entity::Entity,
event::{EventReader, EventWriter},
prelude::Event,
query::Changed,
schedule::IntoSystemConfigs,
system::{Commands, Query},
@ -17,18 +18,19 @@ pub struct DisconnectPlugin;
impl Plugin for DisconnectPlugin {
fn build(&self, app: &mut App) {
app.add_event::<DisconnectEvent>().add_systems(
PostUpdate,
(
update_read_packets_task_running_component,
disconnect_on_read_packets_ended,
remove_components_from_disconnected_players,
)
.in_base_set(CoreSet::PostUpdate)
.chain(),
);
}
}
/// An event sent when a client is getting disconnected.
#[derive(Event)]
pub struct DisconnectEvent {
pub entity: Entity,
}

View file

@ -7,7 +7,7 @@ use azalea_protocol::packets::game::{
clientbound_player_combat_kill_packet::ClientboundPlayerCombatKillPacket, ClientboundGamePacket,
};
use azalea_world::entity::MinecraftEntityId;
use bevy_app::{App, CoreSchedule, IntoSystemAppConfig, Plugin};
use bevy_app::{App, FixedUpdate, Plugin, Update};
use bevy_ecs::{component::Component, event::EventReader, query::Added, system::Query};
use derive_more::{Deref, DerefMut};
use tokio::sync::mpsc;
@ -100,16 +100,21 @@ pub struct LocalPlayerEvents(pub mpsc::UnboundedSender<Event>);
pub struct EventPlugin;
impl Plugin for EventPlugin {
fn build(&self, app: &mut App) {
app.add_system(chat_listener)
.add_system(login_listener)
.add_system(init_listener)
.add_system(packet_listener)
.add_system(add_player_listener)
.add_system(update_player_listener)
.add_system(remove_player_listener)
.add_system(death_listener)
.add_system(keepalive_listener)
.add_system(tick_listener.in_schedule(CoreSchedule::FixedUpdate));
app.add_systems(
Update,
(
chat_listener,
login_listener,
init_listener,
packet_listener,
add_player_listener,
update_player_listener,
remove_player_listener,
death_listener,
keepalive_listener,
),
)
.add_systems(FixedUpdate, tick_listener);
}
}

View file

@ -11,12 +11,13 @@ use azalea_world::{
entity::{clamp_look_direction, view_vector, EyeHeight, LookDirection, Position, WorldName},
Instance, InstanceContainer,
};
use bevy_app::{App, Plugin};
use bevy_app::{App, Plugin, Update};
use bevy_ecs::{
component::Component,
entity::Entity,
event::EventReader,
schedule::{IntoSystemConfig, IntoSystemConfigs},
prelude::Event,
schedule::IntoSystemConfigs,
system::{Commands, Query, Res},
};
use derive_more::{Deref, DerefMut};
@ -33,6 +34,7 @@ pub struct InteractPlugin;
impl Plugin for InteractPlugin {
fn build(&self, app: &mut App) {
app.add_event::<BlockInteractEvent>().add_systems(
Update,
(
update_hit_result_component.after(clamp_look_direction),
handle_block_interact_event,
@ -61,6 +63,7 @@ impl Client {
/// Right click a block. The behavior of this depends on the target block,
/// and it'll either place the block you're holding in your hand or use the
/// block you clicked (like toggling a lever).
#[derive(Event)]
pub struct BlockInteractEvent {
/// The local player entity that's opening the container.
pub entity: Entity,

View file

@ -14,13 +14,13 @@ use azalea_protocol::packets::game::{
serverbound_container_close_packet::ServerboundContainerClosePacket,
};
use azalea_registry::MenuKind;
use bevy_app::{App, Plugin};
use bevy_app::{App, Plugin, Update};
use bevy_ecs::{
component::Component,
entity::Entity,
event::EventReader,
prelude::EventWriter,
schedule::{IntoSystemConfig, IntoSystemConfigs},
prelude::{Event, EventWriter},
schedule::IntoSystemConfigs,
system::Query,
};
use log::warn;
@ -36,6 +36,7 @@ impl Plugin for InventoryPlugin {
.add_event::<ContainerClickEvent>()
.add_event::<SetContainerContentEvent>()
.add_systems(
Update,
(
handle_menu_opened_event,
handle_set_container_content_event,
@ -563,7 +564,7 @@ impl Default for InventoryComponent {
/// Sent from the server when a menu (like a chest or crafting table) was
/// opened by the client.
#[derive(Debug)]
#[derive(Event, Debug)]
pub struct MenuOpenedEvent {
pub entity: Entity,
pub window_id: u32,
@ -585,6 +586,7 @@ fn handle_menu_opened_event(
///
/// Note that this is also sent when the client closes its own inventory, even
/// though there is no packet for opening its inventory.
#[derive(Event)]
pub struct CloseContainerEvent {
pub entity: Entity,
/// The ID of the container to close. 0 for the player's inventory. If this
@ -621,6 +623,7 @@ fn handle_container_close_event(
/// Close a container without notifying the server.
///
/// Note that this also gets fired when we get a [`CloseContainerEvent`].
#[derive(Event)]
pub struct ClientSideCloseContainerEvent {
pub entity: Entity,
}
@ -635,7 +638,7 @@ pub fn handle_client_side_close_container_event(
}
}
#[derive(Debug)]
#[derive(Event, Debug)]
pub struct ContainerClickEvent {
pub entity: Entity,
pub window_id: u8,
@ -687,6 +690,7 @@ pub fn handle_container_click_event(
/// Sent from the server when the contents of a container are replaced. Usually
/// triggered by the `ContainerSetContent` packet.
#[derive(Event)]
pub struct SetContainerContentEvent {
pub entity: Entity,
pub slots: Vec<ItemSlot>,

View file

@ -11,6 +11,7 @@ use bevy_ecs::{
component::Component,
entity::Entity,
event::EventReader,
prelude::Event,
query::Added,
system::{Query, Res},
};
@ -20,7 +21,7 @@ use thiserror::Error;
use tokio::{sync::mpsc, task::JoinHandle};
use crate::{
events::{Event, LocalPlayerEvents},
events::{Event as AzaleaEvent, LocalPlayerEvents},
ClientInformation, WalkDirection,
};
@ -155,7 +156,7 @@ pub fn update_in_loaded_chunk(
/// Send the "Death" event for [`LocalPlayer`]s that died with no reason.
pub fn death_event(query: Query<&LocalPlayerEvents, Added<Dead>>) {
for local_player_events in &query {
local_player_events.send(Event::Death(None)).unwrap();
local_player_events.send(AzaleaEvent::Death(None)).unwrap();
}
}
@ -168,7 +169,7 @@ pub enum HandlePacketError {
#[error(transparent)]
Other(#[from] anyhow::Error),
#[error("{0}")]
Send(#[from] mpsc::error::SendError<Event>),
Send(#[from] mpsc::error::SendError<AzaleaEvent>),
}
impl<T> From<std::sync::PoisonError<T>> for HandlePacketError {
@ -178,6 +179,7 @@ impl<T> From<std::sync::PoisonError<T>> for HandlePacketError {
}
/// Event for sending a packet to the server.
#[derive(Event)]
pub struct SendPacketEvent {
pub entity: Entity,
pub packet: ServerboundGamePacket,

View file

@ -1,5 +1,5 @@
use azalea_core::BlockPos;
use bevy_app::{App, Plugin};
use bevy_app::{App, Plugin, Update};
use bevy_ecs::prelude::*;
use crate::Client;
@ -9,7 +9,7 @@ pub struct MinePlugin;
impl Plugin for MinePlugin {
fn build(&self, app: &mut App) {
app.add_event::<StartMiningBlockEvent>()
.add_system(handle_start_mining_block_event);
.add_systems(Update, handle_start_mining_block_event);
}
}
@ -23,6 +23,7 @@ impl Client {
}
}
#[derive(Event)]
pub struct StartMiningBlockEvent {
pub entity: Entity,
pub position: BlockPos,

View file

@ -14,14 +14,11 @@ use azalea_world::{
entity::{self, metadata::Sprinting, Attributes, Jumping, MinecraftEntityId},
MoveEntityError,
};
use bevy_app::{App, CoreSchedule, IntoSystemAppConfigs, Plugin};
use bevy_app::{App, FixedUpdate, Plugin, Update};
use bevy_ecs::prelude::Event;
use bevy_ecs::{
component::Component,
entity::Entity,
event::EventReader,
query::With,
schedule::{IntoSystemConfig, IntoSystemConfigs},
system::Query,
component::Component, entity::Entity, event::EventReader, query::With,
schedule::IntoSystemConfigs, system::Query,
};
use std::backtrace::Backtrace;
use thiserror::Error;
@ -51,17 +48,18 @@ impl Plugin for PlayerMovePlugin {
app.add_event::<StartWalkEvent>()
.add_event::<StartSprintEvent>()
.add_systems(
Update,
(sprint_listener, walk_listener)
.chain()
.before(force_jump_listener),
)
.add_systems(
FixedUpdate,
(
local_player_ai_step.in_set(PhysicsSet),
send_position.after(update_in_loaded_chunk),
)
.chain()
.in_schedule(CoreSchedule::FixedUpdate),
.chain(),
);
}
}
@ -379,6 +377,7 @@ impl Client {
/// An event sent when the client starts walking. This does not get sent for
/// non-local entities.
#[derive(Event)]
pub struct StartWalkEvent {
pub entity: Entity,
pub direction: WalkDirection,
@ -402,6 +401,7 @@ pub fn walk_listener(
/// An event sent when the client starts sprinting. This does not get sent for
/// non-local entities.
#[derive(Event)]
pub struct StartSprintEvent {
pub entity: Entity,
pub direction: SprintDirection,

View file

@ -24,12 +24,13 @@ use azalea_world::{
entity::{LoadedBy, RelativeEntityUpdate},
InstanceContainer, PartialInstance,
};
use bevy_app::{App, CoreSet, Plugin};
use bevy_app::{App, First, Plugin, PreUpdate};
use bevy_ecs::{
component::Component,
entity::Entity,
event::{EventReader, EventWriter, Events},
schedule::IntoSystemConfig,
prelude::Event,
schedule::IntoSystemConfigs,
system::{Commands, Query, ResMut, SystemState},
world::World,
};
@ -69,7 +70,7 @@ use crate::{
/// }
/// }
/// ```
#[derive(Debug, Clone)]
#[derive(Event, Debug, Clone)]
pub struct PacketEvent {
/// The client entity that received the packet.
pub entity: Entity,
@ -81,10 +82,10 @@ pub struct PacketHandlerPlugin;
impl Plugin for PacketHandlerPlugin {
fn build(&self, app: &mut App) {
app.add_system(send_packet_events.in_base_set(CoreSet::First))
.add_system(
app.add_systems(First, send_packet_events)
.add_systems(
PreUpdate,
process_packet_events
.in_base_set(CoreSet::PreUpdate)
// we want to index and deindex right after
.before(EntityUpdateSet::Deindex),
)
@ -100,7 +101,7 @@ impl Plugin for PacketHandlerPlugin {
/// A player joined the game (or more specifically, was added to the tab
/// list of a local player).
#[derive(Debug, Clone)]
#[derive(Event, Debug, Clone)]
pub struct AddPlayerEvent {
/// The local player entity that received this event.
pub entity: Entity,
@ -108,7 +109,7 @@ pub struct AddPlayerEvent {
}
/// A player left the game (or maybe is still in the game and was just
/// removed from the tab list of a local player).
#[derive(Debug, Clone)]
#[derive(Event, Debug, Clone)]
pub struct RemovePlayerEvent {
/// The local player entity that received this event.
pub entity: Entity,
@ -116,7 +117,7 @@ pub struct RemovePlayerEvent {
}
/// A player was updated in the tab list of a local player (gamemode, display
/// name, or latency changed).
#[derive(Debug, Clone)]
#[derive(Event, Debug, Clone)]
pub struct UpdatePlayerEvent {
/// The local player entity that received this event.
pub entity: Entity,
@ -126,7 +127,7 @@ 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
/// be included.
#[derive(Debug, Clone)]
#[derive(Event, Debug, Clone)]
pub struct DeathEvent {
pub entity: Entity,
pub packet: Option<ClientboundPlayerCombatKillPacket>,
@ -134,7 +135,7 @@ pub struct DeathEvent {
/// A KeepAlive packet is sent from the server to verify that the client is
/// still connected.
#[derive(Debug, Clone)]
#[derive(Event, Debug, Clone)]
pub struct KeepAliveEvent {
pub entity: Entity,
/// The ID of the keepalive. This is an arbitrary number, but vanilla
@ -143,7 +144,7 @@ pub struct KeepAliveEvent {
}
/// Something that receives packets from the server.
#[derive(Component, Clone)]
#[derive(Event, Component, Clone)]
pub struct PacketReceiver {
pub packets: Arc<Mutex<Vec<ClientboundGamePacket>>>,
pub run_schedule_sender: mpsc::UnboundedSender<()>,

View file

@ -1,13 +1,13 @@
use azalea_protocol::packets::game::serverbound_client_command_packet::{
self, ServerboundClientCommandPacket,
};
use bevy_app::{App, Plugin};
use bevy_app::{App, Plugin, Update};
use bevy_ecs::prelude::*;
use crate::local_player::{handle_send_packet_event, SendPacketEvent};
/// Tell the server that we're respawning.
#[derive(Debug, Clone)]
#[derive(Event, Debug, Clone)]
pub struct PerformRespawnEvent {
pub entity: Entity,
}
@ -17,7 +17,7 @@ pub struct RespawnPlugin;
impl Plugin for RespawnPlugin {
fn build(&self, app: &mut App) {
app.add_event::<PerformRespawnEvent>()
.add_system(perform_respawn.before(handle_send_packet_event));
.add_systems(Update, perform_respawn.before(handle_send_packet_event));
}
}

View file

@ -2,11 +2,8 @@
use std::marker::PhantomData;
use bevy_app::{App, CoreSet, Plugin};
use bevy_ecs::{
schedule::IntoSystemConfig,
system::{NonSend, Resource},
};
use bevy_app::{App, Last, Plugin};
use bevy_ecs::system::{NonSend, Resource};
use bevy_tasks::{
tick_global_task_pools_on_main_thread, AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool,
TaskPoolBuilder,
@ -27,7 +24,7 @@ impl Plugin for TaskPoolPlugin {
self.task_pool_options.create_default_pools();
#[cfg(not(target_arch = "wasm32"))]
app.add_system(tick_global_task_pools.in_base_set(CoreSet::Last));
app.add_systems(Last, tick_global_task_pools);
}
}

View file

@ -14,10 +14,10 @@ azalea-chat = { path = "../azalea-chat", version = "^0.7.0" }
azalea-inventory = { version = "0.7.0", path = "../azalea-inventory" }
azalea-nbt = { path = "../azalea-nbt", version = "^0.7.0" }
azalea-registry = { path = "../azalea-registry", version = "^0.7.0" }
bevy_ecs = { version = "0.10.0", default-features = false, optional = true }
bevy_ecs = { version = "0.11.0", default-features = false, optional = true }
num-traits = "0.2.15"
serde = { version = "^1.0", optional = true }
uuid = "^1.1.2"
uuid = "^1.4.0"
[features]
bevy_ecs = ["dep:bevy_ecs"]

View file

@ -9,19 +9,19 @@ repository = "https://github.com/mat-1/azalea/tree/main/azalea-crypto"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
aes = "0.8.1"
aes = "0.8.3"
azalea-buf = { path = "../azalea-buf", version = "^0.7.0" }
cfb8 = "0.8.1"
num-bigint = "^0.4.3"
rand = { version = "^0.8.4", features = ["getrandom"] }
rand = { version = "^0.8.5", features = ["getrandom"] }
rsa = { version = "0.9.2", features = ["sha2"] }
rsa_public_encrypt_pkcs1 = "0.4.0"
sha-1 = "^0.10.0"
sha2 = "0.10.6"
uuid = "^1.1.2"
sha-1 = "^0.10.1"
sha2 = "0.10.7"
uuid = "^1.4.0"
[dev-dependencies]
criterion = { version = "^0.4.0", features = ["html_reports"] }
criterion = { version = "^0.5.1", features = ["html_reports"] }
[[bench]]
harness = false

View file

@ -12,6 +12,6 @@ proc-macro = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
proc-macro2 = "1.0.47"
quote = "1.0.21"
syn = "1.0.104"
proc-macro2 = "1.0.64"
quote = "1.0.29"
syn = "2.0.25"

View file

@ -39,7 +39,7 @@ impl Parse for Menu {
let content;
braced!(content in input);
let fields = content
.parse_terminated::<Field, Token![,]>(Field::parse)?
.parse_terminated(Field::parse, Token![,])?
.into_iter()
.collect();
@ -61,7 +61,7 @@ pub struct DeclareMenus {
impl Parse for DeclareMenus {
fn parse(input: ParseStream) -> Result<Self> {
let menus = input
.parse_terminated::<Menu, Token![,]>(Menu::parse)?
.parse_terminated(Menu::parse, Token![,])?
.into_iter()
.collect();
Ok(Self { menus })

View file

@ -9,7 +9,7 @@ version = "0.7.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
once_cell = "1.16.0"
once_cell = "1.18.0"
serde = "^1.0"
serde_json = "^1.0.93"
serde_json = "^1.0.100"
# tokio = {version = "^1.21.2", features = ["fs"]}

View file

@ -11,18 +11,18 @@ repository = "https://github.com/mat-1/azalea/tree/main/azalea-nbt"
[dependencies]
azalea-buf = { path = "../azalea-buf", version = "^0.7.0" }
byteorder = "^1.4.3"
compact_str = { version = "0.7.0", features = ["serde"] }
enum-as-inner = "0.5.1"
flate2 = "^1.0.25"
log = "0.4.17"
compact_str = { version = "0.7.1", features = ["serde"] }
enum-as-inner = "0.6.0"
flate2 = "^1.0.26"
log = "0.4.19"
packed_simd_2 = "0.3.8"
serde = { version = "^1.0", features = ["derive"], optional = true }
[dev-dependencies]
criterion = { version = "^0.4.0", features = ["html_reports"] }
criterion = { version = "^0.5.1", features = ["html_reports"] }
graphite_binary = "0.1.0"
valence_nbt = "0.4.0"
fastnbt = "2.4.3"
fastnbt = "2.4.4"
[features]
default = []

View file

@ -14,11 +14,11 @@ azalea-core = { path = "../azalea-core", version = "^0.7.0" }
azalea-inventory = { version = "0.7.0", path = "../azalea-inventory" }
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"
once_cell = "1.16.0"
bevy_app = "0.11.0"
bevy_ecs = "0.11.0"
once_cell = "1.18.0"
parking_lot = "^0.12.1"
[dev-dependencies]
bevy_time = "0.10.0"
uuid = "^1.1.2"
bevy_time = "0.11.0"
uuid = "^1.4.0"

View file

@ -13,12 +13,13 @@ use azalea_world::{
},
Instance, InstanceContainer,
};
use bevy_app::{App, CoreSchedule, IntoSystemAppConfigs, Plugin};
use bevy_app::{App, FixedUpdate, Plugin, Update};
use bevy_ecs::{
entity::Entity,
event::{EventReader, EventWriter},
prelude::Event,
query::With,
schedule::{IntoSystemConfig, IntoSystemConfigs, SystemSet},
schedule::{IntoSystemConfigs, SystemSet},
system::{Query, Res},
};
use collision::{move_colliding, MoverType};
@ -31,17 +32,13 @@ pub struct PhysicsPlugin;
impl Plugin for PhysicsPlugin {
fn build(&self, app: &mut App) {
app.add_event::<ForceJumpEvent>()
.add_system(
.add_systems(
Update,
force_jump_listener
.before(azalea_world::entity::update_bounding_box)
.after(clamp_look_direction),
)
.add_systems(
(ai_step, travel)
.chain()
.in_set(PhysicsSet)
.in_schedule(CoreSchedule::FixedUpdate),
);
.add_systems(FixedUpdate, (ai_step, travel).chain().in_set(PhysicsSet));
}
}
@ -170,6 +167,7 @@ pub fn ai_step(
}
/// Jump even if we aren't on the ground.
#[derive(Event)]
pub struct ForceJumpEvent(pub Entity);
pub fn force_jump_listener(
@ -340,8 +338,7 @@ mod tests {
/// You need an app to spawn entities in the world and do updates.
fn make_test_app() -> App {
let mut app = App::new();
app.add_plugin(PhysicsPlugin)
.add_plugin(EntityPlugin)
app.add_plugins((PhysicsPlugin, EntityPlugin))
.insert_resource(FixedTime::new(Duration::from_millis(50)))
.init_resource::<InstanceContainer>();
app
@ -378,7 +375,7 @@ mod tests {
// y should start at 70
assert_eq!(entity_pos.y, 70.);
}
app.world.run_schedule(CoreSchedule::FixedUpdate);
app.world.run_schedule(FixedUpdate);
app.update();
{
let entity_pos = *app.world.get::<Position>(entity).unwrap();
@ -387,7 +384,7 @@ mod tests {
let entity_physics = app.world.get::<Physics>(entity).unwrap().clone();
assert!(entity_physics.delta.y < 0.);
}
app.world.run_schedule(CoreSchedule::FixedUpdate);
app.world.run_schedule(FixedUpdate);
app.update();
{
let entity_pos = *app.world.get::<Position>(entity).unwrap();
@ -440,7 +437,7 @@ mod tests {
block_state.is_some(),
"Block state should exist, if this fails that means the chunk wasn't loaded and the block didn't get placed"
);
app.world.run_schedule(CoreSchedule::FixedUpdate);
app.world.run_schedule(FixedUpdate);
app.update();
{
let entity_pos = *app.world.get::<Position>(entity).unwrap();
@ -449,7 +446,7 @@ mod tests {
let entity_physics = app.world.get::<Physics>(entity).unwrap().clone();
assert!(entity_physics.delta.y < 0.);
}
app.world.run_schedule(CoreSchedule::FixedUpdate);
app.world.run_schedule(FixedUpdate);
app.update();
{
let entity_pos = *app.world.get::<Position>(entity).unwrap();
@ -505,7 +502,7 @@ mod tests {
);
// do a few steps so we fall on the slab
for _ in 0..20 {
app.world.run_schedule(CoreSchedule::FixedUpdate);
app.world.run_schedule(FixedUpdate);
app.update();
}
let entity_pos = app.world.get::<Position>(entity).unwrap();
@ -558,7 +555,7 @@ mod tests {
);
// do a few steps so we fall on the slab
for _ in 0..20 {
app.world.run_schedule(CoreSchedule::FixedUpdate);
app.world.run_schedule(FixedUpdate);
app.update();
}
let entity_pos = app.world.get::<Position>(entity).unwrap();
@ -615,7 +612,7 @@ mod tests {
);
// do a few steps so we fall on the wall
for _ in 0..20 {
app.world.run_schedule(CoreSchedule::FixedUpdate);
app.world.run_schedule(FixedUpdate);
app.update();
}
@ -677,7 +674,7 @@ mod tests {
);
// do a few steps so we fall on the wall
for _ in 0..20 {
app.world.run_schedule(CoreSchedule::FixedUpdate);
app.world.run_schedule(FixedUpdate);
app.update();
}

View file

@ -9,11 +9,11 @@ version = "0.7.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
async-compression = { version = "^0.3.8", features = [
async-compression = { version = "^0.4.0", features = [
"tokio",
"zlib",
], optional = true }
async-recursion = "1.0.0"
async-recursion = "1.0.4"
azalea-auth = { path = "../azalea-auth", version = "^0.7.0" }
azalea-block = { path = "../azalea-block", default-features = false, version = "^0.7.0" }
azalea-brigadier = { path = "../azalea-brigadier", version = "^0.7.0", features = [
@ -32,22 +32,22 @@ azalea-nbt = { path = "../azalea-nbt", version = "^0.7.0", features = [
azalea-protocol-macros = { path = "./azalea-protocol-macros", version = "^0.7.0" }
azalea-registry = { path = "../azalea-registry", version = "^0.7.0" }
azalea-world = { path = "../azalea-world", version = "^0.7.0" }
bevy_ecs = { version = "0.10.0", default-features = false }
bevy_ecs = { version = "0.11.0", default-features = false }
byteorder = "^1.4.3"
bytes = "^1.1.0"
flate2 = "1.0.25"
futures = "0.3.24"
futures-util = "0.3.24"
log = "0.4.17"
bytes = "^1.4.0"
flate2 = "1.0.26"
futures = "0.3.28"
futures-util = "0.3.28"
log = "0.4.19"
serde = { version = "^1.0", features = ["serde_derive"] }
serde_json = "^1.0.93"
thiserror = "1.0.37"
tokio = { version = "^1.24.2", features = ["io-util", "net", "macros"] }
tokio-util = { version = "0.7.4", features = ["codec"] }
serde_json = "^1.0.100"
thiserror = "1.0.43"
tokio = { version = "^1.29.1", features = ["io-util", "net", "macros"] }
tokio-util = { version = "0.7.8", features = ["codec"] }
trust-dns-resolver = { version = "^0.22.0", default-features = false, features = [
"tokio-runtime",
] }
uuid = "1.1.2"
uuid = "1.4.0"
[features]
connecting = []
@ -56,7 +56,7 @@ packets = ["connecting", "dep:async-compression", "dep:azalea-core"]
strict_registry = ["packets"]
[dev-dependencies]
anyhow = "^1.0.65"
tracing = "^0.1.36"
tracing-subscriber = "^0.3.15"
once_cell = "1.17.0"
anyhow = "^1.0.71"
tracing = "^0.1.37"
tracing-subscriber = "^0.3.17"
once_cell = "1.18.0"

View file

@ -11,6 +11,6 @@ proc-macro = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
proc-macro2 = "^1.0.36"
quote = "^1.0.10"
syn = "^1.0.82"
proc-macro2 = "^1.0.64"
quote = "^1.0.29"
syn = "^2.0.25"

View file

@ -142,6 +142,7 @@ mod tests {
}),
criteria: HashMap::new(),
requirements: Vec::new(),
sends_telemetry_event: false,
},
)]
.into_iter()

View file

@ -12,9 +12,9 @@ proc-macro = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
proc-macro2 = "1.0.39"
quote = "1.0.18"
syn = "1.0.95"
proc-macro2 = "1.0.64"
quote = "1.0.29"
syn = "2.0.25"
[features]
serde = []

View file

@ -43,8 +43,8 @@ impl Parse for Registry {
let name = input.parse()?;
let content;
braced!(content in input);
let items: Punctuated<RegistryItem, Token![,]> =
content.parse_terminated(RegistryItem::parse)?;
let items: Punctuated<RegistryItem, _> =
content.parse_terminated(RegistryItem::parse, Token![,])?;
Ok(Registry {
name,

View file

@ -18,16 +18,16 @@ azalea-core = { path = "../azalea-core", version = "^0.7.0", features = [
azalea-inventory = { version = "0.7.0", path = "../azalea-inventory" }
azalea-nbt = { path = "../azalea-nbt", version = "^0.7.0" }
azalea-registry = { path = "../azalea-registry", version = "^0.7.0" }
bevy_app = "0.10.0"
bevy_ecs = "0.10.0"
bevy_app = "0.11.0"
bevy_ecs = "0.11.0"
derive_more = { version = "0.99.17", features = ["deref", "deref_mut"] }
enum-as-inner = "0.5.1"
log = "0.4.17"
enum-as-inner = "0.6.0"
log = "0.4.19"
nohash-hasher = "0.2.0"
once_cell = "1.16.0"
once_cell = "1.18.0"
parking_lot = "^0.12.1"
thiserror = "1.0.34"
uuid = "1.1.2"
thiserror = "1.0.43"
uuid = "1.4.0"
[profile.release]
lto = true

View file

@ -9,12 +9,12 @@ use crate::{
update_entity_by_id_index, update_uuid_index, InstanceContainer, PartialInstance,
};
use azalea_core::ChunkPos;
use bevy_app::{App, CoreSet, Plugin};
use bevy_app::{App, Plugin, PostUpdate, PreUpdate, Update};
use bevy_ecs::{
component::Component,
entity::Entity,
query::{Added, Changed, With, Without},
schedule::{IntoSystemConfig, IntoSystemConfigs, SystemSet},
schedule::{IntoSystemConfigs, SystemSet},
system::{Commands, EntityCommand, Query, Res, ResMut, Resource},
world::{EntityMut, World},
};
@ -51,32 +51,33 @@ impl Plugin for EntityPlugin {
// added to indexes during update (done by this plugin)
// modified during update
// despawned post-update (done by this plugin)
app.add_system(
remove_despawned_entities_from_indexes
.in_base_set(CoreSet::PreUpdate)
.in_set(EntityUpdateSet::Deindex),
app.add_systems(
PreUpdate,
remove_despawned_entities_from_indexes.in_set(EntityUpdateSet::Deindex),
)
.add_systems(
(deduplicate_entities, deduplicate_local_entities)
.in_base_set(CoreSet::PostUpdate)
.in_set(EntityUpdateSet::Deduplicate),
PostUpdate,
(deduplicate_entities, deduplicate_local_entities).in_set(EntityUpdateSet::Deduplicate),
)
.add_systems(
Update,
(
update_entity_chunk_positions,
update_uuid_index,
update_entity_by_id_index,
)
.in_set(EntityUpdateSet::Index),
(
update_entity_chunk_positions,
update_uuid_index,
update_entity_by_id_index,
)
.in_set(EntityUpdateSet::Index),
(
add_updates_received,
debug_new_entity,
debug_detect_updates_received_on_local_entities,
add_dead,
update_bounding_box,
clamp_look_direction,
),
),
)
.add_systems((
add_updates_received,
debug_new_entity,
debug_detect_updates_received_on_local_entities,
add_dead,
update_bounding_box,
clamp_look_direction,
))
.init_resource::<EntityInfos>();
}
}
@ -152,7 +153,7 @@ pub struct RelativeEntityUpdate {
pub update: Box<dyn FnOnce(&mut EntityMut) + Send + Sync>,
}
impl EntityCommand for RelativeEntityUpdate {
fn write(self, entity: Entity, world: &mut World) {
fn apply(self, entity: Entity, world: &mut World) {
let partial_entity_infos = &mut self.partial_world.write().entity_infos;
let mut entity_mut = world.entity_mut(entity);

View file

@ -12,8 +12,8 @@ pre-release-replacements = [
]
[dependencies]
anyhow = "^1.0.65"
async-trait = "0.1.58"
anyhow = "^1.0.71"
async-trait = "0.1.71"
azalea-block = { version = "0.7.0", path = "../azalea-block" }
azalea-chat = { version = "0.7.0", path = "../azalea-chat" }
azalea-client = { version = "0.7.0", path = "../azalea-client" }
@ -25,21 +25,21 @@ azalea-registry = { version = "0.7.0", path = "../azalea-registry" }
azalea-world = { version = "0.7.0", path = "../azalea-world" }
azalea-auth = { version = "0.7.0", path = "../azalea-auth" }
azalea-brigadier = { version = "0.7.0", path = "../azalea-brigadier" }
bevy_app = "0.10.0"
bevy_ecs = "0.10.0"
bevy_tasks = "0.10.0"
bevy_app = "0.11.0"
bevy_ecs = "0.11.0"
bevy_tasks = "0.11.0"
derive_more = { version = "0.99.17", features = ["deref", "deref_mut"] }
futures = "0.3.25"
futures-lite = "1.12.0"
log = "0.4.17"
futures = "0.3.28"
futures-lite = "1.13.0"
log = "0.4.19"
nohash-hasher = "0.2.0"
num-traits = "0.2.15"
parking_lot = { version = "^0.12.1", features = ["deadlock_detection"] }
priority-queue = "1.3.0"
thiserror = "^1.0.37"
tokio = "^1.24.2"
uuid = "1.2.2"
bevy_log = "0.10.1"
priority-queue = "1.3.2"
thiserror = "^1.0.43"
tokio = "^1.29.1"
uuid = "1.4.0"
bevy_log = "0.11.0"
[features]
default = ["log"]

View file

@ -1,6 +1,7 @@
use crate::app::{App, Plugin};
use azalea_client::packet_handling::DeathEvent;
use azalea_client::respawn::{perform_respawn, PerformRespawnEvent};
use bevy_app::Update;
use bevy_ecs::prelude::*;
/// A plugin that makes [`DeathEvent`]s send [`PerformRespawnEvent`]s.
@ -8,7 +9,7 @@ use bevy_ecs::prelude::*;
pub struct AutoRespawnPlugin;
impl Plugin for AutoRespawnPlugin {
fn build(&self, app: &mut App) {
app.add_system(auto_respawn.before(perform_respawn));
app.add_systems(Update, auto_respawn.before(perform_respawn));
}
}

View file

@ -1,4 +1,4 @@
use crate::app::{App, CoreSchedule, IntoSystemAppConfig, Plugin, PluginGroup, PluginGroupBuilder};
use crate::app::{App, Plugin, PluginGroup, PluginGroupBuilder};
use crate::auto_respawn::AutoRespawnPlugin;
use crate::container::ContainerPlugin;
use crate::ecs::{
@ -6,13 +6,15 @@ use crate::ecs::{
entity::Entity,
event::EventReader,
query::{With, Without},
schedule::IntoSystemConfig,
system::{Commands, Query},
};
use azalea_core::Vec3;
use azalea_physics::{force_jump_listener, PhysicsSet};
use azalea_world::entity::{clamp_look_direction, EyeHeight, LookDirection};
use azalea_world::entity::{metadata::Player, Jumping, Local, Position};
use bevy_app::{FixedUpdate, Update};
use bevy_ecs::prelude::Event;
use bevy_ecs::schedule::IntoSystemConfigs;
use std::f64::consts::PI;
use crate::pathfinder::PathfinderPlugin;
@ -23,16 +25,17 @@ impl Plugin for BotPlugin {
fn build(&self, app: &mut App) {
app.add_event::<LookAtEvent>()
.add_event::<JumpEvent>()
.add_systems((
insert_bot,
look_at_listener
.before(force_jump_listener)
.before(clamp_look_direction),
jump_listener,
stop_jumping
.in_schedule(CoreSchedule::FixedUpdate)
.after(PhysicsSet),
));
.add_systems(
Update,
(
insert_bot,
look_at_listener
.before(force_jump_listener)
.before(clamp_look_direction),
jump_listener,
),
)
.add_systems(FixedUpdate, stop_jumping.after(PhysicsSet));
}
}
@ -85,6 +88,7 @@ impl BotClientExt for azalea_client::Client {
}
/// Event to jump once.
#[derive(Event)]
pub struct JumpEvent(pub Entity);
fn jump_listener(mut query: Query<(&mut Jumping, &mut Bot)>, mut events: EventReader<JumpEvent>) {
@ -97,6 +101,7 @@ fn jump_listener(mut query: Query<(&mut Jumping, &mut Bot)>, mut events: EventRe
}
/// Make an entity look towards a certain position in the world.
#[derive(Event)]
pub struct LookAtEvent {
pub entity: Entity,
/// The position we want the entity to be looking at.

View file

@ -8,14 +8,14 @@ use azalea_client::{
use azalea_core::BlockPos;
use azalea_inventory::{operations::ClickOperation, ItemSlot, Menu};
use azalea_protocol::packets::game::ClientboundGamePacket;
use bevy_app::{App, Plugin};
use bevy_app::{App, Plugin, Update};
use bevy_ecs::{component::Component, prelude::EventReader, system::Commands};
use std::fmt::Debug;
pub struct ContainerPlugin;
impl Plugin for ContainerPlugin {
fn build(&self, app: &mut App) {
app.add_system(handle_menu_opened_event);
app.add_systems(Update, handle_menu_opened_event);
}
}

View file

@ -10,7 +10,7 @@ pub mod pathfinder;
pub mod prelude;
pub mod swarm;
use app::{App, Plugin, PluginGroup};
use app::{App, Plugins};
pub use azalea_auth as auth;
pub use azalea_block as blocks;
pub use azalea_brigadier as brigadier;
@ -148,16 +148,10 @@ where
self.state = state;
self
}
/// Add a plugin to the client.
#[must_use]
pub fn add_plugin<T: Plugin>(mut self, plugin: T) -> Self {
self.app.add_plugin(plugin);
self
}
/// Add a group of plugins to the client.
#[must_use]
pub fn add_plugins<T: PluginGroup>(mut self, plugin_group: T) -> Self {
self.app.add_plugins(plugin_group);
pub fn add_plugins<M>(mut self, plugins: impl Plugins<M>) -> Self {
self.app.add_plugins(plugins);
self
}

View file

@ -5,13 +5,12 @@ use crate::bot::{JumpEvent, LookAtEvent};
use crate::pathfinder::astar::a_star;
use crate::{SprintDirection, WalkDirection};
use crate::app::{App, CoreSchedule, IntoSystemAppConfig, Plugin};
use crate::app::{App, Plugin};
use crate::ecs::{
component::Component,
entity::Entity,
event::{EventReader, EventWriter},
query::{With, Without},
schedule::IntoSystemConfig,
system::{Commands, Query, Res},
};
use astar::Edge;
@ -24,6 +23,9 @@ use azalea_world::{
entity::{Physics, Position, WorldName},
InstanceContainer,
};
use bevy_app::{FixedUpdate, Update};
use bevy_ecs::prelude::Event;
use bevy_ecs::schedule::IntoSystemConfigs;
use bevy_tasks::{AsyncComputeTaskPool, Task};
use futures_lite::future;
use log::{debug, error};
@ -36,17 +38,20 @@ impl Plugin for PathfinderPlugin {
fn build(&self, app: &mut App) {
app.add_event::<GotoEvent>()
.add_event::<PathFoundEvent>()
.add_system(
// Adding `.in_schedule(CoreSchedule::FixedUpdate)` makes a system run every
// Minecraft tick (every 50 milliseconds).
tick_execute_path
.in_schedule(CoreSchedule::FixedUpdate)
.before(PhysicsSet),
.add_systems(
FixedUpdate,
// putting systems in the FixedUpdate schedule makes them run every Minecraft tick
// (every 50 milliseconds).
tick_execute_path.before(PhysicsSet),
)
.add_system(goto_listener)
.add_system(add_default_pathfinder)
.add_system(handle_tasks.before(path_found_listener))
.add_system(path_found_listener);
.add_systems(
Update,
(
goto_listener,
add_default_pathfinder,
(handle_tasks, path_found_listener).chain(),
),
);
}
}
@ -84,10 +89,12 @@ impl PathfinderClientExt for azalea_client::Client {
});
}
}
#[derive(Event)]
pub struct GotoEvent {
pub entity: Entity,
pub goal: Arc<dyn Goal + Send + Sync>,
}
#[derive(Event)]
pub struct PathFoundEvent {
pub entity: Entity,
pub path: VecDeque<Node>,

View file

@ -20,7 +20,8 @@ use crate::ecs::{
system::{Commands, Query, Res, ResMut, Resource},
};
use azalea_client::chat::{ChatPacket, ChatReceivedEvent};
use bevy_app::{App, Plugin};
use bevy_app::{App, Plugin, Update};
use bevy_ecs::prelude::Event;
use std::collections::VecDeque;
use super::{Swarm, SwarmEvent};
@ -30,7 +31,10 @@ pub struct SwarmChatPlugin;
impl Plugin for SwarmChatPlugin {
fn build(&self, app: &mut App) {
app.add_event::<NewChatMessageEvent>()
.add_systems((chat_listener, update_min_index_and_shrink_queue).chain())
.add_systems(
Update,
(chat_listener, update_min_index_and_shrink_queue).chain(),
)
.insert_resource(GlobalChatState {
chat_queue: VecDeque::new(),
chat_min_index: 0,
@ -44,7 +48,7 @@ pub struct ClientChatState {
}
/// A chat message that no other bots have seen yet was received by a bot.
#[derive(Debug)]
#[derive(Event, Debug)]
pub struct NewChatMessageEvent(ChatPacket);
#[derive(Resource)]
@ -160,7 +164,10 @@ mod tests {
// event mangement in drain_events
app.init_resource::<Events<ChatReceivedEvent>>()
.init_resource::<Events<NewChatMessageEvent>>()
.add_systems((chat_listener, update_min_index_and_shrink_queue).chain())
.add_systems(
Update,
(chat_listener, update_min_index_and_shrink_queue).chain(),
)
.insert_resource(GlobalChatState {
chat_queue: VecDeque::new(),
chat_min_index: 0,

View file

@ -1,6 +1,6 @@
use azalea_client::LocalPlayer;
use azalea_world::entity::MinecraftEntityId;
use bevy_app::{App, Plugin};
use bevy_app::{App, Plugin, Update};
use bevy_ecs::prelude::*;
use derive_more::{Deref, DerefMut};
@ -8,12 +8,13 @@ pub struct SwarmPlugin;
impl Plugin for SwarmPlugin {
fn build(&self, app: &mut App) {
app.add_event::<SwarmReadyEvent>()
.add_system(check_ready)
.add_systems(Update, check_ready)
.init_resource::<IsSwarmReady>();
}
}
/// All the bots from the swarm are now in the world.
#[derive(Event)]
pub struct SwarmReadyEvent;
#[derive(Default, Resource, Deref, DerefMut)]

View file

@ -14,7 +14,7 @@ use azalea_protocol::{
ServerAddress,
};
use azalea_world::InstanceContainer;
use bevy_app::{App, Plugin, PluginGroup, PluginGroupBuilder};
use bevy_app::{App, PluginGroup, PluginGroupBuilder, Plugins};
use bevy_ecs::{component::Component, entity::Entity, system::Resource, world::World};
use futures::future::join_all;
use log::error;
@ -234,16 +234,10 @@ where
self
}
/// Add a plugin to the swarm.
/// Add one or more plugins to this swarm.
#[must_use]
pub fn add_plugin<T: Plugin>(mut self, plugin: T) -> Self {
self.app.add_plugin(plugin);
self
}
/// Add a group of plugins to the swarm.
#[must_use]
pub fn add_plugins<T: PluginGroup>(mut self, plugin_group: T) -> Self {
self.app.add_plugins(plugin_group);
pub fn add_plugins<M>(mut self, plugins: impl Plugins<M>) -> Self {
self.app.add_plugins(plugins);
self
}