mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
fix all bevy ambiguities
This commit is contained in:
parent
2773146fbf
commit
472496b7b8
17 changed files with 1448 additions and 51 deletions
|
@ -1,8 +1,9 @@
|
||||||
use azalea_core::GameMode;
|
use azalea_core::GameMode;
|
||||||
use azalea_entity::{
|
use azalea_entity::{
|
||||||
metadata::{ShiftKeyDown, Sprinting},
|
metadata::{ShiftKeyDown, Sprinting},
|
||||||
Attributes, Physics,
|
update_bounding_box, Attributes, Physics,
|
||||||
};
|
};
|
||||||
|
use azalea_physics::PhysicsSet;
|
||||||
use azalea_protocol::packets::game::serverbound_interact_packet::{
|
use azalea_protocol::packets::game::serverbound_interact_packet::{
|
||||||
self, ServerboundInteractPacket,
|
self, ServerboundInteractPacket,
|
||||||
};
|
};
|
||||||
|
@ -14,6 +15,8 @@ use derive_more::{Deref, DerefMut};
|
||||||
use crate::{
|
use crate::{
|
||||||
interact::SwingArmEvent,
|
interact::SwingArmEvent,
|
||||||
local_player::{LocalGameMode, SendPacketEvent},
|
local_player::{LocalGameMode, SendPacketEvent},
|
||||||
|
movement::walk_listener,
|
||||||
|
respawn::perform_respawn,
|
||||||
Client,
|
Client,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,12 +24,18 @@ pub struct AttackPlugin;
|
||||||
impl Plugin for AttackPlugin {
|
impl Plugin for AttackPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_event::<AttackEvent>()
|
app.add_event::<AttackEvent>()
|
||||||
.add_systems(Update, handle_attack_event)
|
.add_systems(
|
||||||
|
Update,
|
||||||
|
handle_attack_event
|
||||||
|
.before(update_bounding_box)
|
||||||
|
.before(walk_listener)
|
||||||
|
.after(perform_respawn),
|
||||||
|
)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
FixedUpdate,
|
FixedUpdate,
|
||||||
(
|
(
|
||||||
increment_ticks_since_last_attack,
|
increment_ticks_since_last_attack,
|
||||||
update_attack_strength_scale,
|
update_attack_strength_scale.after(PhysicsSet),
|
||||||
)
|
)
|
||||||
.chain(),
|
.chain(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,7 +25,7 @@ use azalea_entity::{
|
||||||
indexing::EntityIdIndex, metadata::Health, EntityPlugin, EntityUpdateSet, EyeHeight, Local,
|
indexing::EntityIdIndex, metadata::Health, EntityPlugin, EntityUpdateSet, EyeHeight, Local,
|
||||||
Position,
|
Position,
|
||||||
};
|
};
|
||||||
use azalea_physics::{PhysicsPlugin, PhysicsSet};
|
use azalea_physics::PhysicsPlugin;
|
||||||
use azalea_protocol::{
|
use azalea_protocol::{
|
||||||
connect::{Connection, ConnectionError},
|
connect::{Connection, ConnectionError},
|
||||||
packets::{
|
packets::{
|
||||||
|
@ -48,7 +48,7 @@ use azalea_protocol::{
|
||||||
resolver, ServerAddress,
|
resolver, ServerAddress,
|
||||||
};
|
};
|
||||||
use azalea_world::{Instance, InstanceContainer, InstanceName, PartialInstance};
|
use azalea_world::{Instance, InstanceContainer, InstanceName, PartialInstance};
|
||||||
use bevy_app::{App, FixedUpdate, Main, Plugin, PluginGroup, PluginGroupBuilder, Update};
|
use bevy_app::{App, FixedUpdate, Plugin, PluginGroup, PluginGroupBuilder, Update};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
bundle::Bundle,
|
bundle::Bundle,
|
||||||
component::Component,
|
component::Component,
|
||||||
|
@ -617,7 +617,7 @@ impl Plugin for AzaleaPlugin {
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Update,
|
Update,
|
||||||
(
|
(
|
||||||
update_in_loaded_chunk.after(PhysicsSet),
|
update_in_loaded_chunk,
|
||||||
// fire the Death event when the player dies.
|
// fire the Death event when the player dies.
|
||||||
death_event,
|
death_event,
|
||||||
// add GameProfileComponent when we get an AddPlayerEvent
|
// add GameProfileComponent when we get an AddPlayerEvent
|
||||||
|
@ -721,7 +721,13 @@ impl Plugin for TickBroadcastPlugin {
|
||||||
pub struct AmbiguityLoggerPlugin;
|
pub struct AmbiguityLoggerPlugin;
|
||||||
impl Plugin for AmbiguityLoggerPlugin {
|
impl Plugin for AmbiguityLoggerPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.edit_schedule(Main, |schedule| {
|
app.edit_schedule(Update, |schedule| {
|
||||||
|
schedule.set_build_settings(ScheduleBuildSettings {
|
||||||
|
ambiguity_detection: LogLevel::Warn,
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
app.edit_schedule(FixedUpdate, |schedule| {
|
||||||
schedule.set_build_settings(ScheduleBuildSettings {
|
schedule.set_build_settings(ScheduleBuildSettings {
|
||||||
ambiguity_detection: LogLevel::Warn,
|
ambiguity_detection: LogLevel::Warn,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
|
@ -209,7 +209,7 @@ fn remove_player_listener(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn death_listener(query: Query<&LocalPlayerEvents>, mut events: EventReader<DeathEvent>) {
|
pub fn death_listener(query: Query<&LocalPlayerEvents>, mut events: EventReader<DeathEvent>) {
|
||||||
for event in events.iter() {
|
for event in events.iter() {
|
||||||
if let Ok(local_player_events) = query.get(event.entity) {
|
if let Ok(local_player_events) = query.get(event.entity) {
|
||||||
local_player_events
|
local_player_events
|
||||||
|
|
|
@ -28,7 +28,7 @@ use log::warn;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::{PermissionLevel, PlayerAbilities},
|
client::{PermissionLevel, PlayerAbilities},
|
||||||
inventory::InventoryComponent,
|
inventory::{InventoryComponent, InventorySet},
|
||||||
local_player::{handle_send_packet_event, LocalGameMode, SendPacketEvent},
|
local_player::{handle_send_packet_event, LocalGameMode, SendPacketEvent},
|
||||||
Client, LocalPlayer,
|
Client, LocalPlayer,
|
||||||
};
|
};
|
||||||
|
@ -49,7 +49,9 @@ impl Plugin for InteractPlugin {
|
||||||
)
|
)
|
||||||
.before(handle_send_packet_event)
|
.before(handle_send_packet_event)
|
||||||
.chain(),
|
.chain(),
|
||||||
update_modifiers_for_held_item,
|
update_modifiers_for_held_item
|
||||||
|
.after(InventorySet)
|
||||||
|
.after(crate::movement::walk_listener),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -151,7 +153,7 @@ pub fn handle_block_interact_event(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
fn update_hit_result_component(
|
pub fn update_hit_result_component(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut query: Query<(
|
mut query: Query<(
|
||||||
Entity,
|
Entity,
|
||||||
|
@ -297,7 +299,7 @@ pub fn can_use_game_master_blocks(
|
||||||
pub struct SwingArmEvent {
|
pub struct SwingArmEvent {
|
||||||
pub entity: Entity,
|
pub entity: Entity,
|
||||||
}
|
}
|
||||||
fn handle_swing_arm_event(
|
pub fn handle_swing_arm_event(
|
||||||
mut events: EventReader<SwingArmEvent>,
|
mut events: EventReader<SwingArmEvent>,
|
||||||
mut send_packet_events: EventWriter<SendPacketEvent>,
|
mut send_packet_events: EventWriter<SendPacketEvent>,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ use bevy_ecs::{
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
event::EventReader,
|
event::EventReader,
|
||||||
prelude::{Event, EventWriter},
|
prelude::{Event, EventWriter},
|
||||||
schedule::IntoSystemConfigs,
|
schedule::{IntoSystemConfigs, SystemSet},
|
||||||
system::Query,
|
system::Query,
|
||||||
};
|
};
|
||||||
use log::warn;
|
use log::warn;
|
||||||
|
@ -44,11 +44,15 @@ impl Plugin for InventoryPlugin {
|
||||||
handle_container_close_event.before(handle_send_packet_event),
|
handle_container_close_event.before(handle_send_packet_event),
|
||||||
handle_client_side_close_container_event,
|
handle_client_side_close_container_event,
|
||||||
)
|
)
|
||||||
.chain(),
|
.chain()
|
||||||
|
.in_set(InventorySet),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
|
||||||
|
pub struct InventorySet;
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
/// Return the menu that is currently open. If no menu is open, this will
|
/// Return the menu that is currently open. If no menu is open, this will
|
||||||
/// have the player's inventory.
|
/// have the player's inventory.
|
||||||
|
|
|
@ -2,6 +2,7 @@ use azalea_block::{Block, BlockState, FluidState};
|
||||||
use azalea_core::{BlockPos, Direction, GameMode};
|
use azalea_core::{BlockPos, Direction, GameMode};
|
||||||
use azalea_entity::{mining::get_mine_progress, FluidOnEyes, Physics};
|
use azalea_entity::{mining::get_mine_progress, FluidOnEyes, Physics};
|
||||||
use azalea_inventory::ItemSlot;
|
use azalea_inventory::ItemSlot;
|
||||||
|
use azalea_physics::PhysicsSet;
|
||||||
use azalea_protocol::packets::game::serverbound_player_action_packet::{
|
use azalea_protocol::packets::game::serverbound_player_action_packet::{
|
||||||
self, ServerboundPlayerActionPacket,
|
self, ServerboundPlayerActionPacket,
|
||||||
};
|
};
|
||||||
|
@ -16,7 +17,7 @@ use crate::{
|
||||||
can_use_game_master_blocks, check_is_interaction_restricted, CurrentSequenceNumber,
|
can_use_game_master_blocks, check_is_interaction_restricted, CurrentSequenceNumber,
|
||||||
HitResultComponent, SwingArmEvent,
|
HitResultComponent, SwingArmEvent,
|
||||||
},
|
},
|
||||||
inventory::InventoryComponent,
|
inventory::{InventoryComponent, InventorySet},
|
||||||
local_player::{LocalGameMode, SendPacketEvent},
|
local_player::{LocalGameMode, SendPacketEvent},
|
||||||
Client,
|
Client,
|
||||||
};
|
};
|
||||||
|
@ -31,7 +32,7 @@ impl Plugin for MinePlugin {
|
||||||
.add_event::<StopMiningBlockEvent>()
|
.add_event::<StopMiningBlockEvent>()
|
||||||
.add_event::<MineBlockProgressEvent>()
|
.add_event::<MineBlockProgressEvent>()
|
||||||
.add_event::<AttackBlockEvent>()
|
.add_event::<AttackBlockEvent>()
|
||||||
.add_systems(FixedUpdate, continue_mining_block)
|
.add_systems(FixedUpdate, continue_mining_block.before(PhysicsSet))
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Update,
|
Update,
|
||||||
(
|
(
|
||||||
|
@ -40,11 +41,23 @@ impl Plugin for MinePlugin {
|
||||||
handle_finish_mining_block_event,
|
handle_finish_mining_block_event,
|
||||||
handle_stop_mining_block_event,
|
handle_stop_mining_block_event,
|
||||||
)
|
)
|
||||||
.chain(),
|
.chain()
|
||||||
|
.in_set(MiningSet)
|
||||||
|
.after(InventorySet)
|
||||||
|
.before(azalea_entity::update_bounding_box)
|
||||||
|
.after(azalea_entity::update_fluid_on_eyes)
|
||||||
|
.after(crate::interact::update_hit_result_component)
|
||||||
|
.after(crate::attack::handle_attack_event)
|
||||||
|
.after(crate::interact::handle_block_interact_event)
|
||||||
|
.before(crate::interact::handle_swing_arm_event)
|
||||||
|
.before(azalea_physics::handle_force_jump),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
|
||||||
|
pub struct MiningSet;
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
pub fn start_mining(&mut self, position: BlockPos) {
|
pub fn start_mining(&mut self, position: BlockPos) {
|
||||||
self.ecs.lock().send_event(StartMiningBlockEvent {
|
self.ecs.lock().send_event(StartMiningBlockEvent {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::client::Client;
|
use crate::client::Client;
|
||||||
use crate::local_player::{update_in_loaded_chunk, LocalPlayer, LocalPlayerInLoadedChunk};
|
use crate::local_player::{LocalPlayer, LocalPlayerInLoadedChunk};
|
||||||
use azalea_entity::{metadata::Sprinting, Attributes, Jumping};
|
use azalea_entity::{metadata::Sprinting, Attributes, Jumping};
|
||||||
use azalea_entity::{LastSentPosition, LookDirection, Physics, Position};
|
use azalea_entity::{LastSentPosition, LookDirection, Physics, Position};
|
||||||
use azalea_physics::{force_jump_listener, PhysicsSet};
|
use azalea_physics::{handle_force_jump, PhysicsSet};
|
||||||
use azalea_protocol::packets::game::serverbound_player_command_packet::ServerboundPlayerCommandPacket;
|
use azalea_protocol::packets::game::serverbound_player_command_packet::ServerboundPlayerCommandPacket;
|
||||||
use azalea_protocol::packets::game::{
|
use azalea_protocol::packets::game::{
|
||||||
serverbound_move_player_pos_packet::ServerboundMovePlayerPosPacket,
|
serverbound_move_player_pos_packet::ServerboundMovePlayerPosPacket,
|
||||||
|
@ -48,7 +48,7 @@ impl Plugin for PlayerMovePlugin {
|
||||||
Update,
|
Update,
|
||||||
(sprint_listener, walk_listener)
|
(sprint_listener, walk_listener)
|
||||||
.chain()
|
.chain()
|
||||||
.before(force_jump_listener),
|
.before(handle_force_jump),
|
||||||
)
|
)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
FixedUpdate,
|
FixedUpdate,
|
||||||
|
@ -56,7 +56,7 @@ impl Plugin for PlayerMovePlugin {
|
||||||
local_player_ai_step
|
local_player_ai_step
|
||||||
.in_set(PhysicsSet)
|
.in_set(PhysicsSet)
|
||||||
.before(azalea_physics::ai_step),
|
.before(azalea_physics::ai_step),
|
||||||
send_position.after(update_in_loaded_chunk),
|
send_position.after(PhysicsSet),
|
||||||
)
|
)
|
||||||
.chain(),
|
.chain(),
|
||||||
);
|
);
|
||||||
|
@ -120,7 +120,7 @@ pub struct PhysicsState {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pub(crate) fn send_position(
|
pub fn send_position(
|
||||||
mut query: Query<
|
mut query: Query<
|
||||||
(
|
(
|
||||||
&MinecraftEntityId,
|
&MinecraftEntityId,
|
||||||
|
|
|
@ -42,6 +42,7 @@ use crate::{
|
||||||
chat::{ChatPacket, ChatReceivedEvent},
|
chat::{ChatPacket, ChatReceivedEvent},
|
||||||
client::{PlayerAbilities, TabList},
|
client::{PlayerAbilities, TabList},
|
||||||
disconnect::DisconnectEvent,
|
disconnect::DisconnectEvent,
|
||||||
|
events::death_listener,
|
||||||
inventory::{
|
inventory::{
|
||||||
ClientSideCloseContainerEvent, InventoryComponent, MenuOpenedEvent,
|
ClientSideCloseContainerEvent, InventoryComponent, MenuOpenedEvent,
|
||||||
SetContainerContentEvent,
|
SetContainerContentEvent,
|
||||||
|
@ -90,7 +91,7 @@ impl Plugin for PacketHandlerPlugin {
|
||||||
// we want to index and deindex right after
|
// we want to index and deindex right after
|
||||||
.before(EntityUpdateSet::Deindex),
|
.before(EntityUpdateSet::Deindex),
|
||||||
)
|
)
|
||||||
.add_systems(Update, death_event_on_0_health)
|
.add_systems(Update, death_event_on_0_health.before(death_listener))
|
||||||
.init_resource::<Events<PacketEvent>>()
|
.init_resource::<Events<PacketEvent>>()
|
||||||
.add_event::<AddPlayerEvent>()
|
.add_event::<AddPlayerEvent>()
|
||||||
.add_event::<RemovePlayerEvent>()
|
.add_event::<RemovePlayerEvent>()
|
||||||
|
|
|
@ -117,7 +117,6 @@ pub fn deduplicate_entities(
|
||||||
entity_id_index.insert(*id, *old_entity);
|
entity_id_index.insert(*id, *old_entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let old_loaded_by = loaded_by_query.get_mut(*old_entity);
|
let old_loaded_by = loaded_by_query.get_mut(*old_entity);
|
||||||
// merge them if possible
|
// merge them if possible
|
||||||
if let Ok(mut old_loaded_by) = old_loaded_by {
|
if let Ok(mut old_loaded_by) = old_loaded_by {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::collections::HashSet;
|
||||||
|
|
||||||
use azalea_core::{BlockPos, Vec3};
|
use azalea_core::{BlockPos, Vec3};
|
||||||
use azalea_world::{InstanceContainer, InstanceName, MinecraftEntityId};
|
use azalea_world::{InstanceContainer, InstanceName, MinecraftEntityId};
|
||||||
use bevy_app::{App, FixedUpdate, Plugin, PostUpdate, PreUpdate, Update};
|
use bevy_app::{App, Plugin, PostUpdate, PreUpdate, Update};
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
@ -68,7 +68,7 @@ impl Plugin for EntityPlugin {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.add_systems(FixedUpdate, update_bounding_box)
|
.add_systems(Update, update_bounding_box)
|
||||||
.init_resource::<EntityUuidIndex>();
|
.init_resource::<EntityUuidIndex>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,12 @@ fn collide(movement: &Vec3, world: &Instance, physics: &azalea_entity::Physics)
|
||||||
let collided_movement = if movement.length_sqr() == 0.0 {
|
let collided_movement = if movement.length_sqr() == 0.0 {
|
||||||
*movement
|
*movement
|
||||||
} else {
|
} else {
|
||||||
collide_bounding_box(movement, &entity_bounding_box, world, entity_collisions.clone())
|
collide_bounding_box(
|
||||||
|
movement,
|
||||||
|
&entity_bounding_box,
|
||||||
|
world,
|
||||||
|
entity_collisions.clone(),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let x_collision = movement.x != collided_movement.x;
|
let x_collision = movement.x != collided_movement.x;
|
||||||
|
@ -70,9 +75,8 @@ fn collide(movement: &Vec3, world: &Instance, physics: &azalea_entity::Physics)
|
||||||
let on_ground = physics.on_ground || y_collision && movement.y < 0.;
|
let on_ground = physics.on_ground || y_collision && movement.y < 0.;
|
||||||
|
|
||||||
let max_up_step = 0.6;
|
let max_up_step = 0.6;
|
||||||
if on_ground && (x_collision || z_collision) {
|
if on_ground && (x_collision || z_collision) {
|
||||||
let mut hypothetical_new_position
|
let mut hypothetical_new_position = collide_bounding_box(
|
||||||
= collide_bounding_box(
|
|
||||||
&Vec3 {
|
&Vec3 {
|
||||||
x: movement.x,
|
x: movement.x,
|
||||||
y: max_up_step,
|
y: max_up_step,
|
||||||
|
@ -104,12 +108,15 @@ fn collide(movement: &Vec3, world: &Instance, physics: &azalea_entity::Physics)
|
||||||
entity_collisions.clone(),
|
entity_collisions.clone(),
|
||||||
)
|
)
|
||||||
.add(step_up_position);
|
.add(step_up_position);
|
||||||
if var11.horizontal_distance_sqr() > hypothetical_new_position.horizontal_distance_sqr() {
|
if var11.horizontal_distance_sqr() > hypothetical_new_position.horizontal_distance_sqr()
|
||||||
|
{
|
||||||
hypothetical_new_position = var11;
|
hypothetical_new_position = var11;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if hypothetical_new_position.horizontal_distance_sqr() > collided_movement.horizontal_distance_sqr() {
|
if hypothetical_new_position.horizontal_distance_sqr()
|
||||||
|
> collided_movement.horizontal_distance_sqr()
|
||||||
|
{
|
||||||
return hypothetical_new_position.add(collide_bounding_box(
|
return hypothetical_new_position.add(collide_bounding_box(
|
||||||
&Vec3 {
|
&Vec3 {
|
||||||
x: 0.,
|
x: 0.,
|
||||||
|
|
|
@ -33,15 +33,11 @@ impl Plugin for PhysicsPlugin {
|
||||||
app.add_event::<ForceJumpEvent>()
|
app.add_event::<ForceJumpEvent>()
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Update,
|
Update,
|
||||||
force_jump_listener.after(azalea_entity::clamp_look_direction),
|
handle_force_jump
|
||||||
|
.after(azalea_entity::clamp_look_direction)
|
||||||
|
.before(azalea_entity::update_bounding_box),
|
||||||
)
|
)
|
||||||
.add_systems(
|
.add_systems(FixedUpdate, (ai_step, travel).chain().in_set(PhysicsSet));
|
||||||
FixedUpdate,
|
|
||||||
(ai_step, travel)
|
|
||||||
.chain()
|
|
||||||
.in_set(PhysicsSet)
|
|
||||||
.after(azalea_entity::update_bounding_box),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +169,7 @@ pub fn ai_step(
|
||||||
#[derive(Event)]
|
#[derive(Event)]
|
||||||
pub struct ForceJumpEvent(pub Entity);
|
pub struct ForceJumpEvent(pub Entity);
|
||||||
|
|
||||||
pub fn force_jump_listener(
|
pub fn handle_force_jump(
|
||||||
mut query: Query<(
|
mut query: Query<(
|
||||||
&mut Physics,
|
&mut Physics,
|
||||||
&Position,
|
&Position,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::app::{App, Plugin};
|
use crate::app::{App, Plugin};
|
||||||
use azalea_client::packet_handling::DeathEvent;
|
use azalea_client::packet_handling::{death_event_on_0_health, DeathEvent};
|
||||||
use azalea_client::respawn::{perform_respawn, PerformRespawnEvent};
|
use azalea_client::respawn::{perform_respawn, PerformRespawnEvent};
|
||||||
use bevy_app::Update;
|
use bevy_app::Update;
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
|
@ -9,7 +9,12 @@ use bevy_ecs::prelude::*;
|
||||||
pub struct AutoRespawnPlugin;
|
pub struct AutoRespawnPlugin;
|
||||||
impl Plugin for AutoRespawnPlugin {
|
impl Plugin for AutoRespawnPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(Update, auto_respawn.before(perform_respawn));
|
app.add_systems(
|
||||||
|
Update,
|
||||||
|
auto_respawn
|
||||||
|
.before(perform_respawn)
|
||||||
|
.after(death_event_on_0_health),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ use azalea_core::{BlockPos, Vec3};
|
||||||
use azalea_entity::{
|
use azalea_entity::{
|
||||||
clamp_look_direction, metadata::Player, EyeHeight, Jumping, Local, LookDirection, Position,
|
clamp_look_direction, metadata::Player, EyeHeight, Jumping, Local, LookDirection, Position,
|
||||||
};
|
};
|
||||||
use azalea_physics::{force_jump_listener, PhysicsSet};
|
use azalea_physics::{handle_force_jump, PhysicsSet};
|
||||||
use bevy_app::{FixedUpdate, Update};
|
use bevy_app::{FixedUpdate, Update};
|
||||||
use bevy_ecs::prelude::Event;
|
use bevy_ecs::prelude::Event;
|
||||||
use bevy_ecs::schedule::IntoSystemConfigs;
|
use bevy_ecs::schedule::IntoSystemConfigs;
|
||||||
|
@ -35,9 +35,9 @@ impl Plugin for BotPlugin {
|
||||||
(
|
(
|
||||||
insert_bot,
|
insert_bot,
|
||||||
look_at_listener
|
look_at_listener
|
||||||
.before(force_jump_listener)
|
.before(handle_force_jump)
|
||||||
.before(clamp_look_direction),
|
.before(clamp_look_direction),
|
||||||
jump_listener,
|
jump_listener.before(handle_force_jump),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.add_systems(FixedUpdate, stop_jumping.after(PhysicsSet));
|
.add_systems(FixedUpdate, stop_jumping.after(PhysicsSet));
|
||||||
|
@ -138,7 +138,10 @@ impl BotClientExt for azalea_client::Client {
|
||||||
#[derive(Event)]
|
#[derive(Event)]
|
||||||
pub struct JumpEvent(pub Entity);
|
pub struct JumpEvent(pub Entity);
|
||||||
|
|
||||||
fn jump_listener(mut query: Query<(&mut Jumping, &mut Bot)>, mut events: EventReader<JumpEvent>) {
|
pub fn jump_listener(
|
||||||
|
mut query: Query<(&mut Jumping, &mut Bot)>,
|
||||||
|
mut events: EventReader<JumpEvent>,
|
||||||
|
) {
|
||||||
for event in events.iter() {
|
for event in events.iter() {
|
||||||
if let Ok((mut jumping, mut bot)) = query.get_mut(event.0) {
|
if let Ok((mut jumping, mut bot)) = query.get_mut(event.0) {
|
||||||
**jumping = true;
|
**jumping = true;
|
||||||
|
|
|
@ -16,6 +16,7 @@ use crate::ecs::{
|
||||||
system::{Commands, Query, Res},
|
system::{Commands, Query, Res},
|
||||||
};
|
};
|
||||||
use astar::Edge;
|
use astar::Edge;
|
||||||
|
use azalea_client::movement::walk_listener;
|
||||||
use azalea_client::{StartSprintEvent, StartWalkEvent};
|
use azalea_client::{StartSprintEvent, StartWalkEvent};
|
||||||
use azalea_core::{BlockPos, CardinalDirection};
|
use azalea_core::{BlockPos, CardinalDirection};
|
||||||
use azalea_entity::metadata::Player;
|
use azalea_entity::metadata::Player;
|
||||||
|
@ -43,16 +44,20 @@ impl Plugin for PathfinderPlugin {
|
||||||
FixedUpdate,
|
FixedUpdate,
|
||||||
// putting systems in the FixedUpdate schedule makes them run every Minecraft tick
|
// putting systems in the FixedUpdate schedule makes them run every Minecraft tick
|
||||||
// (every 50 milliseconds).
|
// (every 50 milliseconds).
|
||||||
tick_execute_path.after(PhysicsSet),
|
tick_execute_path
|
||||||
|
.after(PhysicsSet)
|
||||||
|
.after(azalea_client::movement::send_position),
|
||||||
)
|
)
|
||||||
.add_systems(PreUpdate, add_default_pathfinder)
|
.add_systems(PreUpdate, add_default_pathfinder)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Update,
|
Update,
|
||||||
(
|
(
|
||||||
goto_listener,
|
goto_listener,
|
||||||
(handle_tasks, path_found_listener).chain(),
|
handle_tasks,
|
||||||
stop_pathfinding_on_instance_change,
|
path_found_listener,
|
||||||
),
|
stop_pathfinding_on_instance_change.before(walk_listener),
|
||||||
|
)
|
||||||
|
.chain(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
210
tick.svg
Normal file
210
tick.svg
Normal file
|
@ -0,0 +1,210 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||||
|
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<!-- Generated by graphviz version 8.1.0 (0)
|
||||||
|
-->
|
||||||
|
<!-- Pages: 1 -->
|
||||||
|
<svg width="752pt" height="251pt"
|
||||||
|
viewBox="0.00 0.00 752.25 250.80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 246.8)">
|
||||||
|
<polygon fill="#0d1117" stroke="none" points="-4,4 -4,-246.8 748.25,-246.8 748.25,4 -4,4"/>
|
||||||
|
<g id="clust1" class="cluster">
|
||||||
|
<title>clusternode_Set(1)</title>
|
||||||
|
<g id="a_clust1"><a xlink:title="PhysicsSet">
|
||||||
|
<path fill="#ffffff" fill-opacity="0.266667" stroke="#ffffff" stroke-width="2" stroke-opacity="0.313725" d="M216.5,-111.8C216.5,-111.8 710.12,-111.8 710.12,-111.8 716.12,-111.8 722.12,-117.8 722.12,-123.8 722.12,-123.8 722.12,-186.8 722.12,-186.8 722.12,-192.8 716.12,-198.8 710.12,-198.8 710.12,-198.8 216.5,-198.8 216.5,-198.8 210.5,-198.8 204.5,-192.8 204.5,-186.8 204.5,-186.8 204.5,-123.8 204.5,-123.8 204.5,-117.8 210.5,-111.8 216.5,-111.8"/>
|
||||||
|
<text text-anchor="middle" x="463.31" y="-181.5" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#ffffff">PhysicsSet</text>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- set_marker_node_Set(1) -->
|
||||||
|
<!-- node_System(4) -->
|
||||||
|
<g id="node6" class="node">
|
||||||
|
<title>node_System(4)</title>
|
||||||
|
<g id="a_node6"><a xlink:title="azalea_client::movement::send_position">
|
||||||
|
<polygon fill="lightgrey" stroke="black" points="552,-103.8 461,-103.8 461,-67.8 552,-67.8 552,-103.8"/>
|
||||||
|
<text text-anchor="middle" x="506.5" y="-80.75" font-family="Times,serif" font-size="14.00">send_position</text>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- set_marker_node_Set(1)->node_System(4) -->
|
||||||
|
<g id="edge3" class="edge">
|
||||||
|
<title>set_marker_node_Set(1)->node_System(4)</title>
|
||||||
|
<g id="a_edge3"><a xlink:title="PhysicsSet → send_position">
|
||||||
|
<path fill="none" stroke="#00b0cc" stroke-width="2" d="M335.33,-111.8C369.11,-106.64 413.06,-99.92 447.84,-94.61"/>
|
||||||
|
<polygon fill="#00b0cc" stroke="#00b0cc" stroke-width="2" points="449.3,-97.62 458.66,-92.65 448.24,-90.7 449.3,-97.62"/>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(7) -->
|
||||||
|
<g id="node9" class="node">
|
||||||
|
<title>node_System(7)</title>
|
||||||
|
<g id="a_node9"><a xlink:title="azalea_client::attack::update_attack_strength_scale">
|
||||||
|
<polygon fill="lightgrey" stroke="black" points="594,-242.8 419,-242.8 419,-206.8 594,-206.8 594,-242.8"/>
|
||||||
|
<text text-anchor="middle" x="506.5" y="-219.75" font-family="Times,serif" font-size="14.00">update_attack_strength_scale</text>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- set_marker_node_Set(1)->node_System(7) -->
|
||||||
|
<g id="edge6" class="edge">
|
||||||
|
<title>set_marker_node_Set(1)->node_System(7)</title>
|
||||||
|
<g id="a_edge6"><a xlink:title="PhysicsSet → update_attack_strength_scale">
|
||||||
|
<path fill="none" stroke="#0090cc" stroke-width="2" d="M283.05,-119.78C284.96,-119.22 346.62,-101.35 418.35,-198.8"/>
|
||||||
|
<polygon fill="#0090cc" stroke="#0090cc" stroke-width="2" points="414.85,-200.16 424.59,-204.31 419.56,-194.99 414.85,-200.16"/>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(9) -->
|
||||||
|
<g id="node11" class="node">
|
||||||
|
<title>node_System(9)</title>
|
||||||
|
<g id="a_node11"><a xlink:title="azalea::bot::stop_jumping">
|
||||||
|
<polygon fill="lightgrey" stroke="black" points="552,-56.8 461,-56.8 461,-20.8 552,-20.8 552,-56.8"/>
|
||||||
|
<text text-anchor="middle" x="506.5" y="-33.75" font-family="Times,serif" font-size="14.00">stop_jumping</text>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- set_marker_node_Set(1)->node_System(9) -->
|
||||||
|
<g id="edge8" class="edge">
|
||||||
|
<title>set_marker_node_Set(1)->node_System(9)</title>
|
||||||
|
<g id="a_edge8"><a xlink:title="PhysicsSet → stop_jumping">
|
||||||
|
<path fill="none" stroke="#663699" stroke-width="2" d="M299.6,-111.8C324.92,-99.81 374.91,-76.97 419,-61.8 428.4,-58.56 438.51,-55.5 448.38,-52.74"/>
|
||||||
|
<polygon fill="#663699" stroke="#663699" stroke-width="2" points="449.95,-55.4 458.68,-49.41 448.12,-48.64 449.95,-55.4"/>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(10) -->
|
||||||
|
<g id="node12" class="node">
|
||||||
|
<title>node_System(10)</title>
|
||||||
|
<g id="a_node12"><a xlink:title="azalea::pathfinder::tick_execute_path">
|
||||||
|
<polygon fill="lightgrey" stroke="black" points="744.25,-62.8 630,-62.8 630,-26.8 744.25,-26.8 744.25,-62.8"/>
|
||||||
|
<text text-anchor="middle" x="687.12" y="-39.75" font-family="Times,serif" font-size="14.00">tick_execute_path</text>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- set_marker_node_Set(1)->node_System(10) -->
|
||||||
|
<g id="edge9" class="edge">
|
||||||
|
<title>set_marker_node_Set(1)->node_System(10)</title>
|
||||||
|
<g id="a_edge9"><a xlink:title="PhysicsSet → tick_execute_path">
|
||||||
|
<path fill="none" stroke="#3363bb" stroke-width="2" d="M289.72,-111.8C307.91,-90.86 360.67,-34.69 419,-14.8 492.61,10.31 517.18,-2.6 594,-14.8 604.75,-16.5 615.94,-19.26 626.68,-22.43"/>
|
||||||
|
<polygon fill="#3363bb" stroke="#3363bb" stroke-width="2" points="626.42,-26.65 637.01,-26.31 628.52,-19.97 626.42,-26.65"/>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(0) -->
|
||||||
|
<g id="node2" class="node">
|
||||||
|
<title>node_System(0)</title>
|
||||||
|
<g id="a_node2"><a xlink:title="azalea_physics::ai_step">
|
||||||
|
<polygon fill="#eff1f3" stroke="#b4bec7" points="536.25,-166.8 476.75,-166.8 476.75,-130.8 536.25,-130.8 536.25,-166.8"/>
|
||||||
|
<text text-anchor="middle" x="506.5" y="-143.37" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#15191d">ai_step</text>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(1) -->
|
||||||
|
<g id="node3" class="node">
|
||||||
|
<title>node_System(1)</title>
|
||||||
|
<g id="a_node3"><a xlink:title="azalea_physics::travel">
|
||||||
|
<polygon fill="#eff1f3" stroke="#b4bec7" points="714.12,-166.8 660.12,-166.8 660.12,-130.8 714.12,-130.8 714.12,-166.8"/>
|
||||||
|
<text text-anchor="middle" x="687.12" y="-143.37" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#15191d">travel</text>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(0)->node_System(1) -->
|
||||||
|
<g id="edge1" class="edge">
|
||||||
|
<title>node_System(0)->node_System(1)</title>
|
||||||
|
<g id="a_edge1"><a xlink:title="ai_step → travel">
|
||||||
|
<path fill="none" stroke="#eede00" stroke-width="2" d="M536.6,-148.8C566.57,-148.8 613.49,-148.8 646.77,-148.8"/>
|
||||||
|
<polygon fill="#eede00" stroke="#eede00" stroke-width="2" points="646.66,-152.3 656.66,-148.8 646.66,-145.3 646.66,-152.3"/>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(3) -->
|
||||||
|
<g id="node4" class="node">
|
||||||
|
<title>node_System(3)</title>
|
||||||
|
<g id="a_node4"><a xlink:title="azalea_client::movement::local_player_ai_step">
|
||||||
|
<polygon fill="#eff1f3" stroke="#b4bec7" points="351.5,-166.8 212.5,-166.8 212.5,-130.8 351.5,-130.8 351.5,-166.8"/>
|
||||||
|
<text text-anchor="middle" x="282" y="-143.37" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#15191d">local_player_ai_step</text>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(3)->node_System(0) -->
|
||||||
|
<g id="edge2" class="edge">
|
||||||
|
<title>node_System(3)->node_System(0)</title>
|
||||||
|
<g id="a_edge2"><a xlink:title="local_player_ai_step → SystemTypeSet(ai_step")">
|
||||||
|
<path fill="none" stroke="#881877" stroke-width="2" d="M351.88,-148.8C388.51,-148.8 432.34,-148.8 463.79,-148.8"/>
|
||||||
|
<polygon fill="#881877" stroke="#881877" stroke-width="2" points="463.46,-152.3 473.46,-148.8 463.46,-145.3 463.46,-152.3"/>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(3)->node_System(4) -->
|
||||||
|
<g id="edge4" class="edge">
|
||||||
|
<title>node_System(3)->node_System(4)</title>
|
||||||
|
<g id="a_edge4"><a xlink:title="local_player_ai_step → send_position">
|
||||||
|
<path fill="none" stroke="#aa3a55" stroke-width="2" d="M351.8,-134.81C362.34,-132.14 373.03,-129.12 383,-125.8 399.61,-120.25 402.52,-115.71 419,-109.8 428.39,-106.43 438.48,-103.25 448.35,-100.36"/>
|
||||||
|
<polygon fill="#aa3a55" stroke="#aa3a55" stroke-width="2" points="449.99,-102.97 458.66,-96.89 448.08,-96.24 449.99,-102.97"/>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(2) -->
|
||||||
|
<g id="node5" class="node">
|
||||||
|
<title>node_System(2)</title>
|
||||||
|
<g id="a_node5"><a xlink:title="azalea_client::events::tick_listener">
|
||||||
|
<polygon fill="lightgrey" stroke="black" points="113.88,-184.8 31.12,-184.8 31.12,-148.8 113.88,-148.8 113.88,-184.8"/>
|
||||||
|
<text text-anchor="middle" x="72.5" y="-161.75" font-family="Times,serif" font-size="14.00">tick_listener</text>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(4)->node_System(10) -->
|
||||||
|
<g id="edge10" class="edge">
|
||||||
|
<title>node_System(4)->node_System(10)</title>
|
||||||
|
<g id="a_edge10"><a xlink:title="SystemTypeSet(send_position") → tick_execute_path">
|
||||||
|
<path fill="none" stroke="#22c2bb" stroke-width="2" d="M552.11,-75.56C571.72,-71.05 595.2,-65.67 616.99,-60.66"/>
|
||||||
|
<polygon fill="#22c2bb" stroke="#22c2bb" stroke-width="2" points="618.62,-63.42 627.59,-57.77 617.06,-56.6 618.62,-63.42"/>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(5) -->
|
||||||
|
<g id="node7" class="node">
|
||||||
|
<title>node_System(5)</title>
|
||||||
|
<g id="a_node7"><a xlink:title="azalea_client::mining::continue_mining_block">
|
||||||
|
<polygon fill="lightgrey" stroke="black" points="145,-137.8 0,-137.8 0,-101.8 145,-101.8 145,-137.8"/>
|
||||||
|
<text text-anchor="middle" x="72.5" y="-114.75" font-family="Times,serif" font-size="14.00">continue_mining_block</text>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(5)->set_marker_node_Set(1) -->
|
||||||
|
<g id="edge5" class="edge">
|
||||||
|
<title>node_System(5)->set_marker_node_Set(1)</title>
|
||||||
|
<g id="a_edge5"><a xlink:title="continue_mining_block → PhysicsSet">
|
||||||
|
<path fill="none" stroke="#44d488" stroke-width="2" d="M145.49,-119.8C160.39,-119.8 176.25,-119.8 191.68,-119.8"/>
|
||||||
|
<polygon fill="#44d488" stroke="#44d488" stroke-width="2" points="191.5,-123.3 201.5,-119.8 191.5,-116.3 191.5,-123.3"/>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(6) -->
|
||||||
|
<g id="node8" class="node">
|
||||||
|
<title>node_System(6)</title>
|
||||||
|
<g id="a_node8"><a xlink:title="azalea_client::attack::increment_ticks_since_last_attack">
|
||||||
|
<polygon fill="lightgrey" stroke="black" points="383,-242.8 181,-242.8 181,-206.8 383,-206.8 383,-242.8"/>
|
||||||
|
<text text-anchor="middle" x="282" y="-219.75" font-family="Times,serif" font-size="14.00">increment_ticks_since_last_attack</text>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(6)->node_System(7) -->
|
||||||
|
<g id="edge7" class="edge">
|
||||||
|
<title>node_System(6)->node_System(7)</title>
|
||||||
|
<g id="a_edge7"><a xlink:title="increment_ticks_since_last_attack → update_attack_strength_scale">
|
||||||
|
<path fill="none" stroke="#ee9e44" stroke-width="2" d="M383.18,-224.8C390.7,-224.8 398.29,-224.8 405.8,-224.8"/>
|
||||||
|
<polygon fill="#ee9e44" stroke="#ee9e44" stroke-width="2" points="405.79,-228.3 415.79,-224.8 405.79,-221.3 405.79,-228.3"/>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<!-- node_System(8) -->
|
||||||
|
<g id="node10" class="node">
|
||||||
|
<title>node_System(8)</title>
|
||||||
|
<g id="a_node10"><a xlink:title="azalea_client::client::send_tick_broadcast">
|
||||||
|
<polygon fill="lightgrey" stroke="black" points="135.62,-231.8 9.38,-231.8 9.38,-195.8 135.62,-195.8 135.62,-231.8"/>
|
||||||
|
<text text-anchor="middle" x="72.5" y="-208.75" font-family="Times,serif" font-size="14.00">send_tick_broadcast</text>
|
||||||
|
</a>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 10 KiB |
1137
update.svg
Normal file
1137
update.svg
Normal file
File diff suppressed because it is too large
Load diff
After Width: | Height: | Size: 63 KiB |
Loading…
Add table
Reference in a new issue