5
5
import io .github .cottonmc .skillcheck .container .CharacterSheetContainer ;
6
6
import io .netty .buffer .Unpooled ;
7
7
import net .fabricmc .api .EnvType ;
8
- import net .fabricmc .api .Environment ;
9
8
import net .fabricmc .fabric .api .network .ClientSidePacketRegistry ;
10
9
import net .fabricmc .fabric .api .network .ServerSidePacketRegistry ;
11
10
import net .fabricmc .loader .api .FabricLoader ;
12
11
import net .minecraft .client .MinecraftClient ;
13
12
import net .minecraft .client .network .packet .CustomPayloadS2CPacket ;
14
13
import net .minecraft .container .Container ;
14
+ import net .minecraft .entity .player .PlayerEntity ;
15
15
import net .minecraft .server .network .ServerPlayerEntity ;
16
16
import net .minecraft .server .network .packet .CustomPayloadC2SPacket ;
17
17
import net .minecraft .util .Identifier ;
@@ -23,6 +23,8 @@ public class SkillCheckNetworking {
23
23
public static final Identifier SYNC_LEVELUP = new Identifier (SkillCheck .MOD_ID , "sync_levelup" );
24
24
public static final Identifier SYNC_PLAYER_LEVEL = new Identifier (SkillCheck .MOD_ID , "sync_player_level" );
25
25
26
+ public static final Identifier CLEAR_FALL = new Identifier (SkillCheck .MOD_ID , "clear_fall" );
27
+
26
28
public static void init () {
27
29
if (FabricLoader .getInstance ().getEnvironmentType () == EnvType .CLIENT ) initClient ();
28
30
initServer ();
@@ -53,6 +55,10 @@ public static void initServer() {
53
55
ClassManager .levelUp (packetContext .getPlayer (), id );
54
56
}
55
57
});
58
+ ServerSidePacketRegistry .INSTANCE .register (CLEAR_FALL , ((packetContext , packetByteBuf ) -> {
59
+ PlayerEntity player = packetContext .getPlayer ();
60
+ player .fallDistance = 0 ;
61
+ }));
56
62
}
57
63
58
64
@@ -74,4 +80,9 @@ public static void syncLevelup(Identifier id, int xpCost) {
74
80
buf .writeInt (xpCost );
75
81
MinecraftClient .getInstance ().getNetworkHandler ().getClientConnection ().send (new CustomPayloadC2SPacket (SYNC_LEVELUP , buf ));
76
82
}
83
+
84
+ public static void clearFall () {
85
+ PacketByteBuf buf = new PacketByteBuf (Unpooled .buffer ());
86
+ MinecraftClient .getInstance ().getNetworkHandler ().getClientConnection ().send (new CustomPayloadC2SPacket (CLEAR_FALL , buf ));
87
+ }
77
88
}
0 commit comments