aboutsummaryrefslogtreecommitdiff
path: root/azalea/examples/pvp.rs
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2023-03-07 22:09:56 -0600
committerGitHub <noreply@github.com>2023-03-07 22:09:56 -0600
commit5dd35c7ed82c38ef36ca28f630e8d05c5db2cbea (patch)
tree72719e46479e7884ea535c768ab7c244ce048063 /azalea/examples/pvp.rs
parent719379a8a76ab0685f2bd14bebe2f0cd1e97f06b (diff)
downloadazalea-drasl-5dd35c7ed82c38ef36ca28f630e8d05c5db2cbea.tar.xz
Add World::find_block (#80)
* start adding World::find_block * keep working on find_block * BlockStates * fix sorting * update examples that use find_one_block * azalea_block::properties * fix tests * add a gotoblock command to testbot
Diffstat (limited to 'azalea/examples/pvp.rs')
-rwxr-xr-xazalea/examples/pvp.rs65
1 files changed, 0 insertions, 65 deletions
diff --git a/azalea/examples/pvp.rs b/azalea/examples/pvp.rs
deleted file mode 100755
index fb5a768d..00000000
--- a/azalea/examples/pvp.rs
+++ /dev/null
@@ -1,65 +0,0 @@
-use std::time::Duration;
-
-use azalea::ecs::query::With;
-use azalea::entity::metadata::Player;
-use azalea::{pathfinder, Account, Client, Event, GameProfileComponent};
-use azalea::{prelude::*, swarm::prelude::*};
-
-#[tokio::main]
-async fn main() {
- let mut accounts = Vec::new();
- let mut states = Vec::new();
-
- for i in 0..10 {
- accounts.push(Account::offline(&format!("bot{i}")));
- states.push(State::default());
- }
-
- SwarmBuilder::new()
- .add_accounts(accounts.clone())
- .set_handler(handle)
- .set_swarm_handler(swarm_handle)
- .join_delay(Duration::from_millis(1000))
- .start("localhost")
- .await
- .unwrap();
-}
-
-#[derive(Component, Default, Clone)]
-struct State {}
-
-#[derive(Resource, Default, Clone)]
-struct SwarmState {}
-
-async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> {
- Ok(())
-}
-async fn swarm_handle(swarm: Swarm, event: SwarmEvent, state: SwarmState) -> anyhow::Result<()> {
- match event {
- SwarmEvent::Tick => {
- if let Some(target_entity) =
- swarm.entity_by::<With<Player>>(|profile: &&GameProfileComponent| {
- profile.name == "Herobrine"
- })
- {
- let target_bounding_box =
- swarm.map_entity(target_entity, |bb: &BoundingBox| bb.clone());
-
- for (bot, bot_state) in swarm {
- bot.tick_goto_goal(pathfinder::Goals::Reach(target_bounding_box));
- // if target.bounding_box.distance(bot.eyes) < bot.reach_distance() {
- if azalea::entities::can_reach(bot.entity(), target_bounding_box) {
- bot.swing();
- }
- if !bot.using_held_item() && bot.hunger() <= 17 {
- bot.hold(azalea::ItemGroup::Food);
- tokio::task::spawn(bot.use_held_item());
- }
- }
- }
- }
- _ => {}
- }
-
- Ok(())
-}