remove unnecessary references

It's already a usize, so the references are meaningless when the pointer is the same size as the type.
This commit is contained in:
StripedMonkey committed 2024-09-04 21:52:42 -04:00
1 parent b55991d8de
commit dc093f4a21
4 files changed
+25 -25

No files matched your search

+14 -14
View File
@@ -95,7 +95,7 @@ impl Player {
let world = self.world.clone(); let world = self.world.clone();
let world = world.lock().await; let world = world.lock().await;
world.broadcast_packet( world.broadcast_packet(
&[&self.client.token], &[self.client.token],
&CUpdateEntityPos::new( &CUpdateEntityPos::new(
entity_id.into(), entity_id.into(),
(x * 4096.0 - lastx * 4096.0) as i16, (x * 4096.0 - lastx * 4096.0) as i16,
@@ -149,7 +149,7 @@ impl Player {
let world = world.lock().await; let world = world.lock().await;
world.broadcast_packet( world.broadcast_packet(
&[&self.client.token], &[self.client.token],
&CUpdateEntityPosRot::new( &CUpdateEntityPosRot::new(
entity_id.into(), entity_id.into(),
(x * 4096.0 - lastx * 4096.0) as i16, (x * 4096.0 - lastx * 4096.0) as i16,
@@ -161,7 +161,7 @@ impl Player {
), ),
); );
world.broadcast_packet( world.broadcast_packet(
&[&self.client.token], &[self.client.token],
&CHeadRot::new(entity_id.into(), yaw as u8), &CHeadRot::new(entity_id.into(), yaw as u8),
); );
@@ -186,10 +186,10 @@ impl Player {
let world = self.world.lock().await; let world = self.world.lock().await;
let packet = CUpdateEntityRot::new(entity_id.into(), yaw as u8, pitch as u8, on_ground); let packet = CUpdateEntityRot::new(entity_id.into(), yaw as u8, pitch as u8, on_ground);
// self.client.send_packet(&packet); // 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); let packet = CHeadRot::new(entity_id.into(), yaw as u8);
// self.client.send_packet(&packet); // 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) { pub fn handle_chat_command(&mut self, server: &mut Server, command: SChatCommand) {
@@ -248,7 +248,7 @@ impl Player {
let id = self.entity_id(); let id = self.entity_id();
let world = self.world.lock().await; let world = self.world.lock().await;
world.broadcast_packet( world.broadcast_packet(
&[&self.client.token], &[self.client.token],
&CEntityAnimation::new(id.into(), animation as u8), &CEntityAnimation::new(id.into(), animation as u8),
) )
} }
@@ -272,7 +272,7 @@ impl Player {
let world = self.world.lock().await; let world = self.world.lock().await;
world.broadcast_packet( world.broadcast_packet(
&[&self.client.token], &[self.client.token],
&CPlayerChatMessage::new( &CPlayerChatMessage::new(
pumpkin_protocol::uuid::UUID(gameprofile.id), pumpkin_protocol::uuid::UUID(gameprofile.id),
1.into(), 1.into(),
@@ -371,7 +371,7 @@ impl Player {
self.client.send_packet(packet); self.client.send_packet(packet);
player.client.send_packet(packet); player.client.send_packet(packet);
world.broadcast_packet( world.broadcast_packet(
&[&self.client.token, &token], &[self.client.token, token],
&CHurtAnimation::new(&entity_id, 10.0), &CHurtAnimation::new(&entity_id, 10.0),
) )
} }
@@ -411,12 +411,12 @@ impl Player {
// TODO: currently this is always dirt replace it // TODO: currently this is always dirt replace it
let world = self.world.lock().await; let world = self.world.lock().await;
world.broadcast_packet( world.broadcast_packet(
&[&self.client.token], &[self.client.token],
&CWorldEvent::new(2001, &location, 11, false), &CWorldEvent::new(2001, &location, 11, false),
); );
// AIR // AIR
world.broadcast_packet( world.broadcast_packet(
&[&self.client.token], &[self.client.token],
&CBlockUpdate::new(&location, 0.into()), &CBlockUpdate::new(&location, 0.into()),
); );
} }
@@ -439,12 +439,12 @@ impl Player {
// TODO: currently this is always dirt replace it // TODO: currently this is always dirt replace it
let world = self.world.lock().await; let world = self.world.lock().await;
world.broadcast_packet( world.broadcast_packet(
&[&self.client.token], &[self.client.token],
&CWorldEvent::new(2001, &location, 11, false), &CWorldEvent::new(2001, &location, 11, false),
); );
// AIR // AIR
world.broadcast_packet( world.broadcast_packet(
&[&self.client.token], &[self.client.token],
&CBlockUpdate::new(&location, 0.into()), &CBlockUpdate::new(&location, 0.into()),
); );
// TODO: Send this every tick // TODO: Send this every tick
@@ -491,11 +491,11 @@ impl Player {
if let Ok(block_state_id) = BlockId::new(minecraft_id, None) { if let Ok(block_state_id) = BlockId::new(minecraft_id, None) {
let world = self.world.lock().await; let world = self.world.lock().await;
world.broadcast_packet( world.broadcast_packet(
&[&self.client.token], &[self.client.token],
&CBlockUpdate::new(&location, block_state_id.get_id_mojang_repr().into()), &CBlockUpdate::new(&location, block_state_id.get_id_mojang_repr().into()),
); );
world.broadcast_packet( world.broadcast_packet(
&[&self.client.token], &[self.client.token],
&CBlockUpdate::new( &CBlockUpdate::new(
&WorldPosition(location.0 + face.to_offset()), &WorldPosition(location.0 + face.to_offset()),
block_state_id.get_id_mojang_repr().into(), block_state_id.get_id_mojang_repr().into(),
+3 -3
View File
@@ -230,7 +230,7 @@ impl Player {
self.world self.world
.lock() .lock()
.await .await
.broadcast_packet(&[&self.client.token], &packet); .broadcast_packet(&[self.client.token], &packet);
} }
pub async fn set_pose(&mut self, pose: EntityPose) { pub async fn set_pose(&mut self, pose: EntityPose) {
@@ -244,7 +244,7 @@ impl Player {
self.world self.world
.lock() .lock()
.await .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) { 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.world.lock().await.broadcast_packet(
&[&self.client.token], &[self.client.token],
&CPlayerInfoUpdate::new( &CPlayerInfoUpdate::new(
0x04, 0x04,
&[pumpkin_protocol::client::play::Player { &[pumpkin_protocol::client::play::Player {
+1 -1
View File
@@ -129,7 +129,7 @@ impl Server {
} }
/// Sends a Packet to all Players in all worlds /// Sends a Packet to all Players in all worlds
pub fn broadcast_packet_all<P>(&self, expect: &[&Token], packet: &P) pub fn broadcast_packet_all<P>(&self, expect: &[Token], packet: &P)
where where
P: ClientPacket, P: ClientPacket,
{ {
+7 -7
View File
@@ -39,14 +39,14 @@ impl World {
} }
/// Sends a Packet to all Players, Expect some players. Because we can't lock them twice /// Sends a Packet to all Players, Expect some players. Because we can't lock them twice
pub fn broadcast_packet<P>(&self, expect: &[&Token], packet: &P) pub fn broadcast_packet<P>(&self, expect: &[Token], packet: &P)
where where
P: ClientPacket, P: ClientPacket,
{ {
for (_, player) in self for (_, player) in self
.current_players .current_players
.iter() .iter()
.filter(|c| !expect.contains(&c.0)) .filter(|c| !expect.contains(c.0))
{ {
let mut player = player.lock().unwrap(); let mut player = player.lock().unwrap();
player.client.send_packet(packet); player.client.send_packet(packet);
@@ -118,7 +118,7 @@ impl World {
}], }],
)); ));
self.broadcast_packet( self.broadcast_packet(
&[&player.client.token], &[player.client.token],
&CPlayerInfoUpdate::new( &CPlayerInfoUpdate::new(
0x01 | 0x08, 0x01 | 0x08,
&[pumpkin_protocol::client::play::Player { &[pumpkin_protocol::client::play::Player {
@@ -165,7 +165,7 @@ impl World {
// spawn player for every client // spawn player for every client
self.broadcast_packet( self.broadcast_packet(
&[&player.client.token], &[player.client.token],
// TODO: add velo // TODO: add velo
&CSpawnEntity::new( &CSpawnEntity::new(
entity_id.into(), entity_id.into(),
@@ -213,7 +213,7 @@ impl World {
Metadata::new(17, VarInt(0), config.skin_parts), Metadata::new(17, VarInt(0), config.skin_parts),
); );
player.client.send_packet(&packet); player.client.send_packet(&packet);
self.broadcast_packet(&[&player.client.token], &packet) self.broadcast_packet(&[player.client.token], &packet)
} }
// Spawn in inital chunks // Spawn in inital chunks
@@ -288,9 +288,9 @@ impl World {
let id = player.entity_id(); let id = player.entity_id();
let uuid = player.gameprofile.id; let uuid = player.gameprofile.id;
self.broadcast_packet( self.broadcast_packet(
&[&player.client.token], &[player.client.token],
&CRemovePlayerInfo::new(1.into(), &[UUID(uuid)]), &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()]))
} }
} }