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