fix rust 1.86 clippy warns
This commit is contained in:
parent
be19110a24
commit
ae53d93f8e
@ -15,7 +15,7 @@ pub struct BitSet(pub Box<[i64]>);
|
|||||||
|
|
||||||
impl Codec<BitSet> for BitSet {
|
impl Codec<BitSet> for BitSet {
|
||||||
/// The maximum size of the `BitSet` is `remaining / 8`.
|
/// The maximum size of the `BitSet` is `remaining / 8`.
|
||||||
const MAX_SIZE: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(usize::MAX) };
|
const MAX_SIZE: NonZeroUsize = NonZeroUsize::new(usize::MAX).unwrap();
|
||||||
|
|
||||||
fn written_size(&self) -> usize {
|
fn written_size(&self) -> usize {
|
||||||
todo!()
|
todo!()
|
||||||
|
|||||||
@ -31,7 +31,7 @@ impl Identifier {
|
|||||||
}
|
}
|
||||||
impl Codec<Self> for Identifier {
|
impl Codec<Self> for Identifier {
|
||||||
/// The maximum number of bytes an `Identifier` is the same as for a normal `String`.
|
/// The maximum number of bytes an `Identifier` is the same as for a normal `String`.
|
||||||
const MAX_SIZE: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(i16::MAX as usize) };
|
const MAX_SIZE: NonZeroUsize = NonZeroUsize::new(i16::MAX as usize).unwrap();
|
||||||
|
|
||||||
fn written_size(&self) -> usize {
|
fn written_size(&self) -> usize {
|
||||||
todo!()
|
todo!()
|
||||||
|
|||||||
@ -24,7 +24,7 @@ pub struct VarInt(pub VarIntType);
|
|||||||
|
|
||||||
impl Codec<Self> for VarInt {
|
impl Codec<Self> for VarInt {
|
||||||
/// The maximum number of bytes a `VarInt` can occupy.
|
/// The maximum number of bytes a `VarInt` can occupy.
|
||||||
const MAX_SIZE: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(5) };
|
const MAX_SIZE: NonZeroUsize = NonZeroUsize::new(5).unwrap();
|
||||||
|
|
||||||
/// Returns the exact number of bytes this VarInt will write when
|
/// Returns the exact number of bytes this VarInt will write when
|
||||||
/// [`Encode::encode`] is called, assuming no error occurs.
|
/// [`Encode::encode`] is called, assuming no error occurs.
|
||||||
|
|||||||
@ -23,7 +23,7 @@ pub struct VarLong(pub VarLongType);
|
|||||||
|
|
||||||
impl Codec<Self> for VarLong {
|
impl Codec<Self> for VarLong {
|
||||||
/// The maximum number of bytes a `VarLong` can occupy.
|
/// The maximum number of bytes a `VarLong` can occupy.
|
||||||
const MAX_SIZE: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(10) };
|
const MAX_SIZE: NonZeroUsize = NonZeroUsize::new(10).unwrap();
|
||||||
|
|
||||||
/// Returns the exact number of bytes this VarLong will write when
|
/// Returns the exact number of bytes this VarLong will write when
|
||||||
/// [`Encode::encode`] is called, assuming no error occurs.
|
/// [`Encode::encode`] is called, assuming no error occurs.
|
||||||
|
|||||||
@ -90,7 +90,7 @@ pub fn register_button_blocks(manager: &mut BlockRegistry) {
|
|||||||
props.facing = *player_direction;
|
props.facing = *player_direction;
|
||||||
} else {
|
} else {
|
||||||
props.facing = face.opposite().to_cardinal_direction();
|
props.facing = face.opposite().to_cardinal_direction();
|
||||||
};
|
}
|
||||||
|
|
||||||
props.to_state_id(block)
|
props.to_state_id(block)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,7 +63,7 @@ impl PumpkinBlock for LeverBlock {
|
|||||||
lever_props.facing = *player_direction;
|
lever_props.facing = *player_direction;
|
||||||
} else {
|
} else {
|
||||||
lever_props.facing = face.opposite().to_cardinal_direction();
|
lever_props.facing = face.opposite().to_cardinal_direction();
|
||||||
};
|
}
|
||||||
|
|
||||||
lever_props.to_state_id(block)
|
lever_props.to_state_id(block)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -168,16 +168,16 @@ impl RedstoneWireTurbo {
|
|||||||
let mut cz = 0;
|
let mut cz = 0;
|
||||||
if from_west {
|
if from_west {
|
||||||
cx += 1;
|
cx += 1;
|
||||||
};
|
}
|
||||||
if from_east {
|
if from_east {
|
||||||
cx -= 1;
|
cx -= 1;
|
||||||
};
|
}
|
||||||
if from_north {
|
if from_north {
|
||||||
cz += 1;
|
cz += 1;
|
||||||
};
|
}
|
||||||
if from_south {
|
if from_south {
|
||||||
cz -= 1;
|
cz -= 1;
|
||||||
};
|
}
|
||||||
|
|
||||||
let UpdateNode { xbias, zbias, .. } = &self.nodes[upd1.index];
|
let UpdateNode { xbias, zbias, .. } = &self.nodes[upd1.index];
|
||||||
let xbias = *xbias;
|
let xbias = *xbias;
|
||||||
|
|||||||
@ -37,7 +37,7 @@ impl ArgumentConsumer for GamemodeArgumentConsumer {
|
|||||||
if let Ok(gamemode) = GameMode::try_from(id) {
|
if let Ok(gamemode) = GameMode::try_from(id) {
|
||||||
return Some(Arg::GameMode(gamemode));
|
return Some(Arg::GameMode(gamemode));
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
GameMode::from_str(s).map_or_else(|_| None, |gamemode| Some(Arg::GameMode(gamemode)))
|
GameMode::from_str(s).map_or_else(|_| None, |gamemode| Some(Arg::GameMode(gamemode)))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -185,7 +185,7 @@ impl<'a, T: DoubleEndedIterator<Item = (usize, char)>> Iterator
|
|||||||
self.is_complete = true;
|
self.is_complete = true;
|
||||||
return Some(&self.s[start..self.pos]);
|
return Some(&self.s[start..self.pos]);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,11 +39,11 @@ impl ArgumentConsumer for RotationArgumentConsumer {
|
|||||||
yaw %= 360.0;
|
yaw %= 360.0;
|
||||||
if yaw >= 180.0 {
|
if yaw >= 180.0 {
|
||||||
yaw -= 360.0;
|
yaw -= 360.0;
|
||||||
};
|
}
|
||||||
pitch %= 360.0;
|
pitch %= 360.0;
|
||||||
if pitch >= 180.0 {
|
if pitch >= 180.0 {
|
||||||
pitch -= 360.0;
|
pitch -= 360.0;
|
||||||
};
|
}
|
||||||
|
|
||||||
Some(Arg::Rotation(yaw, pitch))
|
Some(Arg::Rotation(yaw, pitch))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ use async_trait::async_trait;
|
|||||||
use pumpkin_util::text::TextComponent;
|
use pumpkin_util::text::TextComponent;
|
||||||
use pumpkin_util::text::color::{Color, NamedColor};
|
use pumpkin_util::text::color::{Color, NamedColor};
|
||||||
use pumpkin_util::text::hover::HoverEvent;
|
use pumpkin_util::text::hover::HoverEvent;
|
||||||
|
use std::fmt::Write as _;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
const NAMES: [&str; 1] = ["bossbar"];
|
const NAMES: [&str; 1] = ["bossbar"];
|
||||||
@ -283,7 +284,7 @@ impl CommandExecutor for RemoveExecuter {
|
|||||||
handle_bossbar_error(sender, err).await;
|
handle_bossbar_error(sender, err).await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -691,7 +692,7 @@ async fn handle_bossbar_error(sender: &CommandSender, error: BossbarUpdateError<
|
|||||||
key.push_str(value);
|
key.push_str(value);
|
||||||
key.push_str(".unchanged");
|
key.push_str(".unchanged");
|
||||||
if let Some(variation) = variation {
|
if let Some(variation) = variation {
|
||||||
key.push_str(&format!(".{variation}"));
|
write!(key, ".{variation}").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
send_error_message(sender, TextComponent::translate(key, [])).await;
|
send_error_message(sender, TextComponent::translate(key, [])).await;
|
||||||
|
|||||||
@ -259,7 +259,6 @@ impl CommandExecutor for Executor {
|
|||||||
.color(Color::Named(NamedColor::Red)),
|
.color(Color::Named(NamedColor::Red)),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -183,7 +183,7 @@ impl CommandExecutor for Executor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
|
|||||||
@ -198,7 +198,7 @@ impl CommandExecutor for SelfToEntityExecutor {
|
|||||||
.send_message(TextComponent::translate("permissions.requires.player", []))
|
.send_message(TextComponent::translate("permissions.requires.player", []))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ impl CommandExecutor for SelfToPosExecutor {
|
|||||||
.send_message(TextComponent::translate("permissions.requires.player", []))
|
.send_message(TextComponent::translate("permissions.requires.player", []))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,7 @@ impl Display for Node {
|
|||||||
f.write_char('>')?;
|
f.write_char('>')?;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ impl Display for CommandTree {
|
|||||||
|
|
||||||
if visible_children.is_empty() {
|
if visible_children.is_empty() {
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
|
|
||||||
f.write_char(' ')?;
|
f.write_char(' ')?;
|
||||||
|
|
||||||
|
|||||||
@ -125,5 +125,5 @@ pub async fn player_attack_sound(pos: &Vector3<f64>, world: &World, attack_type:
|
|||||||
.play_sound(Sound::EntityPlayerAttackWeak, SoundCategory::Players, pos)
|
.play_sound(Sound::EntityPlayerAttackWeak, SoundCategory::Players, pos)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -459,7 +459,7 @@ impl Player {
|
|||||||
combat::spawn_sweep_particle(attacker_entity, &world, &pos).await;
|
combat::spawn_sweep_particle(attacker_entity, &world, &pos).await;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
}
|
||||||
if config.knockback {
|
if config.knockback {
|
||||||
combat::handle_knockback(
|
combat::handle_knockback(
|
||||||
attacker_entity,
|
attacker_entity,
|
||||||
@ -1707,7 +1707,7 @@ impl Player {
|
|||||||
// TODO: We give an error if all play packets are implemented
|
// TODO: We give an error if all play packets are implemented
|
||||||
// return Err(Box::new(DeserializerError::UnknownPacket));
|
// return Err(Box::new(DeserializerError::UnknownPacket));
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -335,7 +335,7 @@ impl Player {
|
|||||||
*carried_item = None;
|
*carried_item = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -463,7 +463,7 @@ impl Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
container_click::Slot::OutsideInventory => (),
|
container_click::Slot::OutsideInventory => (),
|
||||||
};
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ pub async fn start_lan_broadcast(bound_addr: SocketAddr) {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
motd = advanced_motd.clone();
|
motd = advanced_motd.clone();
|
||||||
};
|
}
|
||||||
|
|
||||||
let advertisement = format!("[MOTD]{}[/MOTD][AD]{}[/AD]", &motd, bound_addr.port());
|
let advertisement = format!("[MOTD]{}[/MOTD][AD]{}[/AD]", &motd, bound_addr.port());
|
||||||
|
|
||||||
|
|||||||
@ -392,7 +392,7 @@ impl Client {
|
|||||||
if let Err(err) = packet.write(&mut packet_buf) {
|
if let Err(err) = packet.write(&mut packet_buf) {
|
||||||
log::error!("Failed to serialize packet {}: {}", P::PACKET_ID, err);
|
log::error!("Failed to serialize packet {}: {}", P::PACKET_ID, err);
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
if let Err(err) = self
|
if let Err(err) = self
|
||||||
.network_writer
|
.network_writer
|
||||||
@ -437,7 +437,7 @@ impl Client {
|
|||||||
error
|
error
|
||||||
);
|
);
|
||||||
self.kick(TextComponent::text(text)).await;
|
self.kick(TextComponent::text(text)).await;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,7 +505,7 @@ impl Client {
|
|||||||
packet.id
|
packet.id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +530,7 @@ impl Client {
|
|||||||
packet.id
|
packet.id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -567,7 +567,7 @@ impl Client {
|
|||||||
packet.id
|
packet.id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,7 +607,7 @@ impl Client {
|
|||||||
packet.id
|
packet.id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -637,7 +637,7 @@ impl Client {
|
|||||||
log::warn!("Can't kick in {:?} State", self.connection_state);
|
log::warn!("Can't kick in {:?} State", self.connection_state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
log::debug!("Closing connection for {}", self.id);
|
log::debug!("Closing connection for {}", self.id);
|
||||||
self.close();
|
self.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -847,7 +847,7 @@ impl Player {
|
|||||||
self.kick(TextComponent::text("Invalid client status"))
|
self.kick(TextComponent::text("Invalid client status"))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_interact(&self, interact: SInteract) {
|
pub async fn handle_interact(&self, interact: SInteract) {
|
||||||
@ -920,7 +920,7 @@ impl Player {
|
|||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
ActionType::Interact | ActionType::InteractAt => {
|
ActionType::Interact | ActionType::InteractAt => {
|
||||||
log::debug!("todo");
|
log::debug!("todo");
|
||||||
@ -1233,7 +1233,7 @@ impl Player {
|
|||||||
if let Some(entity) = entity_from_egg(stack.item.id) {
|
if let Some(entity) = entity_from_egg(stack.item.id) {
|
||||||
self.spawn_entity_from_egg(entity, location, &face).await;
|
self.spawn_entity_from_egg(entity, location, &face).await;
|
||||||
should_try_decrement = true;
|
should_try_decrement = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
if should_try_decrement {
|
if should_try_decrement {
|
||||||
// TODO: Config
|
// TODO: Config
|
||||||
@ -1325,7 +1325,7 @@ impl Player {
|
|||||||
// Item drop
|
// Item drop
|
||||||
self.drop_item(item_stack.item.id, u32::from(item_stack.item_count))
|
self.drop_item(item_stack.item.id, u32::from(item_stack.item_count))
|
||||||
.await;
|
.await;
|
||||||
};
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1141,8 +1141,7 @@ impl World {
|
|||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// * `pos`: The center of the sphere.
|
/// * `pos`: The center of the sphere.
|
||||||
/// * `radius`: The radius of the sphere. The higher the radius,
|
/// * `radius`: The radius of the sphere. The higher the radius, the more area will be checked (in every direction).
|
||||||
/// the more area will be checked (in every direction).
|
|
||||||
pub async fn get_nearby_players(
|
pub async fn get_nearby_players(
|
||||||
&self,
|
&self,
|
||||||
pos: Vector3<f64>,
|
pos: Vector3<f64>,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user