mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
add note about current_thread to azalea readme
This commit is contained in:
parent
a2606569bb
commit
5e81d85d7e
13 changed files with 22 additions and 21 deletions
|
@ -153,7 +153,7 @@ impl Client {
|
|||
/// ```rust,no_run
|
||||
/// use azalea_client::{Account, Client};
|
||||
///
|
||||
/// #[tokio::main]
|
||||
/// #[tokio::main(flavor = "current_thread")]
|
||||
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
/// let account = Account::offline("bot");
|
||||
/// let (client, rx) = Client::join(account, "localhost").await?;
|
||||
|
|
|
@ -144,7 +144,7 @@ impl BlockStatePredictionHandler {
|
|||
.or_insert(ServerVerifiedState {
|
||||
seq: self.seq,
|
||||
block_state: old_state,
|
||||
player_pos: player_pos,
|
||||
player_pos,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ fn travel_in_fluid(
|
|||
move_relative(physics, direction, speed, acceleration);
|
||||
move_colliding(
|
||||
MoverType::Own,
|
||||
physics.velocity.clone(),
|
||||
physics.velocity,
|
||||
world,
|
||||
&mut position,
|
||||
physics,
|
||||
|
|
|
@ -46,7 +46,7 @@ use std::sync::Arc;
|
|||
use azalea::prelude::*;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
#[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
let account = Account::offline("bot");
|
||||
// or Account::microsoft("example@example.com").await.unwrap();
|
||||
|
@ -110,5 +110,9 @@ If your code is simply hanging, it might be a deadlock. Enable `parking_lot`'s `
|
|||
|
||||
Backtraces are also useful, though they're sometimes hard to read and don't always contain the actual location of the error. Run your code with `RUST_BACKTRACE=1` to enable full backtraces. If it's very long, often searching for the keyword "azalea" will help you filter out unrelated things and find the actual source of the issue.
|
||||
|
||||
# Using a single-threaded Tokio runtime
|
||||
|
||||
Due to the fact that Azalea clients store the ECS in a Mutex that's frequently locked and unlocked, bots that rely on the `Client` or `Swarm` types may run into race condition bugs (like out-of-order events and ticks happening at suboptimal moments) if they do not set Tokio to use a single thread with `#[tokio::main(flavor = "current_thread")]`. This may change in a future version of Azalea. Setting this option will usually not result in a performance hit, and Azalea internally will keep using multiple threads for running the ECS itself (because Tokio is not used for this).
|
||||
|
||||
[`azalea_client`]: https://docs.rs/azalea-client
|
||||
[`bevy_log`]: https://docs.rs/bevy_log
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use azalea::prelude::*;
|
||||
|
||||
#[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
let account = Account::offline("bot");
|
||||
// or let account = Account::microsoft("email").await.unwrap();
|
||||
|
|
|
@ -12,7 +12,7 @@ use bevy_ecs::{
|
|||
system::Query,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
let account = Account::offline("bot");
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use azalea::{BlockPos, pathfinder::goals::RadiusGoal, prelude::*};
|
|||
use azalea_inventory::{ItemStack, operations::QuickMoveClick};
|
||||
use parking_lot::Mutex;
|
||||
|
||||
#[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
let account = Account::offline("bot");
|
||||
// or let bot = Account::microsoft("email").await.unwrap();
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
//! only have this on if the bot has operator permissions, otherwise it'll
|
||||
//! just spam the server console unnecessarily.
|
||||
|
||||
#![feature(trivial_bounds)]
|
||||
|
||||
mod commands;
|
||||
pub mod killaura;
|
||||
|
||||
|
@ -34,7 +32,7 @@ use azalea::{
|
|||
use commands::{CommandSource, register_commands};
|
||||
use parking_lot::Mutex;
|
||||
|
||||
#[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
let args = parse_args();
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use azalea::pathfinder;
|
||||
use azalea::prelude::*;
|
||||
use azalea::{pathfinder, prelude::*};
|
||||
use parking_lot::Mutex;
|
||||
|
||||
#[derive(Default, Clone, Component)]
|
||||
|
@ -9,7 +8,7 @@ struct State {
|
|||
pub started: Arc<Mutex<bool>>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
let account = Account::offline("bot");
|
||||
// or let bot = Account::microsoft("email").await;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use azalea::{prelude::*, swarm::prelude::*};
|
||||
|
||||
#[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
let mut accounts = Vec::new();
|
||||
let mut states = Vec::new();
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
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::*};
|
||||
use azalea::{
|
||||
Account, Client, Event, GameProfileComponent, ecs::query::With, entity::metadata::Player,
|
||||
pathfinder, prelude::*, swarm::prelude::*,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
let mut accounts = Vec::new();
|
||||
let mut states = Vec::new();
|
||||
|
|
|
@ -59,7 +59,7 @@ pub enum StartError {
|
|||
///
|
||||
/// ```no_run
|
||||
/// # use azalea::prelude::*;
|
||||
/// # #[tokio::main]
|
||||
/// # #[tokio::main(flavor = "current_thread")]
|
||||
/// # async fn main() {
|
||||
/// ClientBuilder::new()
|
||||
/// .set_handler(handle)
|
||||
|
|
|
@ -636,7 +636,7 @@ pub type BoxSwarmHandleFn<SS, R> =
|
|||
/// #[derive(Default, Clone, Resource)]
|
||||
/// struct SwarmState {}
|
||||
///
|
||||
/// #[tokio::main]
|
||||
/// #[tokio::main(flavor = "current_thread")]
|
||||
/// async fn main() {
|
||||
/// let mut accounts = Vec::new();
|
||||
/// let mut states = Vec::new();
|
||||
|
|
Loading…
Add table
Reference in a new issue