mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-30 20:14:23 +00:00
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:
@@ -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(),
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -129,7 +129,7 @@ impl Server {
|
||||
}
|
||||
|
||||
/// 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
|
||||
P: ClientPacket,
|
||||
{
|
||||
|
||||
@@ -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<P>(&self, expect: &[&Token], packet: &P)
|
||||
pub fn broadcast_packet<P>(&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()]))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user