2424import com .lambda .module .modules .movement .ElytraFly ;
2525import com .lambda .module .modules .movement .Velocity ;
2626import com .lambda .module .modules .render .ViewModel ;
27+ import com .llamalad7 .mixinextras .injector .ModifyExpressionValue ;
2728import com .llamalad7 .mixinextras .injector .ModifyReturnValue ;
2829import com .llamalad7 .mixinextras .injector .wrapmethod .WrapMethod ;
2930import com .llamalad7 .mixinextras .injector .wrapoperation .Operation ;
3031import com .llamalad7 .mixinextras .injector .wrapoperation .WrapOperation ;
32+ import com .llamalad7 .mixinextras .sugar .Local ;
33+ import com .llamalad7 .mixinextras .sugar .ref .LocalFloatRef ;
3134import net .minecraft .entity .Entity ;
3235import net .minecraft .entity .LivingEntity ;
33- import net .minecraft .util .math .MathHelper ;
3436import net .minecraft .util .math .Vec3d ;
3537import org .spongepowered .asm .mixin .Mixin ;
36- import org .spongepowered .asm .mixin .Shadow ;
3738import org .spongepowered .asm .mixin .Unique ;
3839import org .spongepowered .asm .mixin .injection .At ;
3940import org .spongepowered .asm .mixin .injection .Inject ;
@@ -45,44 +46,26 @@ public abstract class LivingEntityMixin extends EntityMixin {
4546
4647 @ Unique private final LivingEntity lambda$instance = (LivingEntity ) (Object ) this ;
4748
48- @ Shadow protected abstract float getJumpVelocity ();
49+ @ Inject (method = "jump" , at = @ At (value = "INVOKE_ASSIGN" , target = "Lnet/minecraft/entity/LivingEntity;getJumpVelocity()F" ), cancellable = true )
50+ void onJump (CallbackInfo ci , @ Local LocalFloatRef heightRef ) {
51+ if (lambda$instance != Lambda .getMc ().player ) return ;
4952
50- /**
51- * Overwrites the jump function to use our rotation and movements
52- * <pre>{@code
53- * protected void jump() {
54- * Vec3d vec3d = this.getVelocity();
55- * this.setVelocity(vec3d.x, (double)this.getJumpVelocity(), vec3d.z);
56- * if (this.isSprinting()) {
57- * float f = this.getYaw() * (float) (Math.PI / 180.0);
58- * this.setVelocity(this.getVelocity().add((double)(-MathHelper.sin(f) * 0.2F), 0.0, (double)(MathHelper.cos(f) * 0.2F)));
59- * }
60- *
61- * this.velocityDirty = true;
62- * }
63- * }</pre>
64- */
65- @ Inject (method = "jump" , at = @ At ("HEAD" ), cancellable = true )
66- void onJump (CallbackInfo ci ) {
67- LivingEntity self = lambda$instance ;
68- if (self != Lambda .getMc ().player ) return ;
69- ci .cancel ();
70-
71- float height = this .getJumpVelocity ();
53+ float height = heightRef .get ();
7254 MovementEvent .Jump event = EventFlow .post (new MovementEvent .Jump (height ));
55+ heightRef .set (event .getHeight ());
7356
74- if (event .isCanceled ()) return ;
75-
76- Vec3d vec3d = self . getVelocity ();
77- self . setVelocity ( vec3d . x , event . getHeight (), vec3d . z );
57+ if (event .isCanceled ()) {
58+ ci . cancel ();
59+ }
60+ }
7861
79- if (self .isSprinting ()) {
62+ @ ModifyExpressionValue (method = "jump" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/LivingEntity;getYaw()F" ))
63+ float hookModifyJumpYaw (float original ) {
64+ if (lambda$instance == Lambda .getMc ().player ) {
8065 Float yaw = RotationManager .getMovementYaw ();
81- float f = ((yaw != null ) ? yaw : self .getYaw ()) * ((float ) Math .PI / 180 );
82- self .setVelocity (self .getVelocity ().add (-MathHelper .sin (f ) * 0.2f , 0.0 , MathHelper .cos (f ) * 0.2f ));
66+ return yaw == null ? original : yaw ;
8367 }
84-
85- self .velocityDirty = true ;
68+ return original ;
8669 }
8770
8871 @ Inject (method = "travel" , at = @ At ("HEAD" ), cancellable = true )
0 commit comments