Advertisement
GamingLVScripts

handleEntityTeleport

Apr 1st, 2024
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. /**
  2.      * Updates an entity's position and rotation as specified by the packet
  3.      */
  4.     public void handleEntityTeleport(S18PacketEntityTeleport packetIn)
  5.     {
  6.         PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
  7.         Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
  8.  
  9.         if (entity != null)
  10.         {
  11.             entity.serverPosX = packetIn.getX();
  12.             entity.serverPosY = packetIn.getY();
  13.             entity.serverPosZ = packetIn.getZ();
  14.             double d0 = (double)entity.serverPosX / 32.0D;
  15.             double d1 = (double)entity.serverPosY / 32.0D;
  16.             double d2 = (double)entity.serverPosZ / 32.0D;
  17.             float f = (float)(packetIn.getYaw() * 360) / 256.0F;
  18.             float f1 = (float)(packetIn.getPitch() * 360) / 256.0F;
  19.  
  20.             if (Math.abs(entity.posX - d0) < 0.03125D && Math.abs(entity.posY - d1) < 0.015625D && Math.abs(entity.posZ - d2) < 0.03125D)
  21.             {
  22.                 entity.setPositionAndRotation2(entity.posX, entity.posY, entity.posZ, f, f1, 3, true);
  23.             }
  24.             else
  25.             {
  26.                 entity.setPositionAndRotation2(d0, d1, d2, f, f1, 3, true);
  27.             }
  28.  
  29.             if(entity == Minecraft.getMinecraft().thePlayer) {
  30.                 PlayerHandler.yaw = f;
  31.                 PlayerHandler.pitch = f1;
  32.             }
  33.  
  34.             entity.onGround = packetIn.getOnGround();
  35.         }
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement