mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
still errors with lots of bots
This commit is contained in:
parent
155b620b38
commit
8e7c21750c
4 changed files with 15 additions and 14 deletions
|
@ -60,7 +60,7 @@ pub enum Event {
|
|||
/// it's actually spawned. This can be useful for setting the client
|
||||
/// information with `Client::set_client_information`, so the packet
|
||||
/// doesn't have to be sent twice.
|
||||
Initialize,
|
||||
Init,
|
||||
Login,
|
||||
Chat(ChatPacket),
|
||||
/// Happens 20 times per second, but only when the world is loaded.
|
||||
|
@ -242,9 +242,7 @@ impl Client {
|
|||
// we got the GameConnection, so the server is now connected :)
|
||||
let client = Client::new(game_profile, conn, None);
|
||||
|
||||
tx.send(Event::Initialize)
|
||||
.await
|
||||
.expect("Failed to send event");
|
||||
tx.send(Event::Init).await.expect("Failed to send event");
|
||||
|
||||
// just start up the game loop and we're ready!
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::{Client, Event};
|
|||
use async_trait::async_trait;
|
||||
use azalea_core::{BlockPos, CardinalDirection};
|
||||
use azalea_world::entity::EntityData;
|
||||
use log::{debug, };
|
||||
use log::debug;
|
||||
use mtdstarlite::Edge;
|
||||
pub use mtdstarlite::MTDStarLite;
|
||||
use parking_lot::Mutex;
|
||||
|
|
|
@ -266,9 +266,7 @@ where
|
|||
// rx is used to receive events from the bot
|
||||
let (tx, mut rx) = mpsc::channel(1);
|
||||
let mut bot = Client::new(game_profile, conn, Some(self.worlds.clone()));
|
||||
tx.send(Event::Initialize)
|
||||
.await
|
||||
.expect("Failed to send event");
|
||||
tx.send(Event::Init).await.expect("Failed to send event");
|
||||
bot.start_tasks(tx);
|
||||
|
||||
bot.plugins = Arc::new(self.plugins.clone().build());
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use azalea::pathfinder::BlockPosGoal;
|
||||
use azalea::ClientInformation;
|
||||
use azalea::{prelude::*, BlockPos, Swarm, SwarmEvent, WalkDirection};
|
||||
use azalea::{Account, Client, Event};
|
||||
use azalea_protocol::packets::game::serverbound_client_command_packet::ServerboundClientCommandPacket;
|
||||
|
@ -41,7 +42,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
let mut accounts = Vec::new();
|
||||
let mut states = Vec::new();
|
||||
|
||||
for i in 0..5 {
|
||||
for i in 0..10 {
|
||||
accounts.push(Account::offline(&format!("bot{}", i)));
|
||||
states.push(State::default());
|
||||
}
|
||||
|
@ -60,8 +61,8 @@ async fn main() -> anyhow::Result<()> {
|
|||
handle,
|
||||
swarm_handle,
|
||||
|
||||
// join_delay: Some(Duration::from_millis(100)),
|
||||
join_delay: None,
|
||||
join_delay: Some(Duration::from_millis(1000)),
|
||||
// join_delay: None,
|
||||
})
|
||||
.await;
|
||||
println!("{e:?}");
|
||||
|
@ -70,6 +71,13 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
async fn handle(mut bot: Client, event: Event, _state: State) -> anyhow::Result<()> {
|
||||
match event {
|
||||
Event::Init => {
|
||||
bot.set_client_information(ClientInformation {
|
||||
view_distance: 2,
|
||||
..Default::default()
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
Event::Login => {
|
||||
bot.chat("Hello world").await?;
|
||||
}
|
||||
|
@ -105,9 +113,6 @@ async fn handle(mut bot: Client, event: Event, _state: State) -> anyhow::Result<
|
|||
}
|
||||
}
|
||||
}
|
||||
Event::Initialize => {
|
||||
println!("initialized");
|
||||
}
|
||||
Event::Death(_) => {
|
||||
bot.write_packet(ServerboundClientCommandPacket {
|
||||
action: azalea_protocol::packets::game::serverbound_client_command_packet::Action::PerformRespawn,
|
||||
|
|
Loading…
Add table
Reference in a new issue