From dc093f4a21a8c48e5d94f27b2edb730fc329669a Mon Sep 17 00:00:00 2001 From: StripedMonkey Date: Tue, 3 Sep 2024 19:28:56 -0400 Subject: [PATCH] remove unnecessary references It's already a usize, so the references are meaningless when the pointer is the same size as the type. --- pumpkin/src/client/player_packet.rs | 28 ++++++++++++++-------------- pumpkin/src/entity/player.rs | 6 +++--- pumpkin/src/server/mod.rs | 2 +- pumpkin/src/world/mod.rs | 14 +++++++------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pumpkin/src/client/player_packet.rs b/pumpkin/src/client/player_packet.rs index 32f328e79..8fa1852c9 100644 --- a/pumpkin/src/client/player_packet.rs +++ b/pumpkin/src/client/player_packet.rs @@ -95,7 +95,7 @@ impl Player { let world = self.world.clone(); let world = world.lock().await; world.broadcast_packet( - &[&self.client.token], + &[self.client.token], &CUpdateEntityPos::new( entity_id.into(), (x * 4096.0 - lastx * 4096.0) as i16, @@ -149,7 +149,7 @@ impl Player { let world = world.lock().await; world.broadcast_packet( - &[&self.client.token], + &[self.client.token], &CUpdateEntityPosRot::new( entity_id.into(), (x * 4096.0 - lastx * 4096.0) as i16, @@ -161,7 +161,7 @@ impl Player { ), ); world.broadcast_packet( - &[&self.client.token], + &[self.client.token], &CHeadRot::new(entity_id.into(), yaw as u8), ); @@ -186,10 +186,10 @@ impl Player { let world = self.world.lock().await; let packet = CUpdateEntityRot::new(entity_id.into(), yaw as u8, pitch as u8, on_ground); // self.client.send_packet(&packet); - world.broadcast_packet(&[&self.client.token], &packet); + world.broadcast_packet(&[self.client.token], &packet); let packet = CHeadRot::new(entity_id.into(), yaw as u8); // self.client.send_packet(&packet); - world.broadcast_packet(&[&self.client.token], &packet); + world.broadcast_packet(&[self.client.token], &packet); } pub fn handle_chat_command(&mut self, server: &mut Server, command: SChatCommand) { @@ -248,7 +248,7 @@ impl Player { let id = self.entity_id(); let world = self.world.lock().await; world.broadcast_packet( - &[&self.client.token], + &[self.client.token], &CEntityAnimation::new(id.into(), animation as u8), ) } @@ -272,7 +272,7 @@ impl Player { let world = self.world.lock().await; world.broadcast_packet( - &[&self.client.token], + &[self.client.token], &CPlayerChatMessage::new( pumpkin_protocol::uuid::UUID(gameprofile.id), 1.into(), @@ -371,7 +371,7 @@ impl Player { self.client.send_packet(packet); player.client.send_packet(packet); world.broadcast_packet( - &[&self.client.token, &token], + &[self.client.token, token], &CHurtAnimation::new(&entity_id, 10.0), ) } @@ -411,12 +411,12 @@ impl Player { // TODO: currently this is always dirt replace it let world = self.world.lock().await; world.broadcast_packet( - &[&self.client.token], + &[self.client.token], &CWorldEvent::new(2001, &location, 11, false), ); // AIR world.broadcast_packet( - &[&self.client.token], + &[self.client.token], &CBlockUpdate::new(&location, 0.into()), ); } @@ -439,12 +439,12 @@ impl Player { // TODO: currently this is always dirt replace it let world = self.world.lock().await; world.broadcast_packet( - &[&self.client.token], + &[self.client.token], &CWorldEvent::new(2001, &location, 11, false), ); // AIR world.broadcast_packet( - &[&self.client.token], + &[self.client.token], &CBlockUpdate::new(&location, 0.into()), ); // TODO: Send this every tick @@ -491,11 +491,11 @@ impl Player { if let Ok(block_state_id) = BlockId::new(minecraft_id, None) { let world = self.world.lock().await; world.broadcast_packet( - &[&self.client.token], + &[self.client.token], &CBlockUpdate::new(&location, block_state_id.get_id_mojang_repr().into()), ); world.broadcast_packet( - &[&self.client.token], + &[self.client.token], &CBlockUpdate::new( &WorldPosition(location.0 + face.to_offset()), block_state_id.get_id_mojang_repr().into(), diff --git a/pumpkin/src/entity/player.rs b/pumpkin/src/entity/player.rs index d5688a5d6..1cb2f3b47 100644 --- a/pumpkin/src/entity/player.rs +++ b/pumpkin/src/entity/player.rs @@ -230,7 +230,7 @@ impl Player { self.world .lock() .await - .broadcast_packet(&[&self.client.token], &packet); + .broadcast_packet(&[self.client.token], &packet); } pub async fn set_pose(&mut self, pose: EntityPose) { @@ -244,7 +244,7 @@ impl Player { self.world .lock() .await - .broadcast_packet(&[&self.client.token], &packet) + .broadcast_packet(&[self.client.token], &packet) } pub fn teleport(&mut self, x: f64, y: f64, z: f64, yaw: f32, pitch: f32) { @@ -326,7 +326,7 @@ impl Player { }], )); self.world.lock().await.broadcast_packet( - &[&self.client.token], + &[self.client.token], &CPlayerInfoUpdate::new( 0x04, &[pumpkin_protocol::client::play::Player { diff --git a/pumpkin/src/server/mod.rs b/pumpkin/src/server/mod.rs index d765f7cf9..8da9e3531 100644 --- a/pumpkin/src/server/mod.rs +++ b/pumpkin/src/server/mod.rs @@ -129,7 +129,7 @@ impl Server { } /// Sends a Packet to all Players in all worlds - pub fn broadcast_packet_all

