1717
1818package com .lambda .mixin .entity ;
1919
20- import com .lambda .Lambda ;
2120import com .lambda .event .EventFlow ;
2221import com .lambda .event .events .EntityEvent ;
2322import com .lambda .event .events .PlayerEvent ;
4241import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
4342import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
4443
44+ import static com .lambda .Lambda .getMc ;
45+
4546@ Mixin (Entity .class )
4647public abstract class EntityMixin {
4748 @ Shadow
@@ -56,7 +57,7 @@ public void move(MovementType movementType, Vec3d movement) {
5657 */
5758 @ WrapOperation (method = "updateVelocity" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/Entity;getYaw()F" ))
5859 public float velocityYaw (Entity entity , Operation <Float > original ) {
59- if ((Object ) this != Lambda . getMc ().player ) return original .call (entity );
60+ if ((Object ) this != getMc ().player ) return original .call (entity );
6061
6162 Float y = RotationManager .getMovementYaw ();
6263 if (y == null ) return original .call (entity );
@@ -75,7 +76,7 @@ public float velocityYaw(Entity entity, Operation<Float> original) {
7576 @ WrapOperation (method = "getRotationVec" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/Entity;getYaw(F)F" ))
7677 float fixDirectionYaw (Entity entity , float tickDelta , Operation <Float > original ) {
7778 Vec2d rot = RotationManager .getRotationForVector (tickDelta );
78- if (entity != Lambda . getMc ().player || rot == null ) return original .call (entity , tickDelta );
79+ if (entity != getMc ().player || rot == null ) return original .call (entity , tickDelta );
7980
8081 return (float ) rot .getX ();
8182 }
@@ -91,7 +92,7 @@ float fixDirectionYaw(Entity entity, float tickDelta, Operation<Float> original)
9192 @ WrapOperation (method = "getRotationVec" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/Entity;getPitch(F)F" ))
9293 float fixDirectionPitch (Entity entity , float tickDelta , Operation <Float > original ) {
9394 Vec2d rot = RotationManager .getRotationForVector (tickDelta );
94- if (entity != Lambda . getMc ().player || rot == null ) return original .call (entity , tickDelta );
95+ if (entity != getMc ().player || rot == null ) return original .call (entity , tickDelta );
9596
9697 return (float ) rot .getY ();
9798 }
@@ -107,7 +108,7 @@ float fixDirectionPitch(Entity entity, float tickDelta, Operation<Float> origina
107108 @ WrapOperation (method = "getRotationVector()Lnet/minecraft/util/math/Vec3d;" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/Entity;getYaw()F" ))
108109 float fixDirectionYaw2 (Entity entity , Operation <Float > original ) {
109110 Vec2d rot = RotationManager .getRotationForVector (1.0 );
110- if (entity != Lambda . getMc ().player || rot == null ) return original .call (entity );
111+ if (entity != getMc ().player || rot == null ) return original .call (entity );
111112
112113 return (float ) rot .getX ();
113114 }
@@ -123,7 +124,7 @@ float fixDirectionYaw2(Entity entity, Operation<Float> original) {
123124 @ WrapOperation (method = "getRotationVector()Lnet/minecraft/util/math/Vec3d;" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/Entity;getPitch()F" ))
124125 float fixDirectionPitch2 (Entity entity , Operation <Float > original ) {
125126 Vec2d rot = RotationManager .getRotationForVector (1.0 );
126- if (entity != Lambda . getMc ().player || rot == null ) return original .call (entity );
127+ if (entity != getMc ().player || rot == null ) return original .call (entity );
127128
128129 return (float ) rot .getY ();
129130 }
@@ -161,8 +162,8 @@ private boolean wrapSetPitch(Entity instance, float yaw) {
161162
162163 @ Inject (method = "isSprinting()Z" , at = @ At ("HEAD" ), cancellable = true )
163164 private void injectIsSprinting (CallbackInfoReturnable <Boolean > cir ) {
164- var player = Lambda . getMc ().player ;
165- if ((Object ) this != Lambda . getMc ().player ) return ;
165+ var player = getMc ().player ;
166+ if ((Object ) this != getMc ().player ) return ;
166167 if (ElytraFly .INSTANCE .isEnabled () && ElytraFly .getMode () == ElytraFly .FlyMode .Bounce && player .isGliding ()) cir .setReturnValue (true );
167168 }
168169
@@ -172,4 +173,9 @@ private void injectGetPose(CallbackInfoReturnable<EntityPose> cir) {
172173 if (!(entity instanceof ClientPlayerEntity player )) return ;
173174 if (ElytraFly .INSTANCE .isEnabled () && ElytraFly .getMode () == ElytraFly .FlyMode .Bounce && player .isGliding ()) cir .setReturnValue (EntityPose .GLIDING );
174175 }
176+
177+ @ ModifyExpressionValue (method = "getHorizontalFacing" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/Entity;getYaw()F" ))
178+ private float modifyGetYaw (float original ) {
179+ return (Object ) this == getMc ().player ? RotationManager .getServerRotation ().getYawF () : original ;
180+ }
175181}
0 commit comments