Skip to content

Commit fe393fa

Browse files
committed
Moved actual logic to /src/bin/packet_handlers/ to be consistent with filing scheme present in rest of project.
1 parent 9a49a2b commit fe393fa

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use ferrumc_macros::event_handler;
2+
use ferrumc_net::errors::NetError;
3+
use ferrumc_net::packets::outgoing::entity_animation::EntityAnimationEvent;
4+
use ferrumc_net::utils::broadcast::{broadcast, BroadcastOptions};
5+
use ferrumc_state::GlobalState;
6+
7+
#[event_handler]
8+
async fn entity_animation(
9+
event: EntityAnimationEvent,
10+
state: GlobalState,
11+
) -> Result<EntityAnimationEvent, NetError> {
12+
//TODO change this global broadcast to a broadcast that affects only players in the view distance
13+
// of the player doing it, but as long as we still cant see other players, this will be fine.
14+
15+
broadcast(
16+
&event.packet,
17+
&state,
18+
BroadcastOptions::default().except([event.eid.val as usize]),
19+
)
20+
.await?;
21+
Ok(event)
22+
}

src/bin/src/packet_handlers/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
mod animations;
12
mod handshake;
23
mod login_process;
34
mod tick_handler;

src/lib/net/src/packets/outgoing/entity_animation.rs

-17
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,6 @@ pub struct EntityAnimationEvent {
1919
pub packet: EntityAnimationPacket,
2020
}
2121

22-
#[event_handler]
23-
async fn entity_animation(
24-
event: EntityAnimationEvent,
25-
state: GlobalState,
26-
) -> Result<EntityAnimationEvent, NetError> {
27-
//TODO change this global broadcast to a broadcast that affects only players in the view distance
28-
// of the player doing it, but as long as we still cant see other players, this will be fine.
29-
30-
broadcast(
31-
&event.packet,
32-
&state,
33-
BroadcastOptions::default().except([event.eid.val as usize]),
34-
)
35-
.await?;
36-
Ok(event)
37-
}
38-
3922
impl EntityAnimationPacket {
4023
pub fn new(eid: VarInt, animation: u8) -> Self {
4124
Self { eid, animation }

0 commit comments

Comments
 (0)