mirror of
https://github.com/mat-1/azalea.git
synced 2024-09-19 22:52:32 +00:00
clippy
This commit is contained in:
parent
9f78b3f4a7
commit
614c0df053
9 changed files with 30 additions and 24 deletions
|
@ -7,19 +7,21 @@ use std::{
|
|||
hash::BuildHasherDefault,
|
||||
};
|
||||
|
||||
type U64Hasher = BuildHasherDefault<NoHashHasher<u64>>;
|
||||
|
||||
// kind of based on https://docs.rs/http/latest/src/http/extensions.rs.html
|
||||
/// A map of plugin ids to Plugin trait objects. The client stores this so we
|
||||
/// can keep the state for our plugins.
|
||||
///
|
||||
/// If you're using azalea, you should generate this from the `plugins!` macro.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct Plugins {
|
||||
map: Option<HashMap<TypeId, Box<dyn Plugin>, BuildHasherDefault<NoHashHasher<u64>>>>,
|
||||
map: Option<HashMap<TypeId, Box<dyn Plugin>, U64Hasher>>,
|
||||
}
|
||||
|
||||
impl Plugins {
|
||||
pub fn new() -> Self {
|
||||
Self { map: None }
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn add<T: Plugin>(&mut self, plugin: T) {
|
||||
|
@ -46,7 +48,7 @@ impl IntoIterator for Plugins {
|
|||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.map
|
||||
.map(|map| map.into_iter().map(|(_, v)| v).collect::<Vec<_>>())
|
||||
.map(|map| map.into_values().collect::<Vec<_>>())
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
}
|
||||
|
|
|
@ -122,12 +122,11 @@ impl<D: DerefMut<Target = Dimension>> HasPhysics for Entity<'_, D> {
|
|||
};
|
||||
if self.metadata.sprinting {
|
||||
let y_rot = self.y_rot * 0.017453292;
|
||||
self.delta = self.delta
|
||||
+ Vec3 {
|
||||
x: (-f32::sin(y_rot) * 0.2) as f64,
|
||||
y: 0.,
|
||||
z: (f32::cos(y_rot) * 0.2) as f64,
|
||||
};
|
||||
self.delta += Vec3 {
|
||||
x: (-f32::sin(y_rot) * 0.2) as f64,
|
||||
y: 0.,
|
||||
z: (f32::cos(y_rot) * 0.2) as f64,
|
||||
};
|
||||
}
|
||||
|
||||
self.has_impulse = true;
|
||||
|
|
|
@ -40,9 +40,8 @@ impl AttributeInstance {
|
|||
AttributeModifierOperation::MultiplyBase => total += self.base * modifier.amount,
|
||||
_ => {}
|
||||
}
|
||||
match modifier.operation {
|
||||
AttributeModifierOperation::MultiplyTotal => total *= 1.0 + modifier.amount,
|
||||
_ => {}
|
||||
if let AttributeModifierOperation::MultiplyTotal = modifier.operation {
|
||||
total *= 1.0 + modifier.amount
|
||||
}
|
||||
}
|
||||
total
|
||||
|
|
|
@ -270,10 +270,19 @@ impl EntityData {
|
|||
&self.pos
|
||||
}
|
||||
|
||||
/// Convert this &mut self into a (mutable) pointer.
|
||||
///
|
||||
/// # Safety
|
||||
/// The entity MUST exist while this pointer exists.
|
||||
pub unsafe fn as_ptr(&mut self) -> NonNull<EntityData> {
|
||||
NonNull::new_unchecked(self as *mut EntityData)
|
||||
}
|
||||
|
||||
/// Convert this &self into a (mutable) pointer.
|
||||
///
|
||||
/// # Safety
|
||||
/// The entity MUST exist while this pointer exists. You also must not
|
||||
/// modify the data inside the pointer.
|
||||
pub unsafe fn as_const_ptr(&self) -> NonNull<EntityData> {
|
||||
// this is cursed
|
||||
NonNull::new_unchecked(self as *const EntityData as *mut EntityData)
|
||||
|
|
|
@ -38,11 +38,9 @@ impl BotTrait for azalea_client::Client {
|
|||
impl crate::Plugin for Plugin {
|
||||
async fn handle(self: Box<Self>, event: Event, mut bot: Client) {
|
||||
if let Event::Tick = event {
|
||||
if *self.state.jumping_once.lock() {
|
||||
if bot.jumping() {
|
||||
*self.state.jumping_once.lock() = false;
|
||||
bot.set_jumping(false);
|
||||
}
|
||||
if *self.state.jumping_once.lock() && bot.jumping() {
|
||||
*self.state.jumping_once.lock() = false;
|
||||
bot.set_jumping(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ impl Trait for azalea_client::Client {
|
|||
let dimension = self.dimension.read();
|
||||
for possible_move in possible_moves.iter() {
|
||||
edges.push(Edge {
|
||||
target: possible_move.next_node(&node),
|
||||
target: possible_move.next_node(node),
|
||||
cost: possible_move.cost(&dimension, node),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ fn is_passable(pos: &BlockPos, dim: &Dimension) -> bool {
|
|||
/// Whether we can stand in this position. Checks if the block below is solid,
|
||||
/// and that the two blocks above that are passable.
|
||||
fn is_standable(pos: &BlockPos, dim: &Dimension) -> bool {
|
||||
is_block_solid(&pos.down(1), dim) && is_passable(&pos, dim)
|
||||
is_block_solid(&pos.down(1), dim) && is_passable(pos, dim)
|
||||
}
|
||||
|
||||
const JUMP_COST: f32 = 0.5;
|
||||
|
|
|
@ -105,7 +105,7 @@ impl<
|
|||
for n in &known_nodes {
|
||||
*pf.state_mut(n) = NodeState::default();
|
||||
}
|
||||
(*pf.state_mut(&start)).rhs = W::default();
|
||||
pf.state_mut(&start).rhs = W::default();
|
||||
pf.open.push(start, pf.calculate_key(&start));
|
||||
|
||||
pf
|
||||
|
|
|
@ -58,13 +58,12 @@ async fn handle(bot: Client, event: Event, _state: State) -> anyhow::Result<()>
|
|||
Event::Chat(m) => {
|
||||
println!("{}", m.message().to_ansi(None));
|
||||
if m.message().to_string() == "<py5> goto" {
|
||||
let target_pos_vec3 = bot
|
||||
let target_pos_vec3 = *(bot
|
||||
.dimension
|
||||
.read()
|
||||
.entity_by_uuid(&uuid::uuid!("6536bfed869548fd83a1ecd24cf2a0fd"))
|
||||
.unwrap()
|
||||
.pos()
|
||||
.clone();
|
||||
.pos());
|
||||
let target_pos: BlockPos = (&target_pos_vec3).into();
|
||||
// bot.look_at(&target_pos_vec3);
|
||||
bot.goto(BlockPosGoal::from(target_pos));
|
||||
|
|
Loading…
Reference in a new issue