Advertisement
GamingLVScripts

motion event & server side rots

Jun 7th, 2025
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.62 KB | None | 0 0
  1. @Inject(method = "sendMovementPackets", at = @At("HEAD"), cancellable = true)
  2.     private void sendMovementPackets(CallbackInfo ci) {
  3.         ci.cancel();
  4.  
  5.         MotionEvent motionEvent = new MotionEvent(getX(), getY(), getZ(), getYaw(), getPitch(), isOnGround());
  6.         motionEvent.setState(MotionEvent.State.PRE);
  7.         motionEvent.post();
  8.  
  9.         this.sendSprintingPacket();
  10.  
  11.         if (this.isCamera()) {
  12.             double d = motionEvent.getX() - this.lastXClient;
  13.             double e = motionEvent.getY() - this.lastYClient;
  14.             double f = motionEvent.getZ() - this.lastZClient;
  15.             double g = motionEvent.getYaw() - this.lastYawClient;
  16.             double h = motionEvent.getPitch() - this.lastPitchClient;
  17.             this.ticksSinceLastPositionPacketSent++;
  18.  
  19.             boolean bl = MathHelper.squaredMagnitude(d, e, f) > MathHelper.square(2.0E-4) || this.ticksSinceLastPositionPacketSent >= 20;
  20.             boolean bl2 = g != 0.0 || h != 0.0;
  21.  
  22.             if (bl && bl2) {
  23.                 this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(motionEvent.getPos(), motionEvent.getYaw(), motionEvent.getPitch(), motionEvent.isOnGround(), this.horizontalCollision));
  24.             } else if (bl) {
  25.                 this.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(motionEvent.getPos(), motionEvent.isOnGround(), this.horizontalCollision));
  26.             } else if (bl2) {
  27.                 this.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(motionEvent.getYaw(), motionEvent.getPitch(), motionEvent.isOnGround(), this.horizontalCollision));
  28.             } else if (this.lastOnGround != motionEvent.isOnGround() || this.lastHorizontalCollision != this.horizontalCollision) {
  29.                 this.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(motionEvent.isOnGround(), this.horizontalCollision));
  30.             }
  31.  
  32.             if (bl) {
  33.                 this.lastXClient = motionEvent.getX();
  34.                 this.lastYClient = motionEvent.getY();
  35.                 this.lastZClient = motionEvent.getZ();
  36.                 this.ticksSinceLastPositionPacketSent = 0;
  37.             }
  38.  
  39.             if (bl2) {
  40.                 this.lastYawClient = motionEvent.getYaw();
  41.                 this.lastPitchClient = motionEvent.getPitch();
  42.             }
  43.  
  44.             this.lastOnGround = motionEvent.isOnGround();
  45.             this.lastHorizontalCollision = this.horizontalCollision;
  46.             this.autoJumpEnabled = this.client.options.getAutoJump().getValue();
  47.         }
  48.  
  49.         motionEvent.setState(MotionEvent.State.POST);
  50.         motionEvent.post();
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement