File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
src/main/java/net/hypixel/modapi/fabric Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 55import net .fabricmc .fabric .api .client .networking .v1 .ClientPlayNetworking ;
66import net .fabricmc .fabric .api .networking .v1 .PayloadTypeRegistry ;
77import net .hypixel .modapi .HypixelModAPI ;
8+ import net .hypixel .modapi .fabric .event .HypixelModAPICallback ;
89import net .hypixel .modapi .fabric .payload .ClientboundHypixelPayload ;
910import net .hypixel .modapi .fabric .payload .ServerboundHypixelPayload ;
1011import net .minecraft .network .PacketByteBuf ;
@@ -50,7 +51,17 @@ public void registerClientbound(String identifier) {
5051 return ;
5152 }
5253
53- HypixelModAPI .getInstance ().handle (payload .getPacket ());
54+ try {
55+ HypixelModAPI .getInstance ().handle (payload .getPacket ());
56+ } catch (Exception e ) {
57+ LOGGER .error ("An error occurred while handling packet {}" , identifier , e );
58+ }
59+
60+ try {
61+ HypixelModAPICallback .EVENT .invoker ().onPacketReceived (payload .getPacket ());
62+ } catch (Exception e ) {
63+ LOGGER .error ("An error occurred while handling packet {}" , identifier , e );
64+ }
5465 });
5566 }
5667
Original file line number Diff line number Diff line change 1+ package net .hypixel .modapi .fabric .event ;
2+
3+ import net .fabricmc .fabric .api .event .Event ;
4+ import net .fabricmc .fabric .api .event .EventFactory ;
5+ import net .hypixel .modapi .packet .ClientboundHypixelPacket ;
6+
7+ /**
8+ * Callback for when a Hypixel Mod API packet is received.
9+ */
10+ public interface HypixelModAPICallback {
11+
12+ Event <HypixelModAPICallback > EVENT = EventFactory .createArrayBacked (HypixelModAPICallback .class , callbacks -> packet -> {
13+ for (HypixelModAPICallback callback : callbacks ) {
14+ callback .onPacketReceived (packet );
15+ }
16+ });
17+
18+ void onPacketReceived (ClientboundHypixelPacket packet );
19+
20+ }
You can’t perform that action at this time.
0 commit comments