Advertisement
Guest User

Untitled

a guest
Feb 4th, 2022
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. public void onPlayerPositionLook(PlayerPositionLookS2CPacket packet) {
  2. NetworkThreadUtils.forceMainThread(packet, this, this.client);
  3. PlayerEntity playerEntity = this.client.player;
  4. if (packet.shouldDismount()) {
  5. playerEntity.dismountVehicle();
  6. }
  7.  
  8. Vec3d vec3d = playerEntity.getVelocity();
  9. boolean bl = packet.getFlags().contains(Flag.X);
  10. boolean bl2 = packet.getFlags().contains(Flag.Y);
  11. boolean bl3 = packet.getFlags().contains(Flag.Z);
  12. double d;
  13. double e;
  14. if (bl) {
  15. d = vec3d.getX();
  16. e = playerEntity.getX() + packet.getX();
  17. playerEntity.lastRenderX += packet.getX();
  18. } else {
  19. d = 0.0D;
  20. e = packet.getX();
  21. playerEntity.lastRenderX = e;
  22. }
  23.  
  24. double f;
  25. double g;
  26. if (bl2) {
  27. f = vec3d.getY();
  28. g = playerEntity.getY() + packet.getY();
  29. playerEntity.lastRenderY += packet.getY();
  30. } else {
  31. f = 0.0D;
  32. g = packet.getY();
  33. playerEntity.lastRenderY = g;
  34. }
  35.  
  36. double h;
  37. double i;
  38. if (bl3) {
  39. h = vec3d.getZ();
  40. i = playerEntity.getZ() + packet.getZ();
  41. playerEntity.lastRenderZ += packet.getZ();
  42. } else {
  43. h = 0.0D;
  44. i = packet.getZ();
  45. playerEntity.lastRenderZ = i;
  46. }
  47.  
  48. playerEntity.setPos(e, g, i);
  49. playerEntity.prevX = e;
  50. playerEntity.prevY = g;
  51. playerEntity.prevZ = i;
  52. playerEntity.setVelocity(d, f, h);
  53. float j = packet.getYaw();
  54. float k = packet.getPitch();
  55. if (packet.getFlags().contains(Flag.X_ROT)) {
  56. k += playerEntity.getPitch();
  57. }
  58.  
  59. if (packet.getFlags().contains(Flag.Y_ROT)) {
  60. j += playerEntity.getYaw();
  61. }
  62.  
  63. playerEntity.updatePositionAndAngles(e, g, i, j, k);
  64. this.connection.send(new TeleportConfirmC2SPacket(packet.getTeleportId()));
  65. this.connection.send(new Full(playerEntity.getX(), playerEntity.getY(), playerEntity.getZ(), playerEntity.getYaw(), playerEntity.getPitch(), false));
  66. if (!this.positionLookSetup) {
  67. this.positionLookSetup = true;
  68. this.client.setScreen((Screen)null);
  69. }
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement