/** * Pre GPI/GMI Updating for movement. * * @param localUpdate * @param player * @param packet */ protected void manageMovement(boolean localUpdate, Player player, PacketBuilder packet) { int movementUpdateId = (localUpdate && (player.isTeleporting() || player.isMapRegionUpdate())) ? 3 : player.getDirections().getSecondDirection() != null ? 2 : player.getDirections().getDirection() != null ? 1 : player.getMasks().requiresUpdate() ? 0 : -1; /* * They are, so an update is required. */ packet.putBits(1, movementUpdateId == -1 ? 0 : 1); if (movementUpdateId != -1) { /* * tell the client that our player teleported/changeregion, has movement, or is standing still. */ packet.putBits(2, movementUpdateId); if (movementUpdateId == 3) { /** * Apply custom/scrambled bits for Teleport/region change */ handleRegionChange(player, packet); } else if (movementUpdateId > 0) { /* * Write the primary sprite (i.e. walk direction). */ packet.putBits(3, player.getDirections().getDirection().intValue()); if (movementUpdateId == 2) { /* * Write the secondary sprite (i.e. run direction). */ packet.putBits(3, player.getDirections().getSecondDirection().intValue()); } /* * Write a flag indicating if a block update happened. */ packet.putBits(1, player.getMasks().requiresUpdate() ? 1 : 0); } } }