2020import com .lambda .event .EventFlow ;
2121import com .lambda .event .events .ChatEvent ;
2222import com .lambda .event .events .InventoryEvent ;
23+ import com .lambda .event .events .PlayerEvent ;
2324import com .lambda .event .events .WorldEvent ;
2425import com .lambda .interaction .managers .inventory .InventoryManager ;
2526import com .lambda .module .modules .movement .Velocity ;
2627import com .lambda .module .modules .render .NoRender ;
2728import com .llamalad7 .mixinextras .injector .ModifyExpressionValue ;
2829import com .llamalad7 .mixinextras .injector .wrapmethod .WrapMethod ;
2930import com .llamalad7 .mixinextras .injector .wrapoperation .Operation ;
31+ import net .minecraft .client .MinecraftClient ;
3032import net .minecraft .client .network .ClientPlayNetworkHandler ;
3133import net .minecraft .client .network .PlayerListEntry ;
34+ import net .minecraft .entity .Entity ;
35+ import net .minecraft .entity .EntityPosition ;
3236import net .minecraft .network .packet .s2c .play .*;
3337import org .spongepowered .asm .mixin .Mixin ;
3438import org .spongepowered .asm .mixin .injection .At ;
3539import org .spongepowered .asm .mixin .injection .Inject ;
3640import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
41+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
42+
43+ import java .util .Set ;
3744
3845@ Mixin (ClientPlayNetworkHandler .class )
3946public class ClientPlayNetworkHandlerMixin {
@@ -125,4 +132,25 @@ void onSendMessage(String content, Operation<Void> original) {
125132 if (!EventFlow .post (event ).isCanceled ())
126133 original .call (event .getMessage ());
127134 }
135+
136+ @ Inject (method = "onPlayerRespawn" , at = @ At ("TAIL" ))
137+ void onPlayerRespawn (PlayerRespawnS2CPacket packet , CallbackInfo ci ) {
138+ EventFlow .post (new PlayerEvent .World .Respawn (packet ));
139+ }
140+
141+ @ Inject (method = "onPlayerPositionLook" , at = @ At ("TAIL" ))
142+ void onPlayerPositionLook (PlayerPositionLookS2CPacket packet , CallbackInfo ci ) {
143+ EventFlow .post (new PlayerEvent .World .PositionLook (packet ));
144+ }
145+
146+ @ Inject (method = "setPosition" , at = @ At ("TAIL" ))
147+ private static void onSetPosition (EntityPosition pos , Set <PositionFlag > flags , Entity entity , boolean bl ,
148+ CallbackInfoReturnable <Boolean > cir ) {
149+ if (cir .getReturnValue () == false ) {
150+ var player = MinecraftClient .getInstance ().player ;
151+ assert player != null ;
152+ var event = new PlayerEvent .World .SetPosition (player .getEntityPos (), player .getVelocity (), player .getYaw (), player .getPitch ());
153+ EventFlow .post (event );
154+ }
155+ }
128156}
0 commit comments