(&self, expect: &[&Token], packet: &P) + pub fn broadcast_packet_all

(&self, expect: &[Token], packet: &P) where P: ClientPacket, { diff --git a/pumpkin/src/world/mod.rs b/pumpkin/src/world/mod.rs index 967368d01..525a58efb 100644 --- a/pumpkin/src/world/mod.rs +++ b/pumpkin/src/world/mod.rs @@ -39,14 +39,14 @@ impl World { } /// Sends a Packet to all Players, Expect some players. Because we can't lock them twice - pub fn broadcast_packet

(&self, expect: &[&Token], packet: &P) + pub fn broadcast_packet

(&self, expect: &[Token], packet: &P) where P: ClientPacket, { for (_, player) in self .current_players .iter() - .filter(|c| !expect.contains(&c.0)) + .filter(|c| !expect.contains(c.0)) { let mut player = player.lock().unwrap(); player.client.send_packet(packet); @@ -118,7 +118,7 @@ impl World { }], )); self.broadcast_packet( - &[&player.client.token], + &[player.client.token], &CPlayerInfoUpdate::new( 0x01 | 0x08, &[pumpkin_protocol::client::play::Player { @@ -165,7 +165,7 @@ impl World { // spawn player for every client self.broadcast_packet( - &[&player.client.token], + &[player.client.token], // TODO: add velo &CSpawnEntity::new( entity_id.into(), @@ -213,7 +213,7 @@ impl World { Metadata::new(17, VarInt(0), config.skin_parts), ); player.client.send_packet(&packet); - self.broadcast_packet(&[&player.client.token], &packet) + self.broadcast_packet(&[player.client.token], &packet) } // Spawn in inital chunks @@ -288,9 +288,9 @@ impl World { let id = player.entity_id(); let uuid = player.gameprofile.id; self.broadcast_packet( - &[&player.client.token], + &[player.client.token], &CRemovePlayerInfo::new(1.into(), &[UUID(uuid)]), ); - self.broadcast_packet(&[&player.client.token], &CRemoveEntities::new(&[id.into()])) + self.broadcast_packet(&[player.client.token], &CRemoveEntities::new(&[id.into()])) } }