mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
azalea-ecs stuff compiles
This commit is contained in:
parent
57d91b5220
commit
284a5b645e
33 changed files with 327 additions and 290 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -170,12 +170,11 @@ dependencies = [
|
|||
"azalea-chat",
|
||||
"azalea-client",
|
||||
"azalea-core",
|
||||
"azalea-ecs",
|
||||
"azalea-physics",
|
||||
"azalea-protocol",
|
||||
"azalea-registry",
|
||||
"azalea-world",
|
||||
"bevy_app",
|
||||
"bevy_ecs",
|
||||
"derive_more",
|
||||
"env_logger 0.10.0",
|
||||
"futures",
|
||||
|
@ -377,10 +376,9 @@ version = "0.5.0"
|
|||
dependencies = [
|
||||
"azalea-block",
|
||||
"azalea-core",
|
||||
"azalea-ecs",
|
||||
"azalea-registry",
|
||||
"azalea-world",
|
||||
"bevy_app",
|
||||
"bevy_ecs",
|
||||
"iyes_loopless",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
|
@ -459,10 +457,9 @@ dependencies = [
|
|||
"azalea-buf",
|
||||
"azalea-chat",
|
||||
"azalea-core",
|
||||
"azalea-ecs",
|
||||
"azalea-nbt",
|
||||
"azalea-registry",
|
||||
"bevy_app",
|
||||
"bevy_ecs",
|
||||
"derive_more",
|
||||
"enum-as-inner",
|
||||
"iyes_loopless",
|
||||
|
|
|
@ -11,12 +11,13 @@ use crate::{
|
|||
|
||||
use azalea_auth::{game_profile::GameProfile, sessionserver::ClientSessionServerError};
|
||||
use azalea_chat::FormattedText;
|
||||
use azalea_ecs::{ecs::Ecs, TickPlugin};
|
||||
use azalea_ecs::{
|
||||
app::{App, Plugin},
|
||||
component::Component,
|
||||
entity::Entity,
|
||||
schedule::{IntoSystemDescriptor, Schedule, Stage, SystemSet},
|
||||
App, Plugin,
|
||||
};
|
||||
use azalea_ecs::{ecs::Ecs, TickPlugin};
|
||||
use azalea_physics::PhysicsPlugin;
|
||||
use azalea_protocol::{
|
||||
connect::{Connection, ConnectionError},
|
||||
|
@ -38,7 +39,7 @@ use azalea_protocol::{
|
|||
},
|
||||
resolver, ServerAddress,
|
||||
};
|
||||
use azalea_world::{entity::Entity, EntityPlugin, Local, PartialWorld, World, WorldContainer};
|
||||
use azalea_world::{EntityPlugin, Local, PartialWorld, World, WorldContainer};
|
||||
use bevy_time::TimePlugin;
|
||||
use iyes_loopless::prelude::*;
|
||||
use log::{debug, error};
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use azalea_ecs::component::Component;
|
||||
use azalea_ecs::ecs::Ecs;
|
||||
use azalea_ecs::query::{ROQueryItem, ReadOnlyWorldQuery, WorldQuery};
|
||||
use azalea_world::entity::Entity;
|
||||
use azalea_ecs::{
|
||||
component::Component,
|
||||
ecs::Ecs,
|
||||
entity::Entity,
|
||||
query::{ROQueryItem, ReadOnlyWorldQuery, WorldQuery},
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use crate::Client;
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use azalea_ecs::{
|
||||
app::{App, Plugin},
|
||||
component::Component,
|
||||
event::EventReader,
|
||||
query::{Added, Changed},
|
||||
system::Query,
|
||||
Plugin,
|
||||
};
|
||||
use azalea_protocol::packets::game::{
|
||||
clientbound_player_combat_kill_packet::ClientboundPlayerCombatKillPacket, ClientboundGamePacket,
|
||||
|
@ -85,7 +85,7 @@ pub struct LocalPlayerEvents(pub mpsc::UnboundedSender<Event>);
|
|||
|
||||
pub struct EventPlugin;
|
||||
impl Plugin for EventPlugin {
|
||||
fn build(&self, app: &mut azalea_ecs::App) {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_system(chat_listener)
|
||||
.add_system(login_listener)
|
||||
.add_system(init_listener)
|
||||
|
|
|
@ -3,12 +3,13 @@ use std::{collections::HashMap, io, sync::Arc};
|
|||
use azalea_auth::game_profile::GameProfile;
|
||||
use azalea_core::{ChunkPos, ResourceLocation};
|
||||
use azalea_ecs::component::Component;
|
||||
use azalea_ecs::entity::Entity;
|
||||
use azalea_ecs::{query::Added, system::Query};
|
||||
use azalea_protocol::packets::game::ServerboundGamePacket;
|
||||
use azalea_world::{
|
||||
entity::{self, Dead, Entity},
|
||||
entity::{self, Dead},
|
||||
PartialWorld, World,
|
||||
};
|
||||
use bevy_ecs::{component::Component, query::Added, system::Query};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use parking_lot::RwLock;
|
||||
use thiserror::Error;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use crate::client::Client;
|
||||
use crate::local_player::{LocalPlayer, LocalPlayerInLoadedChunk, PhysicsState};
|
||||
use azalea_ecs::entity::Entity;
|
||||
use azalea_ecs::{event::EventReader, query::With, system::Query};
|
||||
use azalea_protocol::packets::game::serverbound_player_command_packet::ServerboundPlayerCommandPacket;
|
||||
use azalea_protocol::packets::game::{
|
||||
serverbound_move_player_pos_packet::ServerboundMovePlayerPosPacket,
|
||||
|
@ -7,12 +9,10 @@ use azalea_protocol::packets::game::{
|
|||
serverbound_move_player_rot_packet::ServerboundMovePlayerRotPacket,
|
||||
serverbound_move_player_status_only_packet::ServerboundMovePlayerStatusOnlyPacket,
|
||||
};
|
||||
use azalea_world::entity::metadata::Sprinting;
|
||||
use azalea_world::entity::{Attributes, Entity, Jumping, MinecraftEntityId};
|
||||
use azalea_world::{entity, MoveEntityError};
|
||||
use bevy_ecs::event::EventReader;
|
||||
use bevy_ecs::prelude::With;
|
||||
use bevy_ecs::system::Query;
|
||||
use azalea_world::{
|
||||
entity::{self, metadata::Sprinting, Attributes, Jumping, MinecraftEntityId},
|
||||
MoveEntityError,
|
||||
};
|
||||
use std::backtrace::Backtrace;
|
||||
use thiserror::Error;
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
use std::{collections::HashSet, io::Cursor, sync::Arc};
|
||||
|
||||
use azalea_core::{ChunkPos, ResourceLocation, Vec3};
|
||||
use azalea_ecs::{component::Component, ecs::Ecs};
|
||||
use azalea_ecs::{
|
||||
component::Component,
|
||||
prelude::{Entity, EventWriter},
|
||||
ecs::Ecs,
|
||||
query::Changed,
|
||||
schedule::{IntoSystemDescriptor, SystemSet},
|
||||
system::{Commands, Query, ResMut, SystemState},
|
||||
App, Plugin,
|
||||
app::{App, Plugin}, event::EventWriter, entity::Entity,
|
||||
};
|
||||
use azalea_protocol::{
|
||||
connect::{ReadConnection, WriteConnection},
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn derive_resource(input: TokenStream) -> TokenStream {
|
|||
let (impl_generics, type_generics, where_clause) = &ast.generics.split_for_impl();
|
||||
|
||||
TokenStream::from(quote! {
|
||||
impl #impl_generics #azalea_ecs_path::system::Resource for #struct_name #type_generics #where_clause {
|
||||
impl #impl_generics #azalea_ecs_path::system::BevyResource for #struct_name #type_generics #where_clause {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ pub fn derive_component(input: TokenStream) -> TokenStream {
|
|||
let (impl_generics, type_generics, where_clause) = &ast.generics.split_for_impl();
|
||||
|
||||
TokenStream::from(quote! {
|
||||
impl #impl_generics #azalea_ecs_path::component::Component for #struct_name #type_generics #where_clause {
|
||||
impl #impl_generics #azalea_ecs_path::component::BevyComponent for #struct_name #type_generics #where_clause {
|
||||
type Storage = #storage;
|
||||
}
|
||||
})
|
||||
|
|
|
@ -151,13 +151,13 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
|
|||
match field_kind {
|
||||
BundleFieldKind::Component => {
|
||||
field_component_ids.push(quote! {
|
||||
<#field_type as #ecs_path::bundle::Bundle>::component_ids(components, storages, &mut *ids);
|
||||
<#field_type as #ecs_path::bundle::BevyBundle>::component_ids(components, storages, &mut *ids);
|
||||
});
|
||||
field_get_components.push(quote! {
|
||||
self.#field.get_components(&mut *func);
|
||||
});
|
||||
field_from_components.push(quote! {
|
||||
#field: <#field_type as #ecs_path::bundle::Bundle>::from_components(ctx, &mut *func),
|
||||
#field: <#field_type as #ecs_path::bundle::BevyBundle>::from_components(ctx, &mut *func),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
|
|||
|
||||
TokenStream::from(quote! {
|
||||
/// SAFETY: ComponentId is returned in field-definition-order. [from_components] and [get_components] use field-definition-order
|
||||
unsafe impl #impl_generics #ecs_path::bundle::Bundle for #struct_name #ty_generics #where_clause {
|
||||
unsafe impl #impl_generics #ecs_path::bundle::BevyBundle for #struct_name #ty_generics #where_clause {
|
||||
fn component_ids(
|
||||
components: &mut #ecs_path::component::Components,
|
||||
storages: &mut #ecs_path::storage::Storages,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
use syn::DeriveInput;
|
||||
|
||||
use super::symbol::Symbol;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
mod attrs;
|
||||
|
@ -35,8 +37,9 @@ impl Default for BevyManifest {
|
|||
|
||||
impl BevyManifest {
|
||||
pub fn maybe_get_path(&self, name: &str) -> Option<syn::Path> {
|
||||
const AZALEA: &str = "azalea";
|
||||
const BEVY_ECS: &str = "bevy_ecs";
|
||||
const BEVY: &str = "bevy";
|
||||
const BEVY_INTERNAL: &str = "bevy_internal";
|
||||
|
||||
fn dep_package(dep: &Value) -> Option<&str> {
|
||||
if dep.as_str().is_some() {
|
||||
|
@ -52,16 +55,18 @@ impl BevyManifest {
|
|||
let find_in_deps = |deps: &Map<String, Value>| -> Option<syn::Path> {
|
||||
let package = if let Some(dep) = deps.get(name) {
|
||||
return Some(Self::parse_str(dep_package(dep).unwrap_or(name)));
|
||||
} else if let Some(dep) = deps.get(AZALEA) {
|
||||
dep_package(dep).unwrap_or(AZALEA)
|
||||
} else if let Some(dep) = deps.get(BEVY_ECS) {
|
||||
dep_package(dep).unwrap_or(BEVY_ECS)
|
||||
} else if let Some(dep) = deps.get(BEVY) {
|
||||
dep_package(dep).unwrap_or(BEVY)
|
||||
} else if let Some(dep) = deps.get(BEVY_INTERNAL) {
|
||||
dep_package(dep).unwrap_or(BEVY_INTERNAL)
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
|
||||
let mut path = Self::parse_str::<syn::Path>(package);
|
||||
if let Some(module) = name.strip_prefix("bevy_") {
|
||||
if let Some(module) = name.strip_prefix("azalea_") {
|
||||
path.segments.push(Self::parse_str(module));
|
||||
}
|
||||
Some(path)
|
||||
|
@ -109,7 +114,8 @@ impl BevyManifest {
|
|||
///
|
||||
/// # Args
|
||||
///
|
||||
/// - `input`: The [`syn::DeriveInput`] for struct that is deriving the label trait
|
||||
/// - `input`: The [`syn::DeriveInput`] for struct that is deriving the label
|
||||
/// trait
|
||||
/// - `trait_path`: The path [`syn::Path`] to the label trait
|
||||
pub fn derive_label(
|
||||
input: syn::DeriveInput,
|
||||
|
|
|
@ -1,18 +1,29 @@
|
|||
#![feature(trait_alias)]
|
||||
|
||||
//! Re-export the necessary parts of `bevy_ecs` and `bevy_app`.
|
||||
//! Re-export important parts of `bevy_ecs` and `bevy_app` and make them more
|
||||
//! compatible with Azalea.
|
||||
//!
|
||||
//! This is completely compatible with `bevy_ecs`, so it won't cause issues if
|
||||
//! you use plugins meant for Bevy.
|
||||
//!
|
||||
//! Changes:
|
||||
//! - Add [`TickPlugin`], [`TickStage`] and [`AppTickExt`]
|
||||
//! - Change the macros to use azalea_ecs instead of bevy_ecs
|
||||
//! - Rename bevy_ecs::world::World to azalea_ecs::ecs::Ecs
|
||||
//! - Re-export `bevy_app` in the `app` module.
|
||||
|
||||
use std::{
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
pub mod ecs {
|
||||
pub use bevy_ecs::world::World as Ecs;
|
||||
pub use bevy_ecs::world::{EntityMut, EntityRef, Mut};
|
||||
}
|
||||
pub mod component {
|
||||
pub use azalea_ecs_macros::Component;
|
||||
pub use bevy_ecs::component::{ComponentStorage, TableStorage};
|
||||
pub use bevy_ecs::component::{ComponentId, ComponentStorage, Components, TableStorage};
|
||||
|
||||
// we do this because re-exporting Component would re-export the macro as well,
|
||||
// which is bad (since we have our own Component macro)
|
||||
|
@ -21,14 +32,24 @@ pub mod component {
|
|||
pub trait Component = bevy_ecs::component::Component;
|
||||
pub use bevy_ecs::component::Component as BevyComponent;
|
||||
}
|
||||
pub mod ecs {
|
||||
pub use bevy_ecs::world::World as Ecs;
|
||||
pub use bevy_ecs::world::{EntityMut, EntityRef, Mut};
|
||||
pub mod bundle {
|
||||
pub use azalea_ecs_macros::Bundle;
|
||||
pub trait Bundle = bevy_ecs::bundle::Bundle;
|
||||
pub use bevy_ecs::bundle::Bundle as BevyBundle;
|
||||
}
|
||||
pub use bevy_app::*;
|
||||
pub mod system {
|
||||
pub use azalea_ecs_macros::Resource;
|
||||
pub use bevy_ecs::system::{
|
||||
Command, Commands, EntityCommands, Query, Res, ResMut, SystemState,
|
||||
};
|
||||
pub trait Resource = bevy_ecs::system::Resource;
|
||||
pub use bevy_ecs::system::Resource as BevyResource;
|
||||
}
|
||||
pub use bevy_app as app;
|
||||
pub use bevy_ecs::{entity, event, ptr, query, schedule, storage};
|
||||
|
||||
use app::{App, CoreStage, Plugin};
|
||||
use bevy_ecs::schedule::*;
|
||||
pub use bevy_ecs::system;
|
||||
pub use bevy_ecs::{event, query, schedule};
|
||||
use ecs::Ecs;
|
||||
use futures::task::noop_waker_ref;
|
||||
use tokio::time::Interval;
|
||||
|
@ -68,7 +89,7 @@ impl TickStage {
|
|||
impl Stage for TickStage {
|
||||
fn run(&mut self, ecs: &mut Ecs) {
|
||||
// keep calling run until it's caught up
|
||||
while let Poll::Ready(r) = self
|
||||
while let Poll::Ready(_) = self
|
||||
.interval
|
||||
.poll_tick(&mut Context::from_waker(&noop_waker_ref()))
|
||||
{
|
||||
|
|
|
@ -13,11 +13,10 @@ azalea-block = { path = "../azalea-block", version = "^0.5.0" }
|
|||
azalea-core = { path = "../azalea-core", version = "^0.5.0" }
|
||||
azalea-world = { path = "../azalea-world", version = "^0.5.0" }
|
||||
azalea-registry = { path = "../azalea-registry", version = "^0.5.0" }
|
||||
bevy_app = { version = "0.9.1", default-features = false }
|
||||
bevy_ecs = { version = "0.9.1", default-features = false }
|
||||
iyes_loopless = "0.9.1"
|
||||
once_cell = "1.16.0"
|
||||
parking_lot = "^0.12.1"
|
||||
azalea-ecs = { version = "0.5.0", path = "../azalea-ecs" }
|
||||
|
||||
[dev-dependencies]
|
||||
uuid = "^1.1.2"
|
||||
|
|
|
@ -4,29 +4,27 @@ pub mod collision;
|
|||
|
||||
use azalea_block::{Block, BlockState};
|
||||
use azalea_core::{BlockPos, Vec3};
|
||||
use azalea_ecs::{
|
||||
app::{App, Plugin},
|
||||
entity::Entity,
|
||||
event::{EventReader, EventWriter},
|
||||
query::With,
|
||||
schedule::{IntoSystemDescriptor, SystemSet},
|
||||
system::{Query, Res},
|
||||
AppTickExt,
|
||||
};
|
||||
use azalea_world::{
|
||||
entity::{
|
||||
metadata::Sprinting, move_relative, Attributes, Entity, Jumping, Physics, Position,
|
||||
WorldName,
|
||||
metadata::Sprinting, move_relative, Attributes, Jumping, Physics, Position, WorldName,
|
||||
},
|
||||
Local, World, WorldContainer,
|
||||
};
|
||||
use bevy_app::Plugin;
|
||||
use bevy_ecs::{
|
||||
event::{EventReader, EventWriter},
|
||||
query::With,
|
||||
schedule::{IntoSystemDescriptor, SystemStage},
|
||||
system::Res,
|
||||
};
|
||||
use bevy_ecs::{schedule::SystemSet, system::Query};
|
||||
use collision::{move_colliding, MoverType};
|
||||
|
||||
pub struct PhysicsPlugin;
|
||||
impl Plugin for PhysicsPlugin {
|
||||
fn build(&self, app: &mut bevy_app::App) {
|
||||
app.add_event::<ForceJumpEvent>()
|
||||
.stage("tick", |stage: &mut SystemStage| {
|
||||
stage.add_system_set(
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_event::<ForceJumpEvent>().add_tick_system_set(
|
||||
SystemSet::new()
|
||||
.with_system(ai_step.label("ai_step"))
|
||||
.with_system(
|
||||
|
@ -40,8 +38,7 @@ impl Plugin for PhysicsPlugin {
|
|||
.after("ai_step")
|
||||
.after("force_jump_listener"),
|
||||
),
|
||||
)
|
||||
});
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,11 +307,11 @@ mod tests {
|
|||
|
||||
use super::*;
|
||||
use azalea_core::{ChunkPos, ResourceLocation};
|
||||
use azalea_ecs::app::App;
|
||||
use azalea_world::{
|
||||
entity::{EntityBundle, MinecraftEntityId},
|
||||
Chunk, EntityPlugin, PartialWorld,
|
||||
};
|
||||
use bevy_app::App;
|
||||
use iyes_loopless::fixedtimestep::FixedTimestepStageLabel;
|
||||
use parking_lot::RwLock;
|
||||
use uuid::Uuid;
|
||||
|
|
|
@ -13,10 +13,9 @@ azalea-block = {path = "../azalea-block", default-features = false, version = "^
|
|||
azalea-buf = {path = "../azalea-buf", version = "^0.5.0"}
|
||||
azalea-chat = {path = "../azalea-chat", version = "^0.5.0"}
|
||||
azalea-core = {path = "../azalea-core", version = "^0.5.0", features = ["bevy_ecs"]}
|
||||
azalea-ecs = { version = "0.5.0", path = "../azalea-ecs" }
|
||||
azalea-nbt = {path = "../azalea-nbt", version = "^0.5.0"}
|
||||
azalea-registry = {path = "../azalea-registry", version = "^0.5.0"}
|
||||
bevy_app = {version = "0.9.1", default-features = false}
|
||||
bevy_ecs = {version = "0.9.1", default-features = false}
|
||||
derive_more = {version = "0.99.17", features = ["deref", "deref_mut"]}
|
||||
enum-as-inner = "0.5.1"
|
||||
iyes_loopless = "0.9.1"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_core::ResourceLocation;
|
||||
use bevy_ecs::system::Resource;
|
||||
use azalea_ecs::system::Resource;
|
||||
use log::error;
|
||||
use nohash_hasher::IntMap;
|
||||
use parking_lot::RwLock;
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::{
|
|||
};
|
||||
|
||||
use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable};
|
||||
use bevy_ecs::component::Component;
|
||||
use azalea_ecs::component::Component;
|
||||
use thiserror::Error;
|
||||
use uuid::{uuid, Uuid};
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
//! Define some types needed for entity metadata.
|
||||
|
||||
use azalea_block::BlockState;
|
||||
use azalea_buf::{BufReadError, McBufVarReadable, McBufVarWritable};
|
||||
use azalea_buf::{McBuf, McBufReadable, McBufWritable};
|
||||
use azalea_buf::{
|
||||
BufReadError, McBuf, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable,
|
||||
};
|
||||
use azalea_chat::FormattedText;
|
||||
use azalea_core::{BlockPos, Direction, GlobalPos, Particle, Slot};
|
||||
use bevy_ecs::component::Component;
|
||||
use azalea_ecs::component::Component;
|
||||
use derive_more::Deref;
|
||||
use enum_as_inner::EnumAsInner;
|
||||
use nohash_hasher::IntSet;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use azalea_core::{Vec3, AABB};
|
||||
use bevy_ecs::{query::Changed, system::Query};
|
||||
use azalea_ecs::{query::Changed, system::Query};
|
||||
|
||||
use super::{Physics, Position};
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,9 +11,10 @@ use self::{attributes::AttributeInstance, metadata::Health};
|
|||
pub use attributes::Attributes;
|
||||
use azalea_block::BlockState;
|
||||
use azalea_core::{BlockPos, ChunkPos, ResourceLocation, Vec3, AABB};
|
||||
use bevy_ecs::{
|
||||
use azalea_ecs::{
|
||||
bundle::Bundle,
|
||||
component::Component,
|
||||
entity::Entity,
|
||||
query::Changed,
|
||||
system::{Commands, Query},
|
||||
};
|
||||
|
@ -23,15 +24,6 @@ pub use dimensions::{update_bounding_box, EntityDimensions};
|
|||
use std::fmt::Debug;
|
||||
use uuid::Uuid;
|
||||
|
||||
/// A lightweight identifier of an entity.
|
||||
///
|
||||
/// Don't rely on the index of this being the same as a Minecraft entity id!
|
||||
/// (unless you're implementin a server, in which case you can decide your
|
||||
/// entity ids however you want)
|
||||
///
|
||||
/// If you want to refer to a Minecraft entity id, use [`MinecraftEntityId`].
|
||||
pub type Entity = bevy_ecs::entity::Entity;
|
||||
|
||||
/// An entity ID used by Minecraft. These are not guaranteed to be unique in
|
||||
/// shared worlds, that's what [`Entity`] is for.
|
||||
#[derive(Component, Copy, Clone, Debug, PartialEq, Eq, Deref, DerefMut)]
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
use crate::{
|
||||
deduplicate_entities,
|
||||
entity::{
|
||||
self, add_dead, update_bounding_box, Entity, EntityUuid, MinecraftEntityId, Position,
|
||||
WorldName,
|
||||
self, add_dead, update_bounding_box, EntityUuid, MinecraftEntityId, Position, WorldName,
|
||||
},
|
||||
update_entity_by_id_index, update_uuid_index, PartialWorld, WorldContainer,
|
||||
};
|
||||
use azalea_core::ChunkPos;
|
||||
use bevy_app::{App, Plugin};
|
||||
use bevy_ecs::{
|
||||
prelude::Component,
|
||||
use azalea_ecs::{
|
||||
app::{App, Plugin},
|
||||
component::Component,
|
||||
ecs::Ecs,
|
||||
ecs::EntityMut,
|
||||
entity::Entity,
|
||||
query::{Added, Changed, With, Without},
|
||||
schedule::{IntoSystemDescriptor, SystemSet},
|
||||
system::{Command, Commands, Query, Res, ResMut, Resource},
|
||||
world::EntityMut,
|
||||
};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use log::{debug, warn};
|
||||
|
@ -121,7 +122,7 @@ pub struct RelativeEntityUpdate {
|
|||
pub update: Box<dyn FnOnce(&mut EntityMut) + Send + Sync>,
|
||||
}
|
||||
impl Command for RelativeEntityUpdate {
|
||||
fn write(self, world: &mut bevy_ecs::world::World) {
|
||||
fn write(self, world: &mut Ecs) {
|
||||
let partial_entity_infos = &mut self.partial_world.write().entity_infos;
|
||||
|
||||
let mut entity = world.entity_mut(self.entity);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use crate::{
|
||||
entity::{Entity, EntityUuid, MinecraftEntityId, Position, WorldName},
|
||||
entity::{EntityUuid, MinecraftEntityId, Position, WorldName},
|
||||
entity_info::LoadedBy,
|
||||
ChunkStorage, EntityInfos, PartialChunkStorage, PartialEntityInfos, WorldContainer,
|
||||
};
|
||||
use azalea_core::ChunkPos;
|
||||
use bevy_ecs::{
|
||||
use azalea_ecs::{
|
||||
entity::Entity,
|
||||
query::Changed,
|
||||
system::{Commands, Query, Res, ResMut},
|
||||
};
|
||||
|
|
|
@ -18,12 +18,11 @@ azalea-block = {version = "0.5.0", path = "../azalea-block"}
|
|||
azalea-chat = {version = "0.5.0", path = "../azalea-chat"}
|
||||
azalea-client = {version = "0.5.0", path = "../azalea-client"}
|
||||
azalea-core = {version = "0.5.0", path = "../azalea-core"}
|
||||
azalea-ecs = { version = "0.5.0", path = "../azalea-ecs" }
|
||||
azalea-physics = {version = "0.5.0", path = "../azalea-physics"}
|
||||
azalea-protocol = {version = "0.5.0", path = "../azalea-protocol"}
|
||||
azalea-registry = {version = "0.5.0", path = "../azalea-registry"}
|
||||
azalea-world = {version = "0.5.0", path = "../azalea-world"}
|
||||
bevy_app = {version = "0.9.1", default-features = false}
|
||||
bevy_ecs = {version = "0.9.1", default-features = false}
|
||||
derive_more = {version = "0.99.17", features = ["deref", "deref_mut"]}
|
||||
futures = "0.3.25"
|
||||
iyes_loopless = "0.9.1"
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
use azalea_core::Vec3;
|
||||
use azalea_world::entity::{set_rotation, Entity, Jumping, Physics, Position};
|
||||
use bevy_app::App;
|
||||
use bevy_ecs::schedule::IntoSystemDescriptor;
|
||||
use bevy_ecs::{event::EventReader, prelude::Component, schedule::SystemSet, system::Query};
|
||||
use azalea_ecs::{
|
||||
app::{App, Plugin},
|
||||
component::Component,
|
||||
event::EventReader,
|
||||
schedule::IntoSystemDescriptor,
|
||||
schedule::SystemSet,
|
||||
system::Query, entity::Entity,
|
||||
};
|
||||
use azalea_world::entity::{set_rotation, Jumping, Physics, Position};
|
||||
use iyes_loopless::prelude::*;
|
||||
use std::f64::consts::PI;
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct Plugin;
|
||||
impl bevy_app::Plugin for Plugin {
|
||||
pub struct BotPlugin;
|
||||
impl Plugin for BotPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_event::<LookAtEvent>()
|
||||
.add_event::<JumpEvent>()
|
||||
|
|
|
@ -11,11 +11,13 @@ mod swarm;
|
|||
pub use azalea_block as blocks;
|
||||
pub use azalea_client::*;
|
||||
pub use azalea_core::{BlockPos, Vec3};
|
||||
use azalea_ecs::{
|
||||
app::{App, Plugin},
|
||||
component::Component,
|
||||
};
|
||||
pub use azalea_protocol as protocol;
|
||||
pub use azalea_registry::EntityKind;
|
||||
pub use azalea_world::{entity, World};
|
||||
use bevy_app::Plugin;
|
||||
use bevy_ecs::prelude::Component;
|
||||
use futures::Future;
|
||||
use protocol::ServerAddress;
|
||||
pub use swarm::*;
|
||||
|
@ -36,7 +38,7 @@ where
|
|||
S: Default + Send + Sync + Clone + 'static,
|
||||
Fut: Future<Output = Result<(), anyhow::Error>>,
|
||||
{
|
||||
app: bevy_app::App,
|
||||
app: App,
|
||||
/// The function that's called every time a bot receives an [`Event`].
|
||||
handler: Option<HandleFn<Fut, S>>,
|
||||
state: S,
|
||||
|
|
|
@ -6,27 +6,30 @@ use crate::{SprintDirection, WalkDirection};
|
|||
|
||||
use azalea_client::{StartSprintEvent, StartWalkEvent};
|
||||
use azalea_core::{BlockPos, CardinalDirection};
|
||||
use azalea_world::entity::{Entity, Physics, Position, WorldName};
|
||||
use azalea_world::WorldContainer;
|
||||
use bevy_ecs::event::EventReader;
|
||||
use bevy_ecs::schedule::SystemSet;
|
||||
use bevy_ecs::system::{Query, Res};
|
||||
use bevy_ecs::{component::Component, event::EventWriter};
|
||||
use iyes_loopless::prelude::*;
|
||||
use azalea_ecs::app::{App, Plugin};
|
||||
use azalea_ecs::AppTickExt;
|
||||
use azalea_ecs::{
|
||||
component::Component,
|
||||
entity::Entity,
|
||||
event::EventReader,
|
||||
event::EventWriter,
|
||||
schedule::SystemSet,
|
||||
system::{Query, Res},
|
||||
};
|
||||
use azalea_world::{
|
||||
entity::{Physics, Position, WorldName},
|
||||
WorldContainer,
|
||||
};
|
||||
use log::{debug, error};
|
||||
use mtdstarlite::Edge;
|
||||
pub use mtdstarlite::MTDStarLite;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct Plugin;
|
||||
impl bevy_app::Plugin for Plugin {
|
||||
fn build(&self, app: &mut bevy_app::App) {
|
||||
app.add_fixed_timestep_system_set(
|
||||
"tick",
|
||||
0,
|
||||
SystemSet::new().with_system(tick_execute_path),
|
||||
)
|
||||
pub struct PathfinderPlugin;
|
||||
impl Plugin for PathfinderPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_tick_system_set(SystemSet::new().with_system(tick_execute_path))
|
||||
.add_system(goto_listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,5 +4,4 @@
|
|||
pub use crate::bot::BotClientExt;
|
||||
pub use crate::pathfinder::PathfinderClientExt;
|
||||
pub use azalea_client::{Account, Client, Event};
|
||||
pub use bevy_ecs;
|
||||
pub use bevy_ecs::component::Component;
|
||||
pub use azalea_ecs::component::Component;
|
||||
|
|
|
@ -14,8 +14,11 @@
|
|||
// messages from the queue that are before that index.
|
||||
|
||||
use azalea_client::{packet_handling::ChatReceivedEvent, ChatPacket, LocalPlayer};
|
||||
use bevy_ecs::{
|
||||
prelude::{Component, Entity, EventReader, EventWriter},
|
||||
use azalea_ecs::app::{Plugin, App};
|
||||
use azalea_ecs::{
|
||||
component::Component,
|
||||
entity::Entity,
|
||||
event::{EventReader, EventWriter},
|
||||
query::{Added, Without},
|
||||
system::{Commands, Query, Res, ResMut, Resource},
|
||||
};
|
||||
|
@ -24,9 +27,9 @@ use std::collections::VecDeque;
|
|||
use crate::{Swarm, SwarmEvent};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Plugin;
|
||||
impl bevy_app::Plugin for Plugin {
|
||||
fn build(&self, app: &mut bevy_app::App) {
|
||||
pub struct SwarmChatPlugin;
|
||||
impl Plugin for SwarmChatPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_event::<NewChatMessageEvent>()
|
||||
.add_system(chat_listener)
|
||||
.add_system(add_default_client_state)
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use azalea_client::LocalPlayer;
|
||||
use azalea_world::entity::MinecraftEntityId;
|
||||
use bevy_ecs::{
|
||||
prelude::{EventWriter, With},
|
||||
use azalea_ecs::{
|
||||
app::{App, Plugin},
|
||||
event::EventWriter,
|
||||
query::With,
|
||||
system::{Query, ResMut, Resource},
|
||||
};
|
||||
use azalea_world::entity::MinecraftEntityId;
|
||||
use derive_more::{Deref, DerefMut};
|
||||
|
||||
pub struct Plugin;
|
||||
impl bevy_app::Plugin for Plugin {
|
||||
fn build(&self, app: &mut bevy_app::App) {
|
||||
pub struct SwarmPlugin;
|
||||
impl Plugin for SwarmPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_event::<SwarmReadyEvent>()
|
||||
.add_system(check_ready)
|
||||
.init_resource::<IsSwarmReady>();
|
||||
|
|
|
@ -5,14 +5,19 @@ mod events;
|
|||
|
||||
use crate::{bot, HandleFn};
|
||||
use azalea_client::{init_ecs_app, start_ecs, Account, ChatPacket, Client, Event, JoinError};
|
||||
use azalea_ecs::{
|
||||
app::{App, Plugin},
|
||||
component::Component,
|
||||
ecs::Ecs,
|
||||
entity::Entity,
|
||||
system::Resource,
|
||||
};
|
||||
use azalea_protocol::{
|
||||
connect::ConnectionError,
|
||||
resolver::{self, ResolverError},
|
||||
ServerAddress,
|
||||
};
|
||||
use azalea_world::{entity::Entity, WorldContainer};
|
||||
use bevy_app::Plugin;
|
||||
use bevy_ecs::{prelude::Component, system::Resource};
|
||||
use azalea_world::WorldContainer;
|
||||
use futures::future::join_all;
|
||||
use log::error;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
|
@ -31,7 +36,7 @@ use tokio::sync::mpsc;
|
|||
/// [`azalea::start_swarm`]: fn.start_swarm.html
|
||||
#[derive(Clone, Resource)]
|
||||
pub struct Swarm {
|
||||
pub ecs_lock: Arc<Mutex<bevy_ecs::world::World>>,
|
||||
pub ecs_lock: Arc<Mutex<Ecs>>,
|
||||
|
||||
bots: Arc<Mutex<HashMap<Entity, Client>>>,
|
||||
|
||||
|
@ -54,7 +59,7 @@ where
|
|||
Fut: Future<Output = Result<(), anyhow::Error>>,
|
||||
SwarmFut: Future<Output = Result<(), anyhow::Error>>,
|
||||
{
|
||||
app: bevy_app::App,
|
||||
app: App,
|
||||
/// The accounts that are going to join the server.
|
||||
accounts: Vec<Account>,
|
||||
/// The individual bot states. This must be the same length as `accounts`,
|
||||
|
@ -163,9 +168,9 @@ where
|
|||
}
|
||||
|
||||
fn add_default_swarm_plugins(self) -> Self {
|
||||
self.add_plugin(chat::Plugin)
|
||||
.add_plugin(events::Plugin)
|
||||
.add_plugin(bot::Plugin)
|
||||
self.add_plugin(chat::SwarmChatPlugin)
|
||||
.add_plugin(events::SwarmPlugin)
|
||||
.add_plugin(bot::BotPlugin)
|
||||
}
|
||||
|
||||
/// Build this `SwarmBuilder` into an actual [`Swarm`] and join the given
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use azalea::bevy_ecs::query::With;
|
||||
use azalea::ecs::query::With;
|
||||
use azalea::entity::metadata::Player;
|
||||
use azalea::entity::Position;
|
||||
use azalea::pathfinder::BlockPosGoal;
|
||||
|
|
|
@ -46,7 +46,7 @@ use super::{EntityDataItem, EntityDataValue, OptionalUnsignedInt, Pose, Rotation
|
|||
use azalea_block::BlockState;
|
||||
use azalea_chat::FormattedText;
|
||||
use azalea_core::{BlockPos, Direction, Particle, Slot};
|
||||
use bevy_ecs::{bundle::Bundle, component::Component};
|
||||
use azalea_ecs::{bundle::Bundle, component::Component};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use thiserror::Error;
|
||||
use uuid::Uuid;
|
||||
|
@ -183,7 +183,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
|
|||
|
||||
# impl Allay {
|
||||
# pub fn apply_metadata(
|
||||
# entity: &mut bevy_ecs::system::EntityCommands,
|
||||
# entity: &mut azalea_ecs::system::EntityCommands,
|
||||
# d: EntityDataItem,
|
||||
# ) -> Result<(), UpdateMetadataError> {
|
||||
# match d.index {
|
||||
|
@ -196,7 +196,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
|
|||
# }
|
||||
code.append(f'impl {struct_name} {{')
|
||||
code.append(
|
||||
f' pub fn apply_metadata(entity: &mut bevy_ecs::system::EntityCommands, d: EntityDataItem) -> Result<(), UpdateMetadataError> {{')
|
||||
f' pub fn apply_metadata(entity: &mut azalea_ecs::system::EntityCommands, d: EntityDataItem) -> Result<(), UpdateMetadataError> {{')
|
||||
code.append(f' match d.index {{')
|
||||
|
||||
parent_last_index = -1
|
||||
|
@ -400,7 +400,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
|
|||
|
||||
# and now make the main apply_metadata
|
||||
# pub fn apply_metadata(
|
||||
# entity: &mut bevy_ecs::system::EntityCommands,
|
||||
# entity: &mut azalea_ecs::system::EntityCommands,
|
||||
# items: Vec<EntityDataItem>,
|
||||
# ) -> Result<(), UpdateMetadataError> {
|
||||
# if entity.contains::<Allay>() {
|
||||
|
@ -414,7 +414,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
|
|||
# }
|
||||
code.append(
|
||||
f'''pub fn apply_metadata(
|
||||
entity: &mut bevy_ecs::system::EntityCommands,
|
||||
entity: &mut azalea_ecs::system::EntityCommands,
|
||||
entity_kind: azalea_registry::EntityKind,
|
||||
items: Vec<EntityDataItem>,
|
||||
) -> Result<(), UpdateMetadataError> {{
|
||||
|
@ -436,7 +436,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
|
|||
code.append('}')
|
||||
code.append('')
|
||||
|
||||
# pub fn apply_default_metadata(entity: &mut bevy_ecs::system::EntityCommands, kind: azalea_registry::EntityKind) {
|
||||
# pub fn apply_default_metadata(entity: &mut azalea_ecs::system::EntityCommands, kind: azalea_registry::EntityKind) {
|
||||
# match kind {
|
||||
# azalea_registry::EntityKind::AreaEffectCloud => {
|
||||
# entity.insert(AreaEffectCloudMetadataBundle::default());
|
||||
|
@ -444,7 +444,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
|
|||
# }
|
||||
# }
|
||||
code.append(
|
||||
'pub fn apply_default_metadata(entity: &mut bevy_ecs::system::EntityCommands, kind: azalea_registry::EntityKind) {')
|
||||
'pub fn apply_default_metadata(entity: &mut azalea_ecs::system::EntityCommands, kind: azalea_registry::EntityKind) {')
|
||||
code.append(' match kind {')
|
||||
for entity_id in burger_entity_data:
|
||||
if entity_id.startswith('~'):
|
||||
|
|
Loading…
Add table
Reference in a new issue