1
2
Fork 0
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:
mat 2022-11-23 22:57:23 -06:00
parent 155b620b38
commit 8e7c21750c
4 changed files with 15 additions and 14 deletions

View file

@ -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!

View file

@ -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;

View file

@ -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());

View file

@ -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,