diff options
| author | mat <git@matdoes.dev> | 2025-08-09 22:08:48 -0900 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-08-09 22:08:48 -0900 |
| commit | 3b659833c1ad4cca89b4cd553193edcb6d223163 (patch) | |
| tree | 6035c6797703dcf0b0240999bae34893f29cd9e8 | |
| parent | 45cb5823f50ece7af86804d4331bd7ba2f6c5917 (diff) | |
| download | azalea-drasl-3b659833c1ad4cca89b4cd553193edcb6d223163.tar.xz | |
clippy
| -rw-r--r-- | azalea-core/src/math.rs | 2 | ||||
| -rw-r--r-- | azalea-entity/src/lib.rs | 5 | ||||
| -rw-r--r-- | azalea/examples/testbot/commands/debug.rs | 24 | ||||
| -rw-r--r-- | azalea/examples/testbot/commands/movement.rs | 4 | ||||
| -rw-r--r-- | azalea/examples/testbot/main.rs | 2 |
5 files changed, 19 insertions, 18 deletions
diff --git a/azalea-core/src/math.rs b/azalea-core/src/math.rs index 4422c371..d5fe5af9 100644 --- a/azalea-core/src/math.rs +++ b/azalea-core/src/math.rs @@ -1,10 +1,10 @@ use std::{ + f64::consts::PI, ops::{Add, Div, Sub}, sync::LazyLock, }; pub const EPSILON: f64 = 1.0e-7; -pub const PI: f64 = 3.141592653589793; pub static SIN: LazyLock<[f32; 65536]> = LazyLock::new(|| std::array::from_fn(|i| f64::sin((i as f64) * PI * 2. / 65536.) as f32)); diff --git a/azalea-entity/src/lib.rs b/azalea-entity/src/lib.rs index 095098f1..984cce27 100644 --- a/azalea-entity/src/lib.rs +++ b/azalea-entity/src/lib.rs @@ -12,6 +12,7 @@ mod plugin; pub mod vec_delta_codec; use std::{ + f64::consts::PI, fmt::{self, Debug}, hash::{Hash, Hasher}, }; @@ -59,8 +60,8 @@ pub fn input_vector(direction: LookDirection, speed: f32, acceleration: Vec3) -> acceleration } .scale(speed as f64); - let y_rot = math::sin(direction.y_rot * (3.141592653589793 / 180.) as f32); - let x_rot = math::cos(direction.y_rot * (3.141592653589793 / 180.) as f32); + let y_rot = math::sin(direction.y_rot * (PI / 180.) as f32); + let x_rot = math::cos(direction.y_rot * (PI / 180.) as f32); Vec3 { x: acceleration.x * (x_rot as f64) - acceleration.z * (y_rot as f64), y: acceleration.y, diff --git a/azalea/examples/testbot/commands/debug.rs b/azalea/examples/testbot/commands/debug.rs index d0d72b40..92a5b92e 100644 --- a/azalea/examples/testbot/commands/debug.rs +++ b/azalea/examples/testbot/commands/debug.rs @@ -42,7 +42,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { return 0; }; let position = source.bot.entity_component::<Position>(entity); - source.reply(&format!( + source.reply(format!( "You are at {}, {}, {}", position.x, position.y, position.z )); @@ -56,7 +56,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { return 0; }; let entity_id = source.bot.entity_component::<MinecraftEntityId>(entity); - source.reply(&format!( + source.reply(format!( "Your Minecraft ID is {} and your ECS id is {entity:?}", *entity_id )); @@ -66,7 +66,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { let whereareyou = |ctx: &Ctx| { let source = ctx.source.lock(); let position = source.bot.position(); - source.reply(&format!( + source.reply(format!( "I'm at {}, {}, {}", position.x, position.y, position.z )); @@ -77,7 +77,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { commands.register(literal("whoareyou").executes(|ctx: &Ctx| { let source = ctx.source.lock(); - source.reply(&format!( + source.reply(format!( "I am {} ({})", source.bot.username(), source.bot.uuid() @@ -88,7 +88,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { commands.register(literal("getdirection").executes(|ctx: &Ctx| { let source = ctx.source.lock(); let direction = source.bot.component::<LookDirection>(); - source.reply(&format!( + source.reply(format!( "I'm looking at {}, {}", direction.y_rot, direction.x_rot )); @@ -99,7 +99,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { let source = ctx.source.lock(); let health = source.bot.health(); - source.reply(&format!("I have {health} health")); + source.reply(format!("I have {health} health")); 1 })); @@ -116,11 +116,11 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { } let block_pos = r.block_pos; let block = source.bot.world().read().get_block_state(block_pos); - source.reply(&format!("I'm looking at {block:?} at {block_pos:?}")); + source.reply(format!("I'm looking at {block:?} at {block_pos:?}")); } HitResult::Entity(r) => { let entity_kind = *source.bot.entity_component::<EntityKindComponent>(r.entity); - source.reply(&format!( + source.reply(format!( "I'm looking at {entity_kind} ({:?}) at {}", r.entity, r.location )); @@ -139,7 +139,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { println!("getblock xyz {x} {y} {z}"); let block_pos = BlockPos::new(x, y, z); let block = source.bot.world().read().get_block_state(block_pos); - source.reply(&format!("Block at {block_pos} is {block:?}")); + source.reply(format!("Block at {block_pos} is {block:?}")); 1 })), ))); @@ -152,7 +152,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { println!("getfluid xyz {x} {y} {z}"); let block_pos = BlockPos::new(x, y, z); let block = source.bot.world().read().get_fluid_state(block_pos); - source.reply(&format!("Fluid at {block_pos} is {block:?}")); + source.reply(format!("Fluid at {block_pos} is {block:?}")); 1 })), ))); @@ -164,7 +164,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { source.reply("I don't have the Pathfinder ocmponent"); return 1; }; - source.reply(&format!( + source.reply(format!( "pathfinder.is_calculating: {}", pathfinder.is_calculating )); @@ -174,7 +174,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { source.reply("I'm not executing a path"); return 1; }; - source.reply(&format!( + source.reply(format!( "is_path_partial: {}, path.len: {}, queued_path.len: {}", executing_path.is_path_partial, executing_path.path.len(), diff --git a/azalea/examples/testbot/commands/movement.rs b/azalea/examples/testbot/commands/movement.rs index 36ff42ff..89be3d0c 100644 --- a/azalea/examples/testbot/commands/movement.rs +++ b/azalea/examples/testbot/commands/movement.rs @@ -141,7 +141,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { tokio::time::sleep(Duration::from_secs_f32(seconds)).await; bot.walk(WalkDirection::None); }); - source.reply(&format!("ok, walking for {seconds} seconds")); + source.reply(format!("ok, walking for {seconds} seconds")); 1 })), ); @@ -155,7 +155,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) { tokio::time::sleep(Duration::from_secs_f32(seconds)).await; bot.walk(WalkDirection::None); }); - source.reply(&format!("ok, spriting for {seconds} seconds")); + source.reply(format!("ok, spriting for {seconds} seconds")); 1 })), ); diff --git a/azalea/examples/testbot/main.rs b/azalea/examples/testbot/main.rs index 8fb96411..249f7b92 100644 --- a/azalea/examples/testbot/main.rs +++ b/azalea/examples/testbot/main.rs @@ -168,7 +168,7 @@ async fn handle(bot: Client, event: azalea::Event, state: State) -> anyhow::Resu chat: chat.clone(), state: state.clone(), }; - command_source.reply(&format!("{err:?}")); + command_source.reply(format!("{err:?}")); } } } |
