Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Inject(method = "sendMovementPackets", at = @At("HEAD"), cancellable = true)
- private void sendMovementPackets(CallbackInfo ci) {
- ci.cancel();
- MotionEvent motionEvent = new MotionEvent(getX(), getY(), getZ(), getYaw(), getPitch(), isOnGround());
- motionEvent.setState(MotionEvent.State.PRE);
- motionEvent.post();
- this.sendSprintingPacket();
- if (this.isCamera()) {
- double d = motionEvent.getX() - this.lastXClient;
- double e = motionEvent.getY() - this.lastYClient;
- double f = motionEvent.getZ() - this.lastZClient;
- double g = motionEvent.getYaw() - this.lastYawClient;
- double h = motionEvent.getPitch() - this.lastPitchClient;
- this.ticksSinceLastPositionPacketSent++;
- boolean bl = MathHelper.squaredMagnitude(d, e, f) > MathHelper.square(2.0E-4) || this.ticksSinceLastPositionPacketSent >= 20;
- boolean bl2 = g != 0.0 || h != 0.0;
- if (bl && bl2) {
- this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(motionEvent.getPos(), motionEvent.getYaw(), motionEvent.getPitch(), motionEvent.isOnGround(), this.horizontalCollision));
- } else if (bl) {
- this.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(motionEvent.getPos(), motionEvent.isOnGround(), this.horizontalCollision));
- } else if (bl2) {
- this.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(motionEvent.getYaw(), motionEvent.getPitch(), motionEvent.isOnGround(), this.horizontalCollision));
- } else if (this.lastOnGround != motionEvent.isOnGround() || this.lastHorizontalCollision != this.horizontalCollision) {
- this.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(motionEvent.isOnGround(), this.horizontalCollision));
- }
- if (bl) {
- this.lastXClient = motionEvent.getX();
- this.lastYClient = motionEvent.getY();
- this.lastZClient = motionEvent.getZ();
- this.ticksSinceLastPositionPacketSent = 0;
- }
- if (bl2) {
- this.lastYawClient = motionEvent.getYaw();
- this.lastPitchClient = motionEvent.getPitch();
- }
- this.lastOnGround = motionEvent.isOnGround();
- this.lastHorizontalCollision = this.horizontalCollision;
- this.autoJumpEnabled = this.client.options.getAutoJump().getValue();
- }
- motionEvent.setState(MotionEvent.State.POST);
- motionEvent.post();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement