Пример #1
0
 /**
  * Updates this player's movement.
  *
  * @param packet The packet.
  */
 private void updateThisPlayerMovement(final PacketBuilder packet) {
   if (player.isTeleporting() || player.isMapRegionChanging()) {
     packet.putBits(1, 1);
     packet.putBits(2, 3);
     packet.putBits(7, player.getLocation().getLocalX(player.getLastKnownRegion()));
     packet.putBits(1, 1);
     packet.putBits(2, player.getLocation().getZ());
     packet.putBits(1, player.getUpdateFlags().isUpdateRequired() ? 1 : 0);
     packet.putBits(7, player.getLocation().getLocalY(player.getLastKnownRegion()));
   } else {
     if (player.getSprites().getPrimarySprite() == -1) {
       packet.putBits(1, player.getUpdateFlags().isUpdateRequired() ? 1 : 0);
       if (player.getUpdateFlags().isUpdateRequired()) {
         packet.putBits(2, 0);
       }
     } else {
       if (player.getSprites().getSecondarySprite() != -1) {
         packet.putBits(1, 1);
         packet.putBits(2, 2);
         packet.putBits(3, player.getSprites().getPrimarySprite());
         packet.putBits(3, player.getSprites().getSecondarySprite());
         packet.putBits(1, player.getUpdateFlags().isUpdateRequired() ? 1 : 0);
       } else {
         packet.putBits(1, 1);
         packet.putBits(2, 1);
         packet.putBits(3, player.getSprites().getPrimarySprite());
         packet.putBits(1, player.getUpdateFlags().isUpdateRequired() ? 1 : 0);
       }
     }
   }
 }
Пример #2
0
 /**
  * Updates a non-this player's movement.
  *
  * @param packet The packet.
  * @param otherPlayer The player.
  */
 public void updatePlayerMovement(PacketBuilder packet, Player otherPlayer) {
   if (otherPlayer.getSprites().getPrimarySprite() == -1) {
     if (otherPlayer.getUpdateFlags().isUpdateRequired()) {
       packet.putBits(1, 1);
       packet.putBits(2, 0);
     } else {
       packet.putBits(1, 0);
     }
   } else if (otherPlayer.getSprites().getSecondarySprite() == -1) {
     packet.putBits(1, 1);
     packet.putBits(2, 1);
     packet.putBits(3, otherPlayer.getSprites().getPrimarySprite());
     packet.putBits(1, otherPlayer.getUpdateFlags().isUpdateRequired() ? 1 : 0);
   } else {
     packet.putBits(1, 1);
     packet.putBits(2, 2);
     packet.putBits(3, otherPlayer.getSprites().getPrimarySprite());
     packet.putBits(3, otherPlayer.getSprites().getSecondarySprite());
     packet.putBits(1, otherPlayer.getUpdateFlags().isUpdateRequired() ? 1 : 0);
   }
 